pub struct TypeParam {
pub name: String,
pub constraint: Option<Box<TypeDef>>,
pub default: Option<Box<TypeDef>>,
}Expand description
A type parameter for generic type definitions.
Represents a type parameter like T, T extends string, or T = never.
§Examples
ⓘ
// Simple type parameter: T
TypeParam::new("T")
// Constrained type parameter: T extends { type: string }
TypeParam::new("T").with_constraint(TypeDef::Object(...))
// Type parameter with default: T = never
TypeParam::new("T").with_default(TypeDef::Primitive(Primitive::Never))Fields§
§name: StringThe type parameter name, e.g., “T”, “K”, “V”
constraint: Option<Box<TypeDef>>Optional constraint: T extends Constraint
default: Option<Box<TypeDef>>Optional default value: T = Default
Implementations§
Source§impl TypeParam
impl TypeParam
Sourcepub fn with_constraint(self, constraint: TypeDef) -> Self
pub fn with_constraint(self, constraint: TypeDef) -> Self
Adds a constraint to this type parameter: T extends Constraint
Sourcepub fn with_default(self, default: TypeDef) -> Self
pub fn with_default(self, default: TypeDef) -> Self
Adds a default type to this type parameter: T = Default
Trait Implementations§
impl StructuralPartialEq for TypeParam
Auto Trait Implementations§
impl Freeze for TypeParam
impl RefUnwindSafe for TypeParam
impl Send for TypeParam
impl Sync for TypeParam
impl Unpin for TypeParam
impl UnwindSafe for TypeParam
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
Mutably borrows from an owned value. Read more