Struct geom::duration::Duration[][src]

pub struct Duration(f64);
Expand description

A duration, in seconds. Can be negative.

Implementations

Creates a duration in seconds.

Creates a duration in minutes.

Creates a duration in hours.

Creates a duration in minutes.

Returns the duration in seconds. Prefer working in typesafe Durations.

Splits the duration into (hours, minutes, seconds, deciseconds).

Parses a duration such as “3:00” to Duration::minutes(3).

If two durations are within this amount, they’ll print as if they’re the same.

Returns the duration elapsed from this moment in real time.

Rounds a duration up to the nearest whole number multiple.

Returns the duration as a number of minutes, rounded up.

Returns (rounded max, the boundaries)

Shows only the largest unit (hours, minute, seconds), rounded to precision decimal points.

use geom::Duration;
assert_eq!(Duration::seconds(3600.0).to_rounded_string(0), "1hr");
assert_eq!(Duration::seconds(3600.0).to_rounded_string(1), "1.0hr");
assert_eq!(Duration::seconds(7800.0).to_rounded_string(0), "2hr");
assert_eq!(Duration::seconds(800.0).to_rounded_string(1), "13.3min");
assert_eq!(Duration::seconds(-800.0).to_rounded_string(1), "-13.3min");
assert_eq!(Duration::seconds(0.0).to_rounded_string(0), "0");
assert_eq!(Duration::seconds(12.5).to_rounded_string(1), "12.5s");
assert_eq!(Duration::seconds(12.5).to_rounded_string(2), "12.50s");

Describes the duration according to formatting rules.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

Serialize this value into the given Serde serializer. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.