pub enum Type {
Name(Path),
Subscript {
base: Path,
args: Vec<Type>,
},
Optional(Box<Type>),
Annotated {
base: Box<Type>,
markers: Vec<Expr>,
},
}Expand description
A type annotation.
Python writes an annotation as an expression, so every form here is
also an Expr as far as the grammar is concerned. They are separate
types anyway: a rule that could put an arbitrary expression where an
annotation belongs could put list[1] there, and nothing between the
rule and the file would notice.
Variants§
Name(Path)
A name or a dotted name: int, a.b.Point.
Subscript
base[arg, ...] — list[int], tuple[int, int].
Optional(Box<Type>)
typing.Optional[T].
Its own form rather than a Type::Subscript: Optional takes
exactly one argument, and the tree is where that is true.
Annotated
Implementations§
Trait Implementations§
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
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