#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate core;
use core::fmt::{self, Display, Formatter};
#[cfg(feature = "std")]
use std::{
error::Error,
io::{BufRead, Read, Seek, SeekFrom, Write},
};
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)]
pub enum Never {}
impl Never {
pub fn into_any<T>(self) -> T {
match self {}
}
pub fn to_any<T>(&self) -> T {
match *self {}
}
}
impl<T: ?Sized> AsRef<T> for Never {
fn as_ref(&self) -> &T {
self.to_any()
}
}
impl<T: ?Sized> AsMut<T> for Never {
fn as_mut(&mut self) -> &mut T {
self.to_any()
}
}
impl Display for Never {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
self.to_any()
}
}
#[cfg(feature = "std")]
impl Error for Never {}
#[cfg(feature = "std")]
impl Read for Never {
fn read(&mut self, _buf: &mut [u8]) -> std::io::Result<usize> {
self.to_any()
}
}
#[cfg(feature = "std")]
impl BufRead for Never {
fn fill_buf(&mut self) -> std::io::Result<&[u8]> {
self.to_any()
}
fn consume(&mut self, _amt: usize) {
self.to_any()
}
}
#[cfg(feature = "std")]
impl Seek for Never {
fn seek(&mut self, _pos: SeekFrom) -> std::io::Result<u64> {
self.to_any()
}
}
#[cfg(feature = "std")]
impl Write for Never {
fn write(&mut self, _buf: &[u8]) -> std::io::Result<usize> {
self.to_any()
}
fn flush(&mut self) -> std::io::Result<()> {
self.to_any()
}
}