Struct etterna::Rate [−][src]
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.
fn add(self, rhs: Self) -> Self::Output
[src]
impl AddAssign<Rate> for Rate
[src]
fn add_assign(&mut self, other: Self)
[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.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Rate
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Rate
[src]
fn cmp(&self, other: &Rate) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Rate> for Rate
[src]
impl PartialOrd<Rate> for Rate
[src]
fn partial_cmp(&self, other: &Rate) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[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.
fn sub(self, rhs: Self) -> Self::Output
[src]
impl SubAssign<Rate> for Rate
[src]
fn sub_assign(&mut self, other: Self)
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,