Types
This section is a work-in-progress experiment about making the book executable.
Syntax
Type:
| bool =>
| str =>
| ( types=TupleTypes? ) =>
| Self =>
| & lifetime=Lifetime? m=Mutability ty=Type =>
| bool =>
Type::Bool| str =>
Type::Str| ( types=TupleTypes? ) =>
Type::Tuple(types.unwrap_or_default())| Self =>
Type::TraitSelf| & lifetime=Lifetime? m=Mutability ty=Type =>
Type::Ref(lifetime, m, Box::new(ty))
pub enum Type {
Bool,
Str,
Tuple(Vec<Type>),
TraitSelf,
Ref(Option<Lifetime>, Mutability, Box<Type>),
}
impl Type {
pub fn mk_unit() -> Type {
Type::Tuple(Vec::new())
}
}