enum TypeStructure {
Simple(String),
Generic {
base: String,
args: Vec<TypeStructure>,
},
Union(Vec<TypeStructure>),
}Expand description
Parsed structure of a type expression
Variants§
Simple(String)
Simple type: “int”, “ClassA”
Generic
Generic type: “Optional[A]”, “Dict[str, int]”
Union(Vec<TypeStructure>)
Union type: “A | B | C”
Implementations§
Source§impl TypeStructure
impl TypeStructure
Sourcefn parse_tokens(tokens: &[Token]) -> Self
fn parse_tokens(tokens: &[Token]) -> Self
Parse a slice of tokens into a TypeStructure
Sourcefn try_parse_union(tokens: &[Token]) -> Option<Vec<Vec<Token>>>
fn try_parse_union(tokens: &[Token]) -> Option<Vec<Vec<Token>>>
Try to parse tokens as a union (A | B | C) Returns Some(vec![tokens_for_A, tokens_for_B, tokens_for_C]) if successful
Sourcefn try_parse_generic(tokens: &[Token]) -> Option<(Vec<Token>, Vec<Vec<Token>>)>
fn try_parse_generic(tokens: &[Token]) -> Option<(Vec<Token>, Vec<Vec<Token>>)>
Try to parse tokens as a generic type Returns Some((base_tokens, vec![arg1_tokens, arg2_tokens, …])) if successful
Sourcefn split_by_comma_at_depth_zero(tokens: &[Token]) -> Vec<Vec<Token>>
fn split_by_comma_at_depth_zero(tokens: &[Token]) -> Vec<Vec<Token>>
Split tokens by commas at depth 0
Sourcefn tokens_to_string(tokens: &[Token]) -> String
fn tokens_to_string(tokens: &[Token]) -> String
Convert tokens to a string representation
Trait Implementations§
Source§impl Clone for TypeStructure
impl Clone for TypeStructure
Source§fn clone(&self) -> TypeStructure
fn clone(&self) -> TypeStructure
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TypeStructure
impl Debug for TypeStructure
Source§impl PartialEq for TypeStructure
impl PartialEq for TypeStructure
impl StructuralPartialEq for TypeStructure
Auto Trait Implementations§
impl Freeze for TypeStructure
impl RefUnwindSafe for TypeStructure
impl Send for TypeStructure
impl Sync for TypeStructure
impl Unpin for TypeStructure
impl UnwindSafe for TypeStructure
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more