pub struct Fraction {
pub numerator: UnsignedIntegerType,
pub denominator: UnsignedIntegerType,
pub base: UnsignedIntegerType,
}Expand description
A ratio-like value used by tuning tables.
Fields§
§numerator: UnsignedIntegerTypeNumerator for a rational ratio, or exponent numerator when base is set.
denominator: UnsignedIntegerTypeDenominator for a rational ratio, or exponent denominator when base is set.
base: UnsignedIntegerTypeExponential base. A value of 0 means use numerator / denominator.
Implementations§
Source§impl Fraction
impl Fraction
Sourcepub const fn new(
numerator: UnsignedIntegerType,
denominator: UnsignedIntegerType,
) -> Self
pub const fn new( numerator: UnsignedIntegerType, denominator: UnsignedIntegerType, ) -> Self
Creates a rational fraction.
Sourcepub const fn new_with_base(
numerator: UnsignedIntegerType,
denominator: UnsignedIntegerType,
base: UnsignedIntegerType,
) -> Self
pub const fn new_with_base( numerator: UnsignedIntegerType, denominator: UnsignedIntegerType, base: UnsignedIntegerType, ) -> Self
Creates a fraction with an optional exponential base.
Sourcepub const fn numerator(&self) -> UnsignedIntegerType
pub const fn numerator(&self) -> UnsignedIntegerType
Returns the numerator.
Sourcepub const fn denominator(&self) -> UnsignedIntegerType
pub const fn denominator(&self) -> UnsignedIntegerType
Returns the denominator.
Sourcepub const fn base(&self) -> UnsignedIntegerType
pub const fn base(&self) -> UnsignedIntegerType
Returns the exponential base, or 0 for rational ratios.
Sourcepub fn with_octaves(self, octaves: UnsignedIntegerType) -> Self
pub fn with_octaves(self, octaves: UnsignedIntegerType) -> Self
Returns this fraction shifted upward by octaves.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Fraction
impl<'de> Deserialize<'de> for Fraction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<(u32, u32)> for Fraction
impl From<(u32, u32)> for Fraction
Source§fn from(frac: (UnsignedIntegerType, UnsignedIntegerType)) -> Self
fn from(frac: (UnsignedIntegerType, UnsignedIntegerType)) -> Self
Converts to this type from the input type.
Source§impl From<(u32, u32, u32)> for Fraction
impl From<(u32, u32, u32)> for Fraction
Source§fn from(
frac: (UnsignedIntegerType, UnsignedIntegerType, UnsignedIntegerType),
) -> Self
fn from( frac: (UnsignedIntegerType, UnsignedIntegerType, UnsignedIntegerType), ) -> Self
Converts to this type from the input type.
impl Copy for Fraction
impl Eq for Fraction
impl StructuralPartialEq for Fraction
Auto Trait Implementations§
impl Freeze for Fraction
impl RefUnwindSafe for Fraction
impl Send for Fraction
impl Sync for Fraction
impl Unpin for Fraction
impl UnsafeUnpin for Fraction
impl UnwindSafe for Fraction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more