pub enum TypeExpr {
Named(Ident),
Unit(Span),
Never(Span),
Array {
element: Box<TypeExpr>,
length: u64,
span: Span,
},
AnonymousStruct {
directives: Directives,
posture: Posture,
fields: Vec<AnonStructField>,
methods: Vec<Method>,
span: Span,
},
AnonymousEnum {
directives: Directives,
posture: Posture,
variants: Vec<EnumVariant>,
methods: Vec<Method>,
span: Span,
},
AnonymousInterface {
methods: Vec<MethodSig>,
span: Span,
},
TypeCall {
callee: Ident,
args: Vec<TypeExpr>,
span: Span,
},
Tuple {
elems: Vec<TypeExpr>,
span: Span,
},
}Expand description
A type expression in the AST.
Variants§
Named(Ident)
A simple named type (e.g., i32, bool, MyStruct)
Unit(Span)
Unit type: ()
Never(Span)
Never type: !
Array
Array type: [T; N] where T is the element type and N is the length
AnonymousStruct
Anonymous struct type: struct { field: Type, fn method(…) { … }, … }
Used in comptime type construction (e.g., fn Pair(comptime T: type) -> type { struct { first: T, second: T } })
Methods can be included inside the struct definition (Zig-style).
Fields
directives: DirectivesDirectives applied to the struct expression (e.g., @derive(...),
ADR-0058). Parsed before the struct keyword.
posture: PostureDeclared ownership posture (ADR-0080). Affine when neither
@mark(copy) nor @mark(linear) appears in the directive list.
fields: Vec<AnonStructField>Field declarations (name and type)
span: SpanAnonymousEnum
Anonymous enum type: enum { Variant, Variant(T), Variant { field: T }, fn method(…) { … }, … }
Used in comptime type construction (e.g., fn Option(comptime T: type) -> type { enum { Some(T), None } })
Methods can be included inside the enum definition (Zig-style).
Fields
directives: DirectivesDirectives applied to the enum expression (ADR-0058).
posture: PostureDeclared ownership posture (ADR-0080). Affine when neither
@mark(copy) nor @mark(linear) appears in the directive list.
variants: Vec<EnumVariant>Enum variants
span: SpanAnonymousInterface
Anonymous interface type: interface { fn name(self) [-> T]; … }
(ADR-0057) — comptime-constructed interface type, parallel to
AnonymousStruct and AnonymousEnum. Used inside fn ... -> type
bodies to build parameterized interfaces.
Fields
span: SpanTypeCall
Parameterized type call (ADR-0057): Name(arg1, arg2, ...) used in
type position to invoke a comptime function returning type.
Resolves at sema time by evaluating the call at comptime.
Fields
args: Vec<TypeExpr>Type-or-expression arguments. Currently restricted to type expressions; expressions like integer literals can be added when comptime value parameters become common at type positions.
span: SpanTuple
Tuple type: (T,), (T, U), (T, U, V), … (ADR-0048)
() remains the unit type. A 1-tuple requires a trailing comma ((T,))
to distinguish it from a parenthesised type.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TypeExpr
impl<'de> Deserialize<'de> for TypeExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TypeExpr
impl StructuralPartialEq for TypeExpr
Auto Trait Implementations§
impl Freeze for TypeExpr
impl RefUnwindSafe for TypeExpr
impl Send for TypeExpr
impl Sync for TypeExpr
impl Unpin for TypeExpr
impl UnsafeUnpin for TypeExpr
impl UnwindSafe for TypeExpr
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> 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<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].