add unwrap_infallible tool

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-05-25 21:24:17 +00:00 committed by June 🍓🦴
parent dd1d8fa760
commit faa2b95c84

View file

@ -279,3 +279,15 @@ pub fn available_parallelism() -> usize {
.expect("Unable to query for available parallelism.")
.get()
}
/// Boilerplate for wraps which are typed to never error.
///
/// * <https://doc.rust-lang.org/std/convert/enum.Infallible.html>
#[must_use]
#[inline(always)]
pub fn unwrap_infallible<T>(result: Result<T, std::convert::Infallible>) -> T {
match result {
Ok(val) => val,
Err(err) => match err {},
}
}