Skip to main content

TimeDelta

Struct TimeDelta 

Source
pub struct TimeDelta { /* private fields */ }
Expand description

๐Ÿ•˜ A signed duration of time, stored as an (i64, i32) pair of secs and nanos.


๐Ÿ“ phys/time


Supports negative values, allowing representation of both past and future offsets.

ยงVendored

This is adapted work from jiff.

Implementationsยง

Sourceยง

impl TimeDelta

Additional APIs involving SystemInstant.

Source

pub fn after(&self, instant: SystemInstant) -> SystemInstant

Available on crate feature std only.

Adds a TimeDelta to an instant, moving forward or backward in time.

ยงPanics

Panics if the result is outside the valid range of SystemInstant.

Source

pub fn checked_after(&self, instant: SystemInstant) -> Option<SystemInstant> โ“˜

Available on crate feature std only.

Adds a TimeDelta to an instant

Returns None if the result is outside the valid range.

Sourceยง

impl TimeDelta

ยงBasic methods

Source

pub const ZERO: TimeDelta

A duration of zero time.

Source

pub const MIN: TimeDelta

The minimum possible duration. Or the โ€œmost negativeโ€ duration.

Source

pub const MAX: TimeDelta

The maximum possible duration.

Source

pub const fn new(secs: i64, nanos: i32) -> TimeDelta

Creates a new TimeDelta from the given number of whole seconds and additional nanoseconds.

If the absolute value of the nanoseconds is greater than or equal to 1 second, then the excess balances into the number of whole seconds.

ยงPanics

When the absolute value of the nanoseconds is greater than or equal to 1 second and the excess that carries over to the number of whole seconds overflows i64.

This never panics when nanos is less than 1_000_000_000.

Source

pub const fn from_secs(secs: i64) -> TimeDelta

Creates a new TimeDelta from the given number of whole seconds.

Source

pub const fn from_millis(millis: i64) -> TimeDelta

Creates a new TimeDelta from the given number of whole milliseconds.

Note that since this accepts an i64, this method cannot be used to construct the full range of possible time delta values. In particular, TimeDelta::as_millis returns an i128, and this may be a value that would otherwise overflow an i64.

Source

pub const fn from_micros(micros: i64) -> TimeDelta

Creates a new TimeDelta from the given number of whole microseconds.

Note that since this accepts an i64, this method cannot be used to construct the full range of possible time delta values. In particular, TimeDelta::as_micros returns an i128, and this may be a value that would otherwise overflow an i64.

Source

pub const fn from_nanos(nanos: i64) -> TimeDelta

Creates a new TimeDelta from the given number of whole nanoseconds.

Note that since this accepts an i64, this method cannot be used to construct the full range of possible time delta values. In particular, TimeDelta::as_nanos returns an i128, which may be a value that would otherwise overflow an i64.

Source

pub const fn from_hours(hours: i64) -> TimeDelta

Creates a new TimeDelta from the given number of hours. Every hour is exactly 3,600 seconds.

ยงPanics

Panics if the number of hours, after being converted to nanoseconds, overflows the minimum or maximum TimeDelta values.

Source

pub const fn from_mins(minutes: i64) -> TimeDelta

Creates a new TimeDelta from the given number of minutes. Every minute is exactly 60 seconds.

ยงPanics

Panics if the number of minutes, after being converted to nanoseconds, overflows the minimum or maximum TimeDelta values.

Source

pub const fn is_zero(&self) -> bool

Returns true if this duration spans no time.

Source

pub const fn as_secs(&self) -> i64

Returns the number of whole seconds in this duration.

The value returned is negative when the duration is negative.

This does not include any fractional component corresponding to units less than a second. To access those, use one of the subsec methods such as TimeDelta::subsec_nanos.

Source

pub const fn subsec_millis(&self) -> i32

Returns the fractional part of this duration in whole milliseconds.

The value returned is negative when the duration is negative. It is guaranteed that the range of the value returned is in the inclusive range -999..=999.

To get the length of the total duration represented in milliseconds, use TimeDelta::as_millis.

Source

pub const fn subsec_micros(&self) -> i32

Returns the fractional part of this duration in whole microseconds.

The value returned is negative when the duration is negative. It is guaranteed that the range of the value returned is in the inclusive range -999_999..=999_999.

