//! # Void //! //! The uninhabited void type for use in statically impossible cases. //! //! In its own crate so all the users in the ecosystem can share the same type. //! This crate also comes ready with several extension traits for Result that add //! extra functionality to `Result<T, Void>` and `Result<Void, E>`. //!
/// A safe version of `intrinsincs::unreachable`. /// /// If this typechecks, anything that causes this to run is unreachable code. /// /// Calling this function in reachable code invokes undefined behavior, but /// should not be possible unless `unsafe` was used elsewhere to construct /// an instance of `Void` (which is already undefined behavior). #[inline(always)] pubfn unreachable(x: Void) -> ! { match x {}
}
/// Extensions to `Result<T, Void>` pubtrait ResultVoidExt<T>: Sized { /// Get the value out of a wrapper. fn void_unwrap(self) -> T;
}
impl<T> ResultVoidExt<T> for Result<T, Void> { /// Get the value out of an always-ok Result. /// /// Never panics, since it is statically known to be Ok. #[inline] fn void_unwrap(self) -> T { matchself {
Ok(val) => val,
Err(e) => unreachable(e)
}
}
}
/// Extensions to `Result<Void, E>` pubtrait ResultVoidErrExt<E>: Sized { /// Get the error out of a wrapper. fn void_unwrap_err(self) -> E;
}
impl<E> ResultVoidErrExt<E> for Result<Void, E> { /// Get the error out of an always-err Result. /// /// Never panics, since it is statically known to be Err. #[inline] fn void_unwrap_err(self) -> E { matchself {
Ok(v) => unreachable(v),
Err(e) => e
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.