Struct std::time::SystemTimeError
1.8.0 · source · [−]pub struct SystemTimeError(_);Expand description
An error returned from the duration_since and elapsed methods on
SystemTime, used to learn how far in the opposite direction a system time
lies.
Examples
use std::thread::sleep;
use std::time::{Duration, SystemTime};
let sys_time = SystemTime::now();
sleep(Duration::from_secs(1));
let new_sys_time = SystemTime::now();
match sys_time.duration_since(new_sys_time) {
Ok(_) => {}
Err(e) => println!("SystemTimeError difference: {:?}", e.duration()),
}RunImplementations
impl SystemTimeError
source
impl SystemTimeError
sourcepub fn duration(&self) -> Duration
source
pub fn duration(&self) -> Duration
sourceReturns the positive duration which represents how far forward the second system time was from the first.
A SystemTimeError is returned from the SystemTime::duration_since
and SystemTime::elapsed methods whenever the second system time
represents a point later in time than the self of the method call.
Examples
use std::thread::sleep;
use std::time::{Duration, SystemTime};
let sys_time = SystemTime::now();
sleep(Duration::from_secs(1));
let new_sys_time = SystemTime::now();
match sys_time.duration_since(new_sys_time) {
Ok(_) => {}
Err(e) => println!("SystemTimeError difference: {:?}", e.duration()),
}RunTrait Implementations
impl Clone for SystemTimeError
source
impl Clone for SystemTimeError
sourcefn clone(&self) -> SystemTimeError
source
fn clone(&self) -> SystemTimeError
sourceReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0 · source
fn clone_from(&mut self, source: &Self)
1.0.0 · sourcePerforms copy-assignment from source. Read more
impl Debug for SystemTimeError
source
impl Debug for SystemTimeError
sourceimpl Display for SystemTimeError
source
impl Display for SystemTimeError
sourceimpl Error for SystemTimeError
source
impl Error for SystemTimeError
sourcefn description(&self) -> &str
source
fn description(&self) -> &str
sourceuse the Display impl or to_string()
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0 · source
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0 · sourceThe lower-level source of this error, if any. Read more
Auto Trait Implementations
impl RefUnwindSafe for SystemTimeError
impl Send for SystemTimeError
impl Sync for SystemTimeError
impl Unpin for SystemTimeError
impl UnwindSafe for SystemTimeError
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
source
impl<T> BorrowMut<T> for T where
T: ?Sized,
sourcefn borrow_mut(&mut self) -> &mut T
const: unstable · source
fn borrow_mut(&mut self) -> &mut T
const: unstable · sourceMutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
source
impl<T> ToOwned for T where
T: Clone,
sourcetype Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
source
fn clone_into(&self, target: &mut T)
sourceUses borrowed data to replace owned data, usually by cloning. Read more