Skip to content

Commit

Permalink
remove never type in favor of infallible
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Jan 23, 2022
1 parent 7853103 commit 04e6cbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ mod entities;
mod error;
mod machine;
mod machine_helper;
mod never;
mod read_helper;
mod reader;
mod tokenizer;
Expand All @@ -25,6 +24,5 @@ pub mod testutils;

pub use emitter::{DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token};
pub use error::Error;
pub use never::Never;
pub use reader::{IoReader, Readable, Reader, StringReader};
pub use tokenizer::{InfallibleTokenizer, Tokenizer};
24 changes: 0 additions & 24 deletions src/never.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/reader.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Never;
use std::cmp::min;
use std::convert::Infallible;
use std::fs::File;
use std::io::{self, Read};

Expand Down Expand Up @@ -152,7 +152,7 @@ impl<'a> StringReader<'a> {
}

impl<'a> Reader for StringReader<'a> {
type Error = Never;
type Error = Infallible;

fn read_byte(&mut self) -> Result<Option<u8>, Self::Error> {
if self.input.is_empty() {
Expand Down
10 changes: 6 additions & 4 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::convert::Infallible;

use crate::char_validator::CharValidator;
use crate::machine;
use crate::machine_helper::MachineHelper;
use crate::read_helper::ReadHelper;
use crate::utils::{ControlToken, State};
use crate::{DefaultEmitter, Emitter, Never, Readable, Reader};
use crate::{DefaultEmitter, Emitter, Readable, Reader};

/// A HTML tokenizer. See crate-level docs for basic usage.
pub struct Tokenizer<R: Reader, E: Emitter = DefaultEmitter> {
Expand Down Expand Up @@ -96,9 +98,9 @@ impl<R: Reader, E: Emitter> Iterator for Tokenizer<R, E> {
/// `Result<Token, _>`.
///
/// This is the return value of [`Tokenizer::infallible`].
pub struct InfallibleTokenizer<R: Reader<Error = Never>, E: Emitter>(Tokenizer<R, E>);
pub struct InfallibleTokenizer<R: Reader<Error = Infallible>, E: Emitter>(Tokenizer<R, E>);

impl<R: Reader<Error = Never>, E: Emitter> Tokenizer<R, E> {
impl<R: Reader<Error = Infallible>, E: Emitter> Tokenizer<R, E> {
/// Statically assert that this iterator is infallible.
///
/// Call this to get rid of error handling when parsing HTML from strings.
Expand All @@ -107,7 +109,7 @@ impl<R: Reader<Error = Never>, E: Emitter> Tokenizer<R, E> {
}
}

impl<R: Reader<Error = Never>, E: Emitter> Iterator for InfallibleTokenizer<R, E> {
impl<R: Reader<Error = Infallible>, E: Emitter> Iterator for InfallibleTokenizer<R, E> {
type Item = E::Token;

fn next(&mut self) -> Option<Self::Item> {
Expand Down

0 comments on commit 04e6cbe

Please sign in to comment.