summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-11 21:28:50 +0200
committerMartin Fischer <martin@push-f.com>2023-08-19 06:41:55 +0200
commit620deab83d13d9aeca3bb894e6fc20c516c1405f (patch)
tree0d30976ac31942bc0c99413460193b3d7be95f58
parent83144505291319395c1ba40035cf933786bf3422 (diff)
break!: remove Never in favor of std::convert::Infallible
This change is a backport of 04e6cbe[1] from html5gum. [1]: https://github.com/untitaker/html5gum/commit/04e6cbe44bb7a388bd61d1c9cfe4c618eb3b0e29
-rw-r--r--src/lib.rs2
-rw-r--r--src/never.rs21
-rw-r--r--src/reader.rs4
3 files changed, 2 insertions, 25 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 27ce00f..05e5824 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,7 +7,6 @@ mod emitter;
mod entities;
mod error;
mod machine;
-mod never;
mod reader;
pub mod spans;
mod tokenizer;
@@ -18,6 +17,5 @@ pub use utils::State as InternalState;
pub use emitter::{Attribute, DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token};
pub use error::Error;
-pub use never::Never;
pub use reader::{BufReadReader, IntoReader, Reader, StringReader};
pub use tokenizer::{State, Tokenizer};
diff --git a/src/never.rs b/src/never.rs
deleted file mode 100644
index 85a1243..0000000
--- a/src/never.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use std::error;
-use std::fmt;
-
-/// Definition of an empty enum.
-///
-/// This is used as the error type in situations where there can't be an error. A `Result<T, Never>`
-/// can be safely unwrapped and the `unwrap()` may be optimized away entirely.
-pub enum Never {}
-
-impl fmt::Display for Never {
- fn fmt(&self, _: &mut fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
- match *self {}
- }
-}
-impl fmt::Debug for Never {
- fn fmt(&self, _: &mut fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
- match *self {}
- }
-}
-
-impl error::Error for Never {}
diff --git a/src/reader.rs b/src/reader.rs
index 0e7a3a4..1acb4a3 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -1,4 +1,4 @@
-use crate::Never;
+use std::convert::Infallible;
use std::io::{self, BufRead, BufReader, Read};
/// An object that provides characters to the tokenizer.
@@ -67,7 +67,7 @@ impl<'a> StringReader<'a> {
}
impl<'a> Reader for StringReader<'a> {
- type Error = Never;
+ type Error = Infallible;
fn read_char(&mut self) -> Result<Option<char>, Self::Error> {
let c = match self.cursor.next() {