custom_print/
never_error.rs

1use core::fmt::{self, Display, Formatter};
2#[cfg(feature = "std")]
3use std::error::Error;
4
5/// A helper error type that cannot be instantiated.
6///
7/// This error is used in [`ConcatWriter`] and [`ConcatTryWriter`]
8/// there [`writeln!`] is supposed to return [`Result`]
9/// but the `Result::Err` variant is not possible.
10///
11/// [`ConcatWriter`]: struct.ConcatWriter.html
12/// [`ConcatTryWriter`]: struct.ConcatTryWriter.html
13/// [`writeln!`]: https://doc.rust-lang.org/std/macro.writeln.html
14/// [`Result`]: https://doc.rust-lang.org/std/result/
15#[derive(Clone, Copy, Debug, Eq, PartialEq)]
16pub enum NeverError {}
17
18impl Display for NeverError {
19    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
20        let _ = f;
21        unreachable!();
22    }
23}
24
25#[cfg(feature = "std")]
26impl Error for NeverError {}