To get the length of the total duration represented in microseconds, use TimeDelta::as_micros.

Source

pub const fn subsec_nanos(&self) -> i32

Returns the fractional part of this duration in whole nanoseconds.

The value returned is negative when the duration is negative. It is guaranteed that the range of the value returned is in the inclusive range -999_999_999..=999_999_999.

To get the length of the total duration represented in nanoseconds, use TimeDelta::as_nanos.

Source

pub const fn as_millis(&self) -> i128

Returns the total duration in units of whole milliseconds.

The value returned is negative when the duration is negative.

To get only the fractional component of this duration in units of whole milliseconds, use TimeDelta::subsec_millis.

Source

pub const fn as_micros(&self) -> i128

Returns the total duration in units of whole microseconds.

The value returned is negative when the duration is negative.

To get only the fractional component of this duration in units of whole microseconds, use TimeDelta::subsec_micros.

Source

pub const fn as_nanos(&self) -> i128

Returns the total duration in units of whole nanoseconds.

The value returned is negative when the duration is negative.

To get only the fractional component of this duration in units of whole nanoseconds, use TimeDelta::subsec_nanos.

Sourceยง

impl TimeDelta

Additional methods not found in the standard library.

In most cases, these APIs exist as a result of the fact that this duration is signed.

Source

pub const fn as_hours(&self) -> i64

Returns the number of whole hours in this duration.

The value returned is negative when the duration is negative.

This does not include any fractional component corresponding to units less than an hour.

Source

pub const fn as_mins(&self) -> i64

Returns the number of whole minutes in this duration.

The value returned is negative when the duration is negative.

This does not include any fractional component corresponding to units less than a minute.

Source

pub const fn abs(self) -> TimeDelta

Returns the absolute value of this time delta.

If this duration is positive, then this returns the original duration unchanged.

ยงPanics

This panics when the seconds component of this time delta is equal to i64::MIN.

Source

pub const fn neg_abs(self) -> TimeDelta

Returns the negative absolute value of this time delta.

If this duration is negative, then this returns the original duration unchanged.

ยงPanics

This panics when the seconds component of this time delta is equal to i64::MIN.

Source

pub const fn checked_neg(self) -> Option<TimeDelta> โ“˜

Returns this duration with its sign flipped.

If this duration is zero, then this returns the duration unchanged.

This returns none if the negation does not exist. This occurs in precisely the cases when TimeDelta::as_secs is equal to i64::MIN.

Source

pub const fn signum(self) -> i8

Returns a number that represents the sign of this duration.

The above cases are mutually exclusive.

Source

pub const fn is_positive(&self) -> bool

Returns true when this duration is positive. That is, greater than TimeDelta::ZERO.

Source

pub const fn is_negative(&self) -> bool

Returns true when this duration is negative. That is, less than TimeDelta::ZERO.

Sourceยง

impl TimeDelta

ยงOperations.

Source

pub const fn checked_add(self, rhs: TimeDelta) -> Option<TimeDelta> โ“˜

Add two time deltas together. If overflow occurs, then None is returned.

Source

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

Add two time deltas together. If overflow occurs, then arithmetic saturates.

Source

pub const fn checked_sub(self, rhs: TimeDelta) -> Option<TimeDelta> โ“˜

Subtract one time delta from another. If overflow occurs, then None is returned.

Source

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

Add two time deltas together. If overflow occurs, then arithmetic saturates.

Sourceยง

impl TimeDelta

ยงOperations involving integers.

Source

pub const fn checked_mul(self, rhs: i32) -> Option<TimeDelta> โ“˜

Multiply this time delta by an integer. If the multiplication overflows, then None is returned.

Source

pub const fn saturating_mul(self, rhs: i32) -> TimeDelta

Multiply this time delta by an integer.

If the multiplication overflows, then the result saturates to either the minimum or maximum duration depending on the sign of the product.

Source

pub const fn checked_div(self, rhs: i32) -> Option<TimeDelta> โ“˜

Divide this duration by an integer. If the division overflows, then None is returned.

Sourceยง

impl TimeDelta

ยงOperations involving floating-point numbers.

Source

pub const fn as_secs_f64(&self) -> f64

Returns the number of seconds, with a possible fractional nanosecond component.

Source

pub const fn as_secs_f32(&self) -> f32

