#[repr(packed)]
pub struct ScalarInt { data: u128, size: u8, }
Expand description

The raw bytes of a simple value.

This is a packed struct in order to allow this type to be optimally embedded in enums (like Scalar).

Fields

data: u128

The first size bytes of data are the value. Do not try to read less or more bytes than that. The remaining bytes must be 0.

size: u8

Implementations

Make sure the data fits in size. This is guaranteed by all constructors here, but having had this check saved us from bugs many times in the past, so keeping it around is definitely worth it.

Tries to convert the ScalarInt to an unsigned integer of the given size. Fails if the size of the ScalarInt is unequal to size and returns the ScalarInts size in that case.

Tries to convert the ScalarInt to u16. Fails if the size of the ScalarInt in not equal to Size { raw: 2 } and returns the size value of the ScalarInt in that case.

Tries to convert the ScalarInt to u32. Fails if the size of the ScalarInt in not equal to Size { raw: 4 } and returns the size value of the ScalarInt in that case.

Tries to convert the ScalarInt to u64. Fails if the size of the ScalarInt in not equal to Size { raw: 8 } and returns the size value of the ScalarInt in that case.

Tries to convert the ScalarInt to u128. Fails if the size of the ScalarInt in not equal to Size { raw: 16 } and returns the size value of the ScalarInt in that case.

Tries to convert the ScalarInt to a signed integer of the given size. Fails if the size of the ScalarInt is unequal to size and returns the ScalarInts size in that case.

Tries to convert the ScalarInt to i8. Fails if the size of the ScalarInt is unequal to Size { raw: 1 } and returns the ScalarInts size in that case.

Tries to convert the ScalarInt to i16. Fails if the size of the ScalarInt is unequal to Size { raw: 2 } and returns the ScalarInts size in that case.

Tries to convert the ScalarInt to i32. Fails if the size of the ScalarInt is unequal to Size { raw: 4 } and returns the ScalarInts size in that case.

Tries to convert the ScalarInt to i64. Fails if the size of the ScalarInt is unequal to Size { raw: 8 } and returns the ScalarInts size in that case.

Tries to convert the ScalarInt to i128. Fails if the size of the ScalarInt is unequal to Size { raw: 16 } and returns the ScalarInts size in that case.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

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

Formats the value using the given formatter.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

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

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more

This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes during red-green evaluation. The query system will only call this method if fingerprint_style() is not FingerprintStyle::Opaque. It is always valid to return None here, in which case incremental compilation will treat the query as having changed instead of forcing it. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 17 bytes