pub struct NonNegativeUsize(/* private fields */);Expand description
A non-negative usize (≥0)
Many configuration values allow explicitly specifying 0 to disable a behavior (e.g., no blank
lines required) while still requiring validation for negative inputs during deserialization.
NonNegativeUsize captures that intent and guarantees the stored value is never negative.
Implementations§
Source§impl NonNegativeUsize
impl NonNegativeUsize
Sourcepub fn try_from_i64(value: i64) -> Result<Self, NonNegativeUsizeError>
pub fn try_from_i64(value: i64) -> Result<Self, NonNegativeUsizeError>
Attempt to create from a signed integer, validating it’s ≥0.
Sourcepub const fn from_const(value: usize) -> Self
pub const fn from_const(value: usize) -> Self
Convert from a const (for use in defaults).
Trait Implementations§
Source§impl Clone for NonNegativeUsize
impl Clone for NonNegativeUsize
Source§fn clone(&self) -> NonNegativeUsize
fn clone(&self) -> NonNegativeUsize
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NonNegativeUsize
impl Debug for NonNegativeUsize
Source§impl Default for NonNegativeUsize
impl Default for NonNegativeUsize
Source§fn default() -> NonNegativeUsize
fn default() -> NonNegativeUsize
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for NonNegativeUsize
impl<'de> Deserialize<'de> for NonNegativeUsize
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<NonNegativeUsize> for usize
impl From<NonNegativeUsize> for usize
Source§fn from(val: NonNegativeUsize) -> Self
fn from(val: NonNegativeUsize) -> Self
Converts to this type from the input type.
Source§impl Hash for NonNegativeUsize
impl Hash for NonNegativeUsize
Source§impl Ord for NonNegativeUsize
impl Ord for NonNegativeUsize
Source§fn cmp(&self, other: &NonNegativeUsize) -> Ordering
fn cmp(&self, other: &NonNegativeUsize) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for NonNegativeUsize
impl PartialEq for NonNegativeUsize
Source§impl PartialOrd for NonNegativeUsize
impl PartialOrd for NonNegativeUsize
Source§impl Serialize for NonNegativeUsize
impl Serialize for NonNegativeUsize
impl Copy for NonNegativeUsize
impl Eq for NonNegativeUsize
impl StructuralPartialEq for NonNegativeUsize
Auto Trait Implementations§
impl Freeze for NonNegativeUsize
impl RefUnwindSafe for NonNegativeUsize
impl Send for NonNegativeUsize
impl Sync for NonNegativeUsize
impl Unpin for NonNegativeUsize
impl UnwindSafe for NonNegativeUsize
Blanket Implementations§
Source§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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