pub struct GlobalDefault { /* private fields */ }Expand description
A global default f64 value with atomic access.
This type provides thread-safe access to a global default value,
typically used for tolerance parameters like rtol.
§Example
use tensor4all_core::GlobalDefault;
static MY_DEFAULT: GlobalDefault = GlobalDefault::new(1e-12);
// Get the default value
let rtol = MY_DEFAULT.get();
// Set a new default value
MY_DEFAULT.set(1e-10).unwrap();Implementations§
Source§impl GlobalDefault
impl GlobalDefault
Sourcepub const fn new(initial: f64) -> Self
pub const fn new(initial: f64) -> Self
Create a new global default with the given initial value.
This is a const fn, so it can be used in static declarations.
Sourcepub fn set(&self, value: f64) -> Result<(), InvalidRtolError>
pub fn set(&self, value: f64) -> Result<(), InvalidRtolError>
Set a new default value.
§Errors
Returns InvalidRtolError if the value is not finite or is negative.
Sourcepub fn set_unchecked(&self, value: f64)
pub fn set_unchecked(&self, value: f64)
Set a new default value without validation.
§Safety
The caller must ensure the value is valid (finite and non-negative).
Trait Implementations§
impl Sync for GlobalDefault
Auto Trait Implementations§
impl !Freeze for GlobalDefault
impl RefUnwindSafe for GlobalDefault
impl Send for GlobalDefault
impl Unpin for GlobalDefault
impl UnwindSafe for GlobalDefault
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more