pub struct NonNegativeDuration(/* private fields */);Expand description
A duration is a unit of time that represents the amount of time required to complete a task.
Implementations§
Source§impl NonNegativeDuration
impl NonNegativeDuration
Sourcepub fn parse_from_str(s: &str) -> Result<Self, DurationError>
pub fn parse_from_str(s: &str) -> Result<Self, DurationError>
Tries to parse a string and return the corresponding [NonNegativeDuration]
§Arguments
s- The string to parse. Currently, only hours are supported in the format “X h”.
§Returns
Ok(NonNegativeDuration)- If the input string could be parsed into aNonNegativeDuration.Err(DurationError)- If the input string couldn’t be parsed into aNonNegativeDuration.
§Errors
DurationError::InvalidInput- If the input string couldn’t be parsed into aNonNegativeDuration.
§Examples
use planter_core::duration::NonNegativeDuration;
let duration = NonNegativeDuration::parse_from_str("8 h").unwrap();
assert_eq!(duration.num_hours(), 8);Trait Implementations§
Source§impl Clone for NonNegativeDuration
impl Clone for NonNegativeDuration
Source§fn clone(&self) -> NonNegativeDuration
fn clone(&self) -> NonNegativeDuration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for NonNegativeDuration
Source§impl Debug for NonNegativeDuration
impl Debug for NonNegativeDuration
Source§impl Default for NonNegativeDuration
impl Default for NonNegativeDuration
Source§fn default() -> NonNegativeDuration
fn default() -> NonNegativeDuration
Returns the “default value” for a type. Read more
Source§impl Deref for NonNegativeDuration
impl Deref for NonNegativeDuration
Source§impl Display for NonNegativeDuration
impl Display for NonNegativeDuration
impl Eq for NonNegativeDuration
Source§impl FromStr for NonNegativeDuration
impl FromStr for NonNegativeDuration
Source§impl Ord for NonNegativeDuration
impl Ord for NonNegativeDuration
Source§fn cmp(&self, other: &NonNegativeDuration) -> Ordering
fn cmp(&self, other: &NonNegativeDuration) -> Ordering
1.21.0 (const: unstable) · 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 NonNegativeDuration
impl PartialEq for NonNegativeDuration
Source§fn eq(&self, other: &NonNegativeDuration) -> bool
fn eq(&self, other: &NonNegativeDuration) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NonNegativeDuration
impl PartialOrd for NonNegativeDuration
impl StructuralPartialEq for NonNegativeDuration
Auto Trait Implementations§
impl Freeze for NonNegativeDuration
impl RefUnwindSafe for NonNegativeDuration
impl Send for NonNegativeDuration
impl Sync for NonNegativeDuration
impl Unpin for NonNegativeDuration
impl UnsafeUnpin for NonNegativeDuration
impl UnwindSafe for NonNegativeDuration
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