#[repr(u8)]pub enum TypeRef<Id = SchemaHash> {
Concrete {
type_id: Id,
args: Vec<TypeRef<Id>>,
},
Var {
name: TypeParamName,
},
}Expand description
A reference to a type in a schema. Either a concrete type (with optional
type arguments for generics) or a type variable bound by the enclosing
generic’s type_params.
Generic over the ID type: TypeSchemaId for final schemas,
MixedId during extraction.
Variants§
Concrete
A concrete type, possibly generic.
Fields
type_id: IdVar
A reference to a type parameter of the enclosing generic type,
by name (e.g. TypeParamName("T")).
Fields
name: TypeParamNameImplementations§
Source§impl<Id> TypeRef<Id>
impl<Id> TypeRef<Id>
Sourcepub fn generic(type_id: Id, args: Vec<TypeRef<Id>>) -> Self
pub fn generic(type_id: Id, args: Vec<TypeRef<Id>>) -> Self
Shorthand for a generic concrete type reference with type arguments.
Sourcepub fn collect_ids(&self, out: &mut Vec<Id>)where
Id: Copy,
pub fn collect_ids(&self, out: &mut Vec<Id>)where
Id: Copy,
Collect all concrete IDs reachable from this TypeRef (depth-first).
Sourcepub fn expect_concrete_id(&self) -> &Id
pub fn expect_concrete_id(&self) -> &Id
Return the concrete type ID if this is a non-generic Concrete variant, panicking otherwise.
Source§impl TypeRef
impl TypeRef
Sourcepub fn resolve_kind(&self, registry: &SchemaRegistry) -> Option<SchemaKind>
pub fn resolve_kind(&self, registry: &SchemaRegistry) -> Option<SchemaKind>
Look up the schema for this TypeRef in the registry and return the schema’s kind with all type variables substituted.
For non-generic types (Concrete { args: [] }), returns the kind as-is.
For generic types, substitutes Var references with the concrete
type arguments from this TypeRef.
Returns None if the schema is not in the registry or this is a Var.
Trait Implementations§
impl<Id: Eq> Eq for TypeRef<Id>
impl<Id> StructuralPartialEq for TypeRef<Id>
Auto Trait Implementations§
impl<Id> Freeze for TypeRef<Id>where
Id: Freeze,
impl<Id> RefUnwindSafe for TypeRef<Id>where
Id: RefUnwindSafe,
impl<Id> Send for TypeRef<Id>where
Id: Send,
impl<Id> Sync for TypeRef<Id>where
Id: Sync,
impl<Id> Unpin for TypeRef<Id>where
Id: Unpin,
impl<Id> UnsafeUnpin for TypeRef<Id>where
Id: UnsafeUnpin,
impl<Id> UnwindSafe for TypeRef<Id>where
Id: UnwindSafe,
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.