Struct tfm::Number

source ·
pub struct Number(pub i32);
Expand description

Fixed-width numeric type used in TFM files.

This numeric type has 11 bits for the integer part, 20 bits for the fractional part, and a single signed bit. The inner value is the number multiplied by 2^20. It is called a fix_word in TFtoPL.

In property list files, this type is represented as a decimal number with up to 6 digits after the decimal point. This is a non-lossy representation because 10^(-6) is larger than 2^(-20).

Tuple Fields§

§0: i32

Implementations§

source§

impl Number

source

pub const ZERO: Number = _

Representation of the number 0 as a Number.

source

pub const UNITY: Number = _

Representation of the number 1 as a Number.

source

pub fn is_abs_less_than_16(&self) -> bool

Returns true if the number is less than 16.0 in magnitude according to Knuth.

The number +16.0 is not allowed. This is covered in the E2E tests. See check_fix in TFtoPL.2014.60.

Trait Implementations§

source§

impl Add<Number> for Number

§

type Output = Number

The resulting type after applying the + operator.
source§

fn add(self, rhs: Number) -> Self::Output

Performs the + operation. Read more
source§

impl<'arbitrary> Arbitrary<'arbitrary> for Number

source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for Number

source§

fn clone(&self) -> Number

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Number

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Number

source§

fn default() -> Number

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

impl Display for Number

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Div<i32> for Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
source§

impl From<Number> for DesignSize

source§

fn from(value: Number) -> Self

Converts to this type from the input type.
source§

impl Hash for Number

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Mul<i32> for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
source§

impl Ord for Number

source§

fn cmp(&self, other: &Number) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Number> for Number

source§

fn eq(&self, other: &Number) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Number> for Number

source§

fn partial_cmp(&self, other: &Number) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

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

fn le(&self, other: &Rhs) -> bool

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

fn gt(&self, other: &Rhs) -> bool

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

fn ge(&self, other: &Rhs) -> bool

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

impl Sub<Number> for Number

§

type Output = Number

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Number) -> Self::Output

Performs the - operation. Read more
source§

impl Copy for Number

source§

impl Eq for Number

source§

impl StructuralEq for Number

source§

impl StructuralPartialEq for Number

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Fmt for Twhere T: Display,

§

fn fg<C>(self, color: C) -> Foreground<Self>where C: Into<Option<Color>>, Self: Display,

Give this value the specified foreground colour.
§

fn bg<C>(self, color: C) -> Background<Self>where C: Into<Option<Color>>, Self: Display,

Give this value the specified background colour.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.