pub enum ScalaDegree {
Ratio(Ratio),
Cents(FloatType),
}Expand description
A single degree of a ScalaScale.
Scala files express each degree either as an exact ratio (3/2) or as a
cents value (701.955). The distinction is preserved rather than collapsed,
because a ratio carries exactness that cents cannot express.
Variants§
Ratio(Ratio)
An exact ratio, such as 3/2. A Scala file writes only ratios of
whole numbers, so this is always Ratio::Rational.
Cents(FloatType)
A cents value above the scale root, such as 701.955.
Implementations§
Source§impl ScalaDegree
impl ScalaDegree
Sourcepub fn as_ratio(self) -> Option<Ratio>
pub fn as_ratio(self) -> Option<Ratio>
Returns the exact ratio, when this degree was written as one.
Sourcepub fn written(self) -> String
pub fn written(self) -> String
The line a Scala file writes for this degree: the other half of the
reading FromStr does.
Scala tells the two spellings apart by the point: a value carrying one
is cents and a value without one is a ratio, so a whole number of
cents is written 1200.0 and never 1200, which would be a ratio of
twelve hundred to one.
Trait Implementations§
Source§impl Clone for ScalaDegree
impl Clone for ScalaDegree
impl Copy for ScalaDegree
Source§impl Debug for ScalaDegree
impl Debug for ScalaDegree
Source§impl<'de> Deserialize<'de> for ScalaDegree
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ScalaDegree
serde only.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>,
Source§impl Display for ScalaDegree
impl Display for ScalaDegree
Source§impl FromStr for ScalaDegree
impl FromStr for ScalaDegree
Source§impl PartialEq for ScalaDegree
impl PartialEq for ScalaDegree
Source§impl Serialize for ScalaDegree
Available on crate feature serde only.
impl Serialize for ScalaDegree
serde only.impl StructuralPartialEq for ScalaDegree
Auto Trait Implementations§
impl Freeze for ScalaDegree
impl RefUnwindSafe for ScalaDegree
impl Send for ScalaDegree
impl Sync for ScalaDegree
impl Unpin for ScalaDegree
impl UnsafeUnpin for ScalaDegree
impl UnwindSafe for ScalaDegree
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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