Struct etterna::Rate[][src]

pub struct Rate { /* fields omitted */ }

Represents an Etterna chart rate (music speed).

As in Etterna, this value can only be a multiple of 0.05. The value can’t be negative, nor NaN or infinity.

When printed, a Rate is formatted as usual in Etterna; two floating point digits and an x at the end: 0.85x, 1.00x, 2.40x

Implementations

impl Rate[src]

pub fn from_f32(r: f32) -> Option<Self>[src]

Rounds to the nearest valid rate.

Returns None if the given value is negative or too large

pub fn from_string(string: &str) -> Option<Self>[src]

Parses a string into a rate. The string needs to be in the format \d+\.\d+[05]?

Returns None if parsing failed

pub fn from_x20(x20: u32) -> Self[src]

Create a new rate from a value that is equal to the real rate multiplied by 20.

Due to the fact that Etterna ratings are always multiples of 0.05, every rate can be precicely represented precisely with a whole number when multiplied by 20.

pub fn as_f32(self) -> f32[src]

Returns an f32 representation of this rate.

assert_eq!(Rate::from_string("1.40").unwrap().as_f32(), 1.4);

pub fn as_x20(self) -> u32[src]

Returns this rate multiplied by 20. This will always result in a whole number, hence this function returns an integer.

assert_eq!(Rate::from_string("1.45").unwrap().as_x20(), 29);

Trait Implementations

impl Add<Rate> for Rate[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Rate> for Rate[src]

impl Clone for Rate[src]

impl Copy for Rate[src]

impl Debug for Rate[src]

impl Default for Rate[src]

impl Display for Rate[src]

impl Eq for Rate[src]

impl From<f32> for Rate[src]

impl FromStr for Rate[src]

type Err = RateParseError

The associated error which can be returned from parsing.

impl Hash for Rate[src]

impl Ord for Rate[src]

impl PartialEq<Rate> for Rate[src]

impl PartialOrd<Rate> for Rate[src]

impl StructuralEq for Rate[src]

impl StructuralPartialEq for Rate[src]

impl Sub<Rate> for Rate[src]

type Output = Self

The resulting type after applying the - operator.

impl SubAssign<Rate> for Rate[src]

Auto Trait Implementations

impl RefUnwindSafe for Rate

impl Send for Rate

impl Sync for Rate

impl Unpin for Rate

impl UnwindSafe for Rate

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.