pub struct PositiveUsize(/* private fields */);Expand description
A positive non-zero usize (≥1)
Many configuration values must be at least 1 (e.g., indentation sizes, spaces per tab). This type enforces that constraint at deserialization time, preventing invalid configs like “0 spaces per tab” or “0 character line length”.
Implementations§
Source§impl PositiveUsize
impl PositiveUsize
Sourcepub fn new(value: usize) -> Result<Self, PositiveUsizeError>
pub fn new(value: usize) -> Result<Self, PositiveUsizeError>
Create a new PositiveUsize, validating it’s at least 1.
§Errors
Returns PositiveUsizeError if the value is 0.
Sourcepub const fn from_const(value: usize) -> Self
pub const fn from_const(value: usize) -> Self
Convert from a default value (for use in config defaults).
§Panics
Panics if the value is 0. This is intended for const defaults only.
Trait Implementations§
Source§impl Clone for PositiveUsize
impl Clone for PositiveUsize
Source§fn clone(&self) -> PositiveUsize
fn clone(&self) -> PositiveUsize
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 PositiveUsize
impl Debug for PositiveUsize
Source§impl<'de> Deserialize<'de> for PositiveUsize
impl<'de> Deserialize<'de> for PositiveUsize
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<PositiveUsize> for usize
impl From<PositiveUsize> for usize
Source§fn from(val: PositiveUsize) -> Self
fn from(val: PositiveUsize) -> Self
Converts to this type from the input type.
Source§impl Hash for PositiveUsize
impl Hash for PositiveUsize
Source§impl Ord for PositiveUsize
impl Ord for PositiveUsize
Source§fn cmp(&self, other: &PositiveUsize) -> Ordering
fn cmp(&self, other: &PositiveUsize) -> 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 PositiveUsize
impl PartialEq for PositiveUsize
Source§impl PartialOrd for PositiveUsize
impl PartialOrd for PositiveUsize
Source§impl Serialize for PositiveUsize
impl Serialize for PositiveUsize
impl Copy for PositiveUsize
impl Eq for PositiveUsize
impl StructuralPartialEq for PositiveUsize
Auto Trait Implementations§
impl Freeze for PositiveUsize
impl RefUnwindSafe for PositiveUsize
impl Send for PositiveUsize
impl Sync for PositiveUsize
impl Unpin for PositiveUsize
impl UnwindSafe for PositiveUsize
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