Skip to main content

ScalarInt

Struct ScalarInt 

#[repr(packed(1))]
pub struct ScalarInt { data: u128, size: NonZero<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§size: NonZero<u8>

Implementations§

§

impl ScalarInt

pub const TRUE: ScalarInt

pub const FALSE: ScalarInt

pub fn size(self) -> Size

pub fn null(size: Size) -> ScalarInt

pub fn is_null(self) -> bool

pub fn try_from_uint(i: impl Into<u128>, size: Size) -> Option<ScalarInt>

pub fn truncate_from_uint(i: impl Into<u128>, size: Size) -> (ScalarInt, bool)

Returns the truncated result, and whether truncation changed the value.

pub fn try_from_int(i: impl Into<i128>, size: Size) -> Option<ScalarInt>

pub fn truncate_from_int(i: impl Into<i128>, size: Size) -> (ScalarInt, bool)

Returns the truncated result, and whether truncation changed the value.

pub fn try_from_target_usize( i: impl Into<u128>, data_layout: &TargetDataLayout, ) -> Option<ScalarInt>

pub fn try_to_bits(self, target_size: Size) -> Result<u128, Size>

Try to convert this ScalarInt to the raw underlying bits. Fails if the size is wrong. Generally a wrong size should lead to a panic, but Miri sometimes wants to be resilient to size mismatches, so the interpreter will generally use this try method.

pub fn to_bits(self, target_size: Size) -> u128

pub fn to_bits_unchecked(self) -> u128

Extracts the bits from the scalar without checking the size.

pub fn to_uint(self, size: Size) -> u128

Converts the ScalarInt to an unsigned integer of the given size. Panics if the size of the ScalarInt is not equal to size.

pub fn to_uint_unchecked(self) -> u128

pub fn to_u8(self) -> u8

Converts the ScalarInt to u8. Panics if the size of the ScalarIntin not equal to 1 byte.

pub fn to_u16(self) -> u16

Converts the ScalarInt to u16. Panics if the size of the ScalarInt in not equal to 2 bytes.

pub fn to_u32(self) -> u32

Converts the ScalarInt to u32. Panics if the size of the ScalarInt in not equal to 4 bytes.

pub fn to_u64(self) -> u64

Converts the ScalarInt to u64. Panics if the size of the ScalarInt in not equal to 8 bytes.

pub fn to_u128(self) -> u128

Converts the ScalarInt to u128. Panics if the size of the ScalarInt in not equal to 16 bytes.

pub fn to_target_usize(&self, data_layout: &TargetDataLayout) -> u64

pub fn try_to_bool(self) -> Result<bool, ()>

Converts the ScalarInt to bool. Panics if the size of the ScalarInt is not equal to 1 byte. Errors if it is not a valid bool.

pub fn to_int(self, size: Size) -> i128

Converts the ScalarInt to a signed integer of the given size. Panics if the size of the ScalarInt is not equal to size.

pub fn to_int_unchecked(self) -> i128

pub fn to_i8(self) -> i8

Converts the ScalarInt to i8. Panics if the size of the ScalarInt is not equal to 1 byte.

pub fn to_i16(self) -> i16

Converts the ScalarInt to i16. Panics if the size of the ScalarInt is not equal to 2 bytes.

pub fn to_i32(self) -> i32

Converts the ScalarInt to i32. Panics if the size of the ScalarInt is not equal to 4 bytes.

pub fn to_i64(self) -> i64

Converts the ScalarInt to i64. Panics if the size of the ScalarInt is not equal to 8 bytes.

pub fn to_i128(self) -> i128

Converts the ScalarInt to i128. Panics if the size of the ScalarInt is not equal to 16 bytes.

pub fn to_target_isize(&self, data_layout: &TargetDataLayout) -> i64

Trait Implementations§

§

impl Clone for ScalarInt

§

fn clone(&self) -> ScalarInt

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for ScalarInt

§

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

Formats the value using the given formatter. Read more
§

impl Display for ScalarInt

§

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

Formats the value using the given formatter. Read more
§

impl From<Ordering> for ScalarInt

§

fn from(c: Ordering) -> ScalarInt

Converts to this type from the input type.
§

impl From<bool> for ScalarInt

§

fn from(u: bool) -> ScalarInt

Converts to this type from the input type.
§

impl From<char> for ScalarInt

§

fn from(c: char) -> ScalarInt

Converts to this type from the input type.
§

impl From<i128> for ScalarInt

§

fn from(u: i128) -> ScalarInt

Converts to this type from the input type.
§

impl From<i16> for ScalarInt

§

fn from(u: i16) -> ScalarInt

Converts to this type from the input type.
§

impl From<i32> for ScalarInt

§

fn from(u: i32) -> ScalarInt

Converts to this type from the input type.
§

impl From<i64> for ScalarInt

§

fn from(u: i64) -> ScalarInt

Converts to this type from the input type.
§

impl From<i8> for ScalarInt

§

fn from(u: i8) -> ScalarInt

Converts to this type from the input type.
§

impl From<u128> for ScalarInt

§

fn from(u: u128) -> ScalarInt

Converts to this type from the input type.
§

impl From<u16> for ScalarInt

§

fn from(u: u16) -> ScalarInt

Converts to this type from the input type.
§

impl From<u32> for ScalarInt

§

fn from(u: u32) -> ScalarInt

Converts to this type from the input type.
§

impl From<u64> for ScalarInt

§

fn from(u: u64) -> ScalarInt

Converts to this type from the input type.
§

impl From<u8> for ScalarInt

§

fn from(u: u8) -> ScalarInt

Converts to this type from the input type.
§

impl<V> GenericTypeVisitable<V> for ScalarInt

§

fn generic_visit_with(&self, _visitor: &mut V)

§

impl Hash for ScalarInt

§

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

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
§

impl LowerHex for ScalarInt

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for ScalarInt

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl<'db> TypeFoldable<DbInterner<'db>> for ScalarInt

§

fn try_fold_with<F>( self, _: &mut F, ) -> Result<ScalarInt, <F as FallibleTypeFolder<DbInterner<'db>>>::Error>
where F: FallibleTypeFolder<DbInterner<'db>>,

The entry point for folding. To fold a value t with a folder f call: t.try_fold_with(f). Read more
§

fn fold_with<F>(self, _: &mut F) -> ScalarInt
where F: TypeFolder<DbInterner<'db>>,

The entry point for folding. To fold a value t with a folder f call: t.fold_with(f). Read more
§

impl<'db> TypeVisitable<DbInterner<'db>> for ScalarInt

§

fn visit_with<F>( &self, _: &mut F, ) -> <F as TypeVisitor<DbInterner<'db>>>::Result
where F: TypeVisitor<DbInterner<'db>>,

The entry point for visiting. To visit a value t with a visitor v call: t.visit_with(v). Read more
§

impl UpperHex for ScalarInt

§

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

Formats the value using the given formatter. Read more
§

impl Copy for ScalarInt

§

impl Eq for ScalarInt

§

impl StructuralPartialEq for ScalarInt

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> HashEqLike<&T> for T
where T: Hash + Eq,

§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

§

fn eq(&self, data: &&T) -> bool

§

impl<T> HashEqLike<Cow<'_, T>> for T
where T: Hash + Eq + Clone,

§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

§

fn eq(&self, data: &Cow<'_, T>) -> bool

§

impl<T> HashEqLike<T> for T
where T: Hash + Eq,

§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

§

fn eq(&self, data: &T) -> bool

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Sync + Send> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Sync + Send>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

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

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
§

impl<I, T> TypeVisitableExt<I> for T
where I: Interner, T: TypeVisitable<I>,

§

fn has_type_flags(&self, flags: TypeFlags) -> bool

§

fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool

Returns true if self has any late-bound regions that are either bound by binder or bound by some binder outside of binder. If binder is ty::INNERMOST, this indicates whether there are any late-bound regions that appear free.
§

fn error_reported(&self) -> Result<(), <I as Interner>::ErrorGuaranteed>

§

fn non_region_error_reported( &self, ) -> Result<(), <I as Interner>::ErrorGuaranteed>

§

fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool

Returns true if this type has any regions that escape binder (and hence are not bound by it).
§

fn has_escaping_bound_vars(&self) -> bool

Return true if this type has regions that are not a part of the type. For example, for<'a> fn(&'a i32) return false, while fn(&'a i32) would return true. The latter can occur when traversing through the former. Read more
§

fn has_aliases(&self) -> bool

§

fn has_opaque_types(&self) -> bool

§

fn has_coroutines(&self) -> bool

§

fn references_error(&self) -> bool

§

fn has_non_region_param(&self) -> bool

§

fn has_infer_regions(&self) -> bool

§

fn has_infer_types(&self) -> bool

§

fn has_non_region_infer(&self) -> bool

§

fn has_infer(&self) -> bool

§

fn has_placeholders(&self) -> bool

§

fn has_non_region_placeholders(&self) -> bool

§

fn has_param(&self) -> bool

§

fn has_free_regions(&self) -> bool

“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound.
§

fn has_erased_regions(&self) -> bool

§

fn has_erasable_regions(&self) -> bool

True if there are any un-erased free regions.
§

fn is_global(&self) -> bool

Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching.
§

fn has_bound_regions(&self) -> bool

True if there are any late-bound regions
§

fn has_non_region_bound_vars(&self) -> bool

True if there are any late-bound non-region variables
§

fn has_bound_vars(&self) -> bool

True if there are any bound variables
§

fn still_further_specializable(&self) -> bool

Indicates whether this value still has parameters/placeholders/inference variables which could be replaced later, in a way that would change the results of impl specialization.
§

fn has_non_region_error(&self) -> bool

True if a type or const error is reachable
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,