Skip to main content

TypeKind

Enum TypeKind 

Source
pub enum TypeKind {
Show 46 variants I8, I16, I32, I64, U8, U16, U32, U64, Isize, Usize, F16, F32, F64, Bool, Char, Unit, CSchar, CShort, CInt, CLong, CLonglong, CUchar, CUshort, CUint, CUlong, CUlonglong, CFloat, CDouble, CVoid, Struct(StructId), Enum(EnumId), Interface(InterfaceId), Array(ArrayTypeId), PtrConst(PtrConstTypeId), PtrMut(PtrMutTypeId), Ref(RefTypeId), MutRef(MutRefTypeId), Slice(SliceTypeId), MutSlice(MutSliceTypeId), Vec(VecTypeId), Module(ModuleId), Error, Never, ComptimeType, ComptimeStr, ComptimeInt,
}
Expand description

The kind of a type - used for pattern matching.

This enum mirrors the structure of the Type enum but is designed for pattern matching. During the migration to Type(InternedType), code that pattern matches on types will use ty.kind() to get a TypeKind.

This separation allows incremental migration: all pattern matches can be updated to use .kind() while Type is still an enum, then Type can be replaced with Type(InternedType) without breaking existing code.

Variants§

§

I8

8-bit signed integer

§

I16

16-bit signed integer

§

I32

32-bit signed integer

§

I64

64-bit signed integer

§

U8

8-bit unsigned integer

§

U16

16-bit unsigned integer

§

U32

32-bit unsigned integer

§

U64

64-bit unsigned integer

§

Isize

Pointer-sized signed integer

§

Usize

Pointer-sized unsigned integer

§

F16

IEEE 754 binary16 (half-precision float)

§

F32

IEEE 754 binary32 (single-precision float)

§

F64

IEEE 754 binary64 (double-precision float)

§

Bool

Boolean

§

Char

Unicode scalar value (ADR-0071)

§

Unit

The unit type (for functions that don’t return a value)

§

CSchar

ADR-0086: C signed char — target-resolved (8-bit signed on every blessed target).

§

CShort

ADR-0086: C short — target-resolved (16-bit signed on every blessed target).

§

CInt

ADR-0086: C int — target-resolved (32-bit signed on every blessed target). Canonical discriminant type for @mark(c) enum.

§

CLong

ADR-0086: C long — target-resolved (64-bit signed on every blessed LP64 target; 32-bit on hypothetical LLP64 targets like Windows).

§

CLonglong

ADR-0086: C long long — target-resolved (64-bit signed on every blessed target).

§

CUchar

ADR-0086: C unsigned char — target-resolved (8-bit unsigned on every blessed target).

§

CUshort

ADR-0086: C unsigned short — target-resolved (16-bit unsigned on every blessed target).

§

CUint

ADR-0086: C unsigned int — target-resolved (32-bit unsigned on every blessed target).

§

CUlong

ADR-0086: C unsigned long — target-resolved (64-bit unsigned on every blessed LP64 target).

§

CUlonglong

ADR-0086: C unsigned long long — target-resolved (64-bit unsigned on every blessed target).

§

CFloat

ADR-0086: C float — IEEE 754 binary32 on every blessed target.

§

CDouble

ADR-0086: C double — IEEE 754 binary64 on every blessed target.

§

CVoid

ADR-0086: C void — incomplete type. No values, no size, no alignment. Only usable through Ptr(c_void) / MutPtr(c_void). Cannot appear in value-bearing positions (let, return, parameter by value, struct/enum field by value). Use () (unit) for C void return types.

§

Struct(StructId)

User-defined struct type

§

Enum(EnumId)

User-defined enum type

§

Interface(InterfaceId)

User-defined interface type (ADR-0056). Used both as the bound on a comptime T: I parameter and (Phase 4) as a runtime type behind a borrowing parameter.

§

Array(ArrayTypeId)

Fixed-size array type: [T; N]

§

PtrConst(PtrConstTypeId)

Raw pointer to immutable data: ptr const T

§

PtrMut(PtrMutTypeId)

Raw pointer to mutable data: ptr mut T

§

Ref(RefTypeId)

Immutable reference (ADR-0062): Ref(T) — scope-bound, exclusivity-checked.

§

MutRef(MutRefTypeId)

Mutable reference (ADR-0062): MutRef(T) — scope-bound, exclusive.

§

Slice(SliceTypeId)

Immutable slice (ADR-0064): Slice(T) — scope-bound fat pointer {ptr, len}.

§

MutSlice(MutSliceTypeId)

Mutable slice (ADR-0064): MutSlice(T) — scope-bound exclusive fat pointer.

§

Vec(VecTypeId)

Owned, growable vector (ADR-0066): Vec(T) — heap-allocated {ptr, len, cap}.

§

Module(ModuleId)

A module type (from @import)

§

Error

An error type (used during type checking to continue after errors)

§

Never

The never type - represents computations that don’t return

§

ComptimeType

The comptime type - the type of types themselves

§

ComptimeStr

The comptime string type - compile-time only string values

§

ComptimeInt

The comptime integer type - compile-time only integer values

Trait Implementations§

Source§

impl Clone for TypeKind

Source§

fn clone(&self) -> TypeKind

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

impl Debug for TypeKind

Source§

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

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

impl<'de> Deserialize<'de> for TypeKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TypeKind

Source§

fn eq(&self, other: &TypeKind) -> 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.
Source§

impl Serialize for TypeKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for TypeKind

Source§

impl Eq for TypeKind

Source§

impl StructuralPartialEq for TypeKind

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
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
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<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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,