1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use std::fmt::{self, Display}; #[derive(Debug, PartialEq, Eq)] pub enum Never {} impl Never { pub fn result_ok<T>(r: Result<T, Never>) -> T { match r { Ok(t) => t, Err(_) => unreachable!(), } } } impl Display for Never { fn fmt(&self, _f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match self { _ => unreachable!(), } } }