Enum Type
pub enum Type {
Int(IntType),
Bool,
Ptr(PtrType),
Tuple {
sized_fields: List<(Size, Type)>,
sized_head_layout: TupleHeadLayout,
unsized_field: GcCow<Option<Type>>,
},
Array {
elem: GcCow<Type>,
count: Int,
},
Slice {
elem: GcCow<Type>,
},
Union {
fields: List<(Size, Type)>,
chunks: List<(Size, Size)>,
size: Size,
align: Align,
},
Enum {
variants: Map<Int, Variant>,
discriminant_ty: IntType,
discriminator: Discriminator,
size: Size,
align: Align,
},
TraitObject(TraitName),
}Expand description
The types of MiniRust.
Variants§
Int(IntType)
Bool
Ptr(PtrType)
Ptr represents all pointer types: references, raw pointers, boxes, function and vtable pointers.
A pointer type does not need the full pointee type, since (de)serializing a pointer does not
require knowledge about the pointee. We only track the metadata kind and basic pointee information
like size and alignment that is required to check reference validity. This also means types have a finite
representation even when the Rust type is recursive.
Tuple
“Tuple” is used for all heterogeneous types, i.e., both Rust tuples and structs.
Fields
sized_head_layout: TupleHeadLayoutThe layout of the sized fiels, i.e., the head.
Array
Slice
Slices, i.e. [T] are unsized types which therefore cannot be represented as values.
This type is also used for strings: str are treated as [u8].
Union
Fields
fields: List<(Size, Type)>Fields may overlap. Fields only exist for field access place projections, they are irrelevant for the representation relation.
chunks: List<(Size, Size)>A union can be split into multiple “chunks”, where only the data inside those chunks is
preserved, and data between chunks is lost (like padding in a struct).
This is necessary to model the behavior of some repr(C) unions, see
https://github.com/rust-lang/unsafe-code-guidelines/issues/156 for details.
Enum
Fields
variants: Map<Int, Variant>The map variants, each identified by a discriminant. Each variant is given by a type and its
tag description. All variants are thought to “start at offset 0”; if the
discriminant is encoded as an explicit tag, then that will be put into the
padding of the active variant. (This means it is not safe to hand out mutable
references to a variant at that type, as then the tag might be overwritten!)
The Rust type ! is encoded as an Enum with an empty list of variants.
discriminant_ty: IntTypeThe IntType for the discriminant. This is used for the type of
GetDiscriminant and SetDiscriminant. It is entirely independent of how
the discriminant is represented in memory (the “tag”).
discriminator: DiscriminatorThe decision tree to decode the discriminant from the tag at runtime.
TraitObject(TraitName)
A dyn TraitName. Commonly only used behind a pointer.
Implementations§
§impl Type
impl Type
pub fn layout<T>(self) -> LayoutStrategywhere
T: Target + Obj,
pub fn layout<T>(self) -> LayoutStrategywhere
T: Target + Obj,
The layout, i.e. the size and align of the type. For ?Sized types, this needs to be computed.
pub fn meta_kind(self) -> PointerMetaKind
pub fn meta_kind(self) -> PointerMetaKind
Returns the metadata kind when this type is used as a pointee. This matches the meta kind of the layout, but without needing to specify a target.
Trait Implementations§
impl Copy for Type
§impl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Type, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Type, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Type
§impl Ord for Type
impl Ord for Type
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialOrd for Type
impl PartialOrd for Type
§impl Serialize for Type
impl Serialize for Type
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl !Send for Type
impl !Sync for Type
impl Freeze for Type
impl RefUnwindSafe for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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