跳到主要内容

Duration

搜索

结构体 Duration 

Source
pub struct Duration(/* private fields */);
展开描述

用于表示近似时间长度的时长类型

实现§

Source§

impl Duration

Source

pub const fn new(sec: u64, nanos: u32) -> Duration

以指定的秒数与额外纳秒精度创建一个新的 Duration

Source

pub const fn from_days(days: u64) -> Duration

以指定的天数创建一个新的 Duration

Source

pub const fn from_hours(hours: u64) -> Duration

以指定的小时数创建一个新的 Duration

Source

pub const fn from_mins(mins: u64) -> Duration

以指定的分钟数创建一个新的 Duration

Source

pub const fn from_secs(secs: u64) -> Duration

以指定的秒数创建一个新的 Duration

Source

pub const fn from_millis(millis: u64) -> Duration

以指定的毫秒数创建一个新的 Duration

Source

pub const fn as_days(&self) -> u64

返回此时长所表示的天数

Source

pub const fn as_hours(&self) -> u64

返回此时长所表示的小时数

Source

pub const fn as_mins(&self) -> u64

返回此时长所表示的分钟数

Source

pub const fn as_secs(&self) -> u64

返回此时长所表示的完整秒数

Source

pub const fn as_millis(&self) -> u64

返回此时长所表示的完整毫秒数

Source

pub const fn as_micros(&self) -> u64

返回此时长所表示的完整微秒数

Source

pub const fn as_nanos(&self) -> u64

返回此时长所表示的完整纳秒数

Source

pub const fn subsec_nanos(&self) -> u32

返回此时长所表示的纳秒精度

Source

pub const fn as_ticks(&self) -> u64

以“刻度数”形式返回此时长。

请注意,一个‘刻度’的长度并不保证在不同平台上, 或在不同 coarsetime 版本之间代表相同的时间长度。

Source

pub const fn from_ticks(ticks: u64) -> Duration

以指定的“刻度数”创建一个新的 Duration。

请注意,一个‘刻度’的长度并不保证在不同平台上, 或在不同 coarsetime 版本之间代表相同的时间长度。

Source

pub fn as_f64(&self) -> f64

以浮点数形式返回此时长,表示的秒数

Source

pub const fn abs_diff(&self, other: Duration) -> Duration

返回两个 Duration 之间的绝对差

Source

pub const fn saturating_add(self, rhs: Duration) -> Duration

将两个时长相加,溢出时饱和

Source

pub fn checked_add(self, rhs: Duration) -> Option<Duration>

将两个时长相加,溢出时返回 None

Source

pub const fn saturating_sub(self, rhs: Duration) -> Duration

将两个时长相减,溢出/下溢时饱和

Source

pub fn checked_sub(self, rhs: Duration) -> Option<Duration>

将两个时长相减,溢出/下溢时返回 None

Source

pub const fn saturating_mul(self, rhs: u32) -> Duration

将时长乘以一个标量,溢出时饱和

Source

pub fn checked_mul(self, rhs: u32) -> Option<Duration>

将时长乘以一个标量,溢出时返回 None

Source

pub fn checked_div(self, rhs: u32) -> Option<Duration>

将时长除以一个标量,除以零时返回 None

Trait 实现§

Source§

impl Add<Duration> for Instant

Source§

type Output = Instant

应用 + 运算符后得到的类型。
Source§

fn add(self, rhs: Duration) -> Instant

Performs the + operation. 更多信息
Source§

impl Add for Duration

Source§

type Output = Duration

应用 + 运算符后得到的类型。
Source§

fn add(self, rhs: Duration) -> Duration

Performs the + operation. 更多信息
Source§

impl AddAssign<Duration> for Instant

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. 更多信息
Source§

impl AddAssign for Duration

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. 更多信息
Source§

impl Clone for Duration

Source§

fn clone(&self) -> Duration

返回值的副本。 更多信息
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 更多信息
Source§

impl Debug for Duration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

使用给定的格式化器格式化此值。 更多信息
Source§

impl Default for Duration

Source§

fn default() -> Duration

Returns the “default value” for a type. 更多信息
Source§

impl Div<u32> for Duration

Source§

type Output = Duration

应用 / 运算符后得到的类型。
Source§

fn div(self, rhs: u32) -> Duration

Performs the / operation. 更多信息
Source§

impl DivAssign<u32> for Duration

Source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. 更多信息
Source§

impl From<Duration> for Duration

Source§

fn from(duration: Duration) -> Duration

从输入类型转换为此类型。
Source§

impl From<Duration> for Duration

Source§

fn from(duration_sys: Duration) -> Duration

从输入类型转换为此类型。
Source§

impl Hash for Duration

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. 更多信息
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 更多信息
Source§

impl Mul<u32> for Duration

Source§

type Output = Duration

应用 * 运算符后得到的类型。
Source§

fn mul(self, rhs: u32) -> Duration

Performs the * operation. 更多信息
Source§

impl MulAssign<u32> for Duration

Source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. 更多信息
Source§

impl Ord for Duration

Source§

fn cmp(&self, other: &Duration) -> Ordering

This method returns an Ordering between self and other. 更多信息
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. 更多信息
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. 更多信息
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. 更多信息
Source§

impl PartialEq for Duration

Source§

fn eq(&self, other: &Duration) -> bool

测试 selfother 值是否相等,供 == 运算符使用。
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

测试 != 运算符。默认实现几乎总是够用,除非有非常充分的理由,否则不应被覆盖。
Source§

impl PartialOrd for Duration

Source§

fn partial_cmp(&self, other: &Duration) -> Option<Ordering>

若存在,此方法返回 selfother 值之间的排序关系。 更多信息
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

测试小于(针对 selfother),供 < 运算符使用。 更多信息
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. 更多信息
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. 更多信息
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. 更多信息
Source§

impl Sub<Duration> for Instant

Source§

type Output = Instant

应用 - 运算符后得到的类型。
Source§

fn sub(self, rhs: Duration) -> Instant

Performs the - operation. 更多信息
Source§

impl Sub for Duration

Source§

type Output = Duration

应用 - 运算符后得到的类型。
Source§

fn sub(self, rhs: Duration) -> Duration

Performs the - operation. 更多信息
Source§

impl SubAssign<Duration> for Instant

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. 更多信息
Source§

impl SubAssign for Duration

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. 更多信息
Source§

impl Copy for Duration

Source§

impl Eq for Duration

Source§

impl StructuralPartialEq for Duration

自动 Trait 实现§

Blanket 实现§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 更多信息
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 更多信息
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回传入的参数。

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

调用 U::from(self)

That is, this conversion is whatever the implementation of From<T> for U 的实现方式。

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

获得所有权后的类型。
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 更多信息
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

转换出错时返回的类型。
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。