Returns the number of seconds, with a possible fractional nanosecond component.

Source

pub const fn from_secs_f64(secs: f64) -> TimeDelta

Returns a time delta corresponding to the number of seconds.

The number given may have a fractional nanosecond component.

ยงPanics

Panics if the given float overflows the minimum or maximum time delta values.

Source

pub const fn from_secs_f32(secs: f32) -> TimeDelta

Returns a time delta corresponding to the number of seconds.

The number given may have a fractional nanosecond component.

ยงPanics

Panics if the given float overflows the minimum or maximum time delta values.

Source

pub const fn try_from_secs_f64(secs: f64) -> Result<TimeDelta, &'static str> โ“˜

Returns a time delta corresponding to the number of seconds.

The number given may have a fractional nanosecond component.

If the given float overflows the minimum or maximum time delta values, then an error is returned.

Source

pub const fn try_from_secs_f32(secs: f32) -> Result<TimeDelta, &'static str> โ“˜

Returns a time delta corresponding to the number of seconds.

The number given may have a fractional nanosecond component.

Returns an error if the given float overflows the minimum or maximum time delta values.

Source

pub const fn as_millis_f64(&self) -> f64

Returns the number of milliseconds, with a possible fractional nanosecond component.

Source

pub const fn as_millis_f32(&self) -> f32

Returns the number of milliseconds, with a possible fractional nanosecond component.

Source

pub const fn from_millis_f64(millis: f64) -> TimeDelta

Returns a time delta corresponding to the number of milliseconds.

The number given may have a fractional nanosecond component.

ยงPanics

Panics if the given float overflows the minimum or maximum time delta values.

Source

pub const fn try_from_millis_f64(millis: f64) -> Result<TimeDelta, &'static str> โ“˜

Returns a time delta corresponding to the number of milliseconds.

The number given may have a fractional nanosecond component.

Returns an error if the given float overflows the minimum or maximum time delta values.

Source

pub const fn mul_f64(self, rhs: f64) -> TimeDelta

Returns the result of multiplying this duration by the given 64-bit float.

ยงPanics

This panics if the result is not finite or overflows a TimeDelta.

Source

pub const fn mul_f32(self, rhs: f32) -> TimeDelta

Returns the result of multiplying this duration by the given 32-bit float.

ยงPanics

This panics if the result is not finite or overflows a TimeDelta.

Source

pub const fn div_f64(self, rhs: f64) -> TimeDelta

Returns the result of dividing this duration by the given f64.

ยงPanics

This panics if the result is not finite or overflows a TimeDelta.

Source

pub const fn div_f32(self, rhs: f32) -> TimeDelta

Returns the result of dividing this duration by the given f32.

ยงPanics

This panics if the result is not finite or overflows a TimeDelta.

Source

pub const fn div_delta_f64(self, rhs: TimeDelta) -> f64

Divides this time delta by another time delta.

Source

pub const fn div_delta_f32(self, rhs: TimeDelta) -> f32

Divides this time delta by another time delta.

Sourceยง

impl TimeDelta

ยงAdditional APIs involving Duration

.
Source

pub const fn from_duration(duration: Duration) -> Self

Converts a Duration to a TimeDelta.

Source

pub const fn to_duration(&self) -> Option<Duration> โ“˜

Converts a TimeDelta to a Duration if it is non-negative. Returns None if the TimeDelta is negative.

Source

pub const fn abs_duration(self) -> Duration

Returns the absolute value of this time delta as a Duration.

This method cannot panic because the absolute value of TimeDelta::MIN is always representable in a Duration.

Source

pub const fn checked_add_duration(&self, duration: Duration) -> Option<Self> โ“˜

Adds a Duration to this TimeDelta. Returns None if the result overflows.

Source

pub const fn checked_sub_duration(&self, duration: Duration) -> Option<Self> โ“˜

Subtracts a Duration from this TimeDelta. Returns None if the result underflows.

Sourceยง

impl TimeDelta

Source

pub const fn from_js(js: JsInstant) -> Self

Available on crate feature js only.

Converts a JsInstant into a TimeDelta relative to the time origin.

Source

pub const fn to_js(self) -> JsInstant

Available on crate feature js only.

Converts a TimeDelta into a JsInstant, interpreting it as an absolute timestamp.

Sourceยง

impl TimeDelta

Source

