Struct tor_units::BoundedInt32 [−][src]
Expand description
A 32-bit signed integer with a restricted range.
This type holds an i32 value such that LOWER
<= value <= UPPER
Limitations
If you try to instantiate this type with LOWER > UPPER, you will get an uninhabitable type. It would be better if we could check that at compile time, and prevent such types from being named.
Implementations
Return the underlying i32 value.
This value will always be between Self::LOWER
and Self::UPPER
,
inclusive.
If val
is within range, return a new BoundedInt32
wrapping
it; otherwise, clamp it to the upper or lower bound as
appropriate.
If val
is an acceptable value inside the range for this type,
return a new BoundedInt32
. Otherwise return an error.
Convert from the underlying type, clamping to the upper or lower bound if needed.
Panics
This function will panic if UPPER < LOWER.
Convert from a string, clamping to the upper or lower bound if needed.
Limitations
If the input is a number that cannot be represented as an i32, then we return an error instead of clamping it.
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
impl<const LOWER: i32, const UPPER: i32> RefUnwindSafe for BoundedInt32<LOWER, UPPER>
impl<const LOWER: i32, const UPPER: i32> Send for BoundedInt32<LOWER, UPPER>
impl<const LOWER: i32, const UPPER: i32> Sync for BoundedInt32<LOWER, UPPER>
impl<const LOWER: i32, const UPPER: i32> Unpin for BoundedInt32<LOWER, UPPER>
impl<const LOWER: i32, const UPPER: i32> UnwindSafe for BoundedInt32<LOWER, UPPER>
Blanket Implementations
Mutably borrows from an owned value. Read more