|
|
@ -1,5 +1,3 @@
|
|
|
|
use alloc::string::String;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Calls a function and aborts if it panics.
|
|
|
|
/// Calls a function and aborts if it panics.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// This is useful in unsafe code where we can't recover from panics.
|
|
|
|
/// This is useful in unsafe code where we can't recover from panics.
|
|
|
@ -55,6 +53,7 @@ pub fn random(n: u32) -> u32 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Add additional context to errors
|
|
|
|
/// Add additional context to errors
|
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
pub(crate) trait Context {
|
|
|
|
pub(crate) trait Context {
|
|
|
|
fn context(self, message: impl Fn() -> String) -> Self;
|
|
|
|
fn context(self, message: impl Fn() -> String) -> Self;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -148,7 +147,7 @@ macro_rules! cfg_unstable_default {
|
|
|
|
($($item:item)*) => {
|
|
|
|
($($item:item)*) => {
|
|
|
|
$(
|
|
|
|
$(
|
|
|
|
#[cfg(all(feature = "default", feature = "unstable"))]
|
|
|
|
#[cfg(all(feature = "default", feature = "unstable"))]
|
|
|
|
#[cfg_attr(feature = "docs", doc(unstable))]
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
|
|
$item
|
|
|
|
$item
|
|
|
|
)*
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -161,7 +160,6 @@ macro_rules! cfg_unix {
|
|
|
|
($($item:item)*) => {
|
|
|
|
($($item:item)*) => {
|
|
|
|
$(
|
|
|
|
$(
|
|
|
|
#[cfg(any(unix, feature = "docs"))]
|
|
|
|
#[cfg(any(unix, feature = "docs"))]
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(unix)))]
|
|
|
|
|
|
|
|
$item
|
|
|
|
$item
|
|
|
|
)*
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -174,7 +172,6 @@ macro_rules! cfg_windows {
|
|
|
|
($($item:item)*) => {
|
|
|
|
($($item:item)*) => {
|
|
|
|
$(
|
|
|
|
$(
|
|
|
|
#[cfg(any(windows, feature = "docs"))]
|
|
|
|
#[cfg(any(windows, feature = "docs"))]
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(windows)))]
|
|
|
|
|
|
|
|
$item
|
|
|
|
$item
|
|
|
|
)*
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|