pub const fn from_jiff(from: SignedDuration) -> TimeDelta

Available on crate feature dep_jiff only.

Converts [SignedDuration] into TimeDelta.

Source

pub const fn to_jiff(self) -> SignedDuration

Available on crate feature dep_jiff only.

Converts TimeDelta into [SignedDuration].

Trait Implementationsยง

Sourceยง

impl Add for TimeDelta

Sourceยง

type Output = TimeDelta

The resulting type after applying the + operator.
Sourceยง

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

Performs the + operation. Read more
Sourceยง

impl Add<TimeDelta> for SystemInstant

Available on crate feature std only.

Shifts Instant forward or backward.

Sourceยง

type Output = Instant

The resulting type after applying the + operator.
Sourceยง

fn add(self, rhs: TimeDelta) -> SystemInstant

Performs the + operation. Read more
Sourceยง

impl AddAssign for TimeDelta

Sourceยง

fn add_assign(&mut self, rhs: TimeDelta)

Performs the += operation. Read more
Sourceยง

impl Clone for TimeDelta

Sourceยง

fn clone(&self) -> TimeDelta

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Performs copy-assignment from source. Read more
Sourceยง

impl Copy for TimeDelta

Sourceยง

impl Debug for TimeDelta

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for TimeDelta

Sourceยง

fn default() -> TimeDelta

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Div<i32> for TimeDelta

Sourceยง

type Output = TimeDelta

The resulting type after applying the / operator.
Sourceยง

fn div(self, rhs: i32) -> TimeDelta

Performs the / operation. Read more
Sourceยง

impl DivAssign<i32> for TimeDelta

Sourceยง

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
Sourceยง

impl Eq for TimeDelta

Sourceยง

impl From<SignedDuration> for TimeDelta

Available on crate feature dep_jiff only.
Sourceยง

fn from(from: SignedDuration) -> TimeDelta

Converts to this type from the input type.
Sourceยง

impl From<TimeDelta> for SignedDuration

Available on crate feature dep_jiff only.
Sourceยง

fn from(from: TimeDelta) -> SignedDuration

Converts to this type from the input type.
Sourceยง

impl Hash for TimeDelta

Sourceยง

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

Feeds this value into the given Hasher. Read more
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. Read more
Sourceยง

impl Mul<TimeDelta> for i32

Sourceยง

type Output = TimeDelta

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: TimeDelta) -> TimeDelta

Performs the * operation. Read more
Sourceยง

impl Mul<i32> for TimeDelta

Sourceยง

type Output = TimeDelta

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: i32) -> TimeDelta

Performs the * operation. Read more
Sourceยง

impl MulAssign<i32> for TimeDelta

Sourceยง

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
Sourceยง

impl Neg for TimeDelta

Sourceยง

type Output = TimeDelta

The resulting type after applying the - operator.
Sourceยง

fn neg(self) -> TimeDelta

Performs the unary - operation. Read more
Sourceยง

impl Ord for TimeDelta

Sourceยง

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) ยท Sourceยง

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) ยท Sourceยง

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) ยท Sourceยง

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

Restrict a value to a certain interval. Read more
Sourceยง

impl PartialEq for TimeDelta

Sourceยง

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) ยท Sourceยง

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl PartialOrd for TimeDelta

Sourceยง

fn partial_cmp(&self, other: &TimeDelta) -> Option<Ordering> โ“˜

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Sourceยง

impl StructuralPartialEq for TimeDelta

Sourceยง

impl Sub for TimeDelta

Sourceยง

type Output = TimeDelta

The resulting type after applying the - operator.
Sourceยง

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

Performs the - operation. Read more
Sourceยง

impl Sub<Instant> for TimeDelta

Available on crate feature std only.

Returns a signed TimeDelta.

Sourceยง

type Output = Instant

The resulting type after applying the - operator.
Sourceยง

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

Performs the - operation. Read more
Sourceยง

impl Sub<TimeDelta> for SystemInstant

Available on crate feature std only.

Moves Instant backward or forward.

Sourceยง

type Output = Instant

The resulting type after applying the - operator.
Sourceยง

fn sub(self, rhs: TimeDelta) -> SystemInstant

Performs the - operation. Read more
Sourceยง

impl SubAssign for TimeDelta

Sourceยง

fn sub_assign(&mut self, rhs: TimeDelta)

Performs the -= operation. Read more
Sourceยง

impl TimeSpan for TimeDelta

Sourceยง

const TIME_ZERO: Self = TimeDelta::ZERO

The additive zero span.
Sourceยง

fn time_add_checked(self, other: Self) -> Option<Self> โ“˜

Returns the sum of two spans, or None if it is not representable.
Sourceยง

fn time_sub_checked(self, other: Self) -> Option<Self> โ“˜

Returns the difference of two spans, or None if it is not representable.
Sourceยง

fn time_is_zero(self) -> bool

Returns whether this span is zero.
Sourceยง

fn time_add(self, other: Self) -> Self

Returns the sum of two spans. Read more
Sourceยง

fn time_sub(self, other: Self) -> Self

Returns the difference of two spans. Read more
Sourceยง

impl TryFrom<Duration> for TimeDelta

Sourceยง

type Error = &'static str

The type returned in the event of a conversion error.
Sourceยง

fn try_from(d: Duration) -> Result<TimeDelta, Self::Error> โ“˜

Performs the conversion.
Sourceยง

impl TryFrom<LinuxTimespec> for TimeDelta

Available on crate feature linux only.
Sourceยง

type Error = Overflow

The type returned in the event of a conversion error.
Sourceยง

fn try_from(timespec: LinuxTimespec) -> Result<Self, Self::Error> โ“˜

Performs the conversion.
Sourceยง

impl TryFrom<TimeDelta> for Duration

Sourceยง

type Error = &'static str

The type returned in the event of a conversion error.
Sourceยง

fn try_from(sd: TimeDelta) -> Result<Duration, Self::Error> โ“˜

Performs the conversion.
Sourceยง

impl TryFrom<TimeDelta> for LinuxTimespec

Available on crate feature linux only.
Sourceยง

type Error = Overflow

The type returned in the event of a conversion error.
Sourceยง

fn try_from(time_delta: TimeDelta) -> Result<Self, Self::Error> โ“˜

Performs the conversion.

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

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

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

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

Sourceยง

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Sourceยง

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Sourceยง

fn type_name(&self) -> &'static str โ“˜

Returns the type name of self. Read more
Sourceยง

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Sourceยง

fn type_hash(&self) -> u64

Returns a deterministic hash of the TypeId of Self.
Sourceยง

fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64

Returns a deterministic hash of the TypeId of Self using a custom hasher.
Sourceยง

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Sourceยง

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Sourceยง

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Available on crate feature alloc only.
Upcasts Box<self> as Box<dyn Any>. Read more
Sourceยง

fn downcast_ref<T: 'static>(&self) -> Option<&T> โ“˜

Available on crate feature unsafe_layout and non-crate feature safe_code only.
Returns some shared reference to the inner value if it is of type T. Read more
Sourceยง

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> โ“˜

Available on crate feature unsafe_layout and non-crate feature safe_code only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Sourceยง

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

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

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

Sourceยง

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

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> ByteSized for T

Sourceยง

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Sourceยง

const BYTE_SIZE: usize = _

The size of this type in bytes.
Sourceยง

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Sourceยง

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Sourceยง

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
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. Read more
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Hook for T

Sourceยง

fn hook<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Hooks a mutation step into the value and returns it. Read more
Sourceยง

fn tap<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Taps into the value for observation and returns it unchanged. Read more
Sourceยง

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

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

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

Sourceยง

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Sourceยง

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Sourceยง

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Sourceยง

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Sourceยง

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Sourceยง

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Sourceยง

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Sourceยง

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Sourceยง

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Sourceยง

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Sourceยง

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Sourceยง

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Sourceยง

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Sourceยง

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Sourceยง

fn mem_as_bytes(&self) -> &[u8] โ“˜
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Sourceยง

fn mem_as_bytes_mut(&mut self) -> &mut [u8] โ“˜
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Sourceยง

impl<T, R> Morph<R> for T
where T: ?Sized,

Sourceยง

fn morph<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Morphs the value into a new one and returns it. Read more
Sourceยง

fn morph_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Morphs the value by shared reference and returns the result. Read more
Sourceยง

fn morph_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Morphs the value by exclusive reference and returns the result. Read more
Sourceยง

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

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

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

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

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

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.
Sourceยง

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

Sourceยง

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

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.