add unwrap_infallible tool
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
dd1d8fa760
commit
faa2b95c84
1 changed files with 12 additions and 0 deletions
|
@ -279,3 +279,15 @@ pub fn available_parallelism() -> usize {
|
||||||
.expect("Unable to query for available parallelism.")
|
.expect("Unable to query for available parallelism.")
|
||||||
.get()
|
.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 {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue