pub struct Positive<T>(/* private fields */)
where
T: PartialOrd + Default + Debug;Expand description
A number type that must be greater than zero.
Implementations§
Source§impl<T> Positive<T>
impl<T> Positive<T>
Sourcepub fn new(value: T) -> Result<Self, NotPositiveError<T>>
pub fn new(value: T) -> Result<Self, NotPositiveError<T>>
Create a new Positive if the given value is greater than 0 (T::default());
Sourcepub const unsafe fn new_unchecked(value: T) -> Self
pub const unsafe fn new_unchecked(value: T) -> Self
Create a new Positive without checking whether the value is greater than 0.
§Safety
The value must be greater than T::default().
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume self and return the inner value.
Trait Implementations§
impl<T> Copy for Positive<T>
impl<T> StructuralPartialEq for Positive<T>
Auto Trait Implementations§
impl<T> Freeze for Positive<T>where
T: Freeze,
impl<T> RefUnwindSafe for Positive<T>where
T: RefUnwindSafe,
impl<T> Send for Positive<T>where
T: Send,
impl<T> Sync for Positive<T>where
T: Sync,
impl<T> Unpin for Positive<T>where
T: Unpin,
impl<T> UnsafeUnpin for Positive<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Positive<T>where
T: UnwindSafe,
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<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