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
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)
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)
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>
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
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
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
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
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
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
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
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, ()>
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
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
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
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
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
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
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<V> GenericTypeVisitable<V> for ScalarInt
impl<V> GenericTypeVisitable<V> for ScalarInt
fn generic_visit_with(&self, _visitor: &mut V)
§impl<'db> TypeFoldable<DbInterner<'db>> for ScalarInt
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>>,
fn try_fold_with<F>(
self,
_: &mut F,
) -> Result<ScalarInt, <F as FallibleTypeFolder<DbInterner<'db>>>::Error>where
F: FallibleTypeFolder<DbInterner<'db>>,
§impl<'db> TypeVisitable<DbInterner<'db>> for ScalarInt
impl<'db> TypeVisitable<DbInterner<'db>> for ScalarInt
§fn visit_with<F>(
&self,
_: &mut F,
) -> <F as TypeVisitor<DbInterner<'db>>>::Resultwhere
F: TypeVisitor<DbInterner<'db>>,
fn visit_with<F>(
&self,
_: &mut F,
) -> <F as TypeVisitor<DbInterner<'db>>>::Resultwhere
F: TypeVisitor<DbInterner<'db>>,
impl Copy for ScalarInt
impl Eq for ScalarInt
impl StructuralPartialEq for ScalarInt
Auto Trait Implementations§
impl Freeze for ScalarInt
impl RefUnwindSafe for ScalarInt
impl Send for ScalarInt
impl Sync for ScalarInt
impl Unpin for ScalarInt
impl UnsafeUnpin for ScalarInt
impl UnwindSafe for ScalarInt
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Lookup<T> for T
impl<T> Lookup<T> for T
fn into_owned(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
§impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
fn has_type_flags(&self, flags: TypeFlags) -> bool
§fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
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
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
true if this type has any regions that escape binder (and
hence are not bound by it).§fn has_escaping_bound_vars(&self) -> bool
fn has_escaping_bound_vars(&self) -> bool
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 morefn 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
fn has_free_regions(&self) -> bool
fn has_erased_regions(&self) -> bool
§fn has_erasable_regions(&self) -> bool
fn has_erasable_regions(&self) -> bool
§fn is_global(&self) -> bool
fn is_global(&self) -> bool
§fn has_bound_regions(&self) -> bool
fn has_bound_regions(&self) -> bool
§fn has_non_region_bound_vars(&self) -> bool
fn has_non_region_bound_vars(&self) -> bool
§fn has_bound_vars(&self) -> bool
fn has_bound_vars(&self) -> bool
§fn still_further_specializable(&self) -> bool
fn still_further_specializable(&self) -> bool
impl
specialization.