Struct tor_units::BoundedInt32[][src]

pub struct BoundedInt32<const LOWER: i32, const UPPER: i32> { /* fields omitted */ }
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

Lower bound

Upper bound

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; othwerwise, 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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.