[][src]Trait embedded_time::duration::TryConvertFrom

pub trait TryConvertFrom<Source>: Sized {
    fn try_convert_from(other: Source) -> Option<Self>;
}

Required methods

fn try_convert_from(other: Source) -> Option<Self>

Loading content...

Implementors

impl<Source, Dest> TryConvertFrom<Source> for Dest where
    Dest: Duration,
    Dest::Rep: TimeRep + TryFrom<Source::Rep, Error: Debug>,
    Source: Duration,
    Source::Rep: TimeRep
[src]

fn try_convert_from(source: Source) -> Option<Self>[src]

Attempt to convert from one duration type to another

Both the underlying storage type and the LSbit period can be converted

Errors

  • unable to cast underlying types
  • LSbit period conversion overflow

Examples

assert_eq!(Seconds::<i32>::try_convert_from(Milliseconds(23_000_i64)), Some(Seconds(23_i32)));
assert_eq!(Seconds::<i64>::try_convert_from(Milliseconds(23_000_i32)), Some(Seconds(23_i64)));
Loading content...