pub trait PathExtension {
// Required method
fn get_self(&self) -> &Path;
// Provided methods
fn idents(&self) -> Vec<String> { ... }
fn to_string(&self) -> String { ... }
fn prefix(&self) -> String { ... }
fn last(&self) -> &PathSegment { ... }
fn last_str(&self) -> String { ... }
fn is(&self, path: &str) -> bool { ... }
fn is_strict(&self, path: &str) -> bool { ... }
fn generic_arguments(&self) -> Vec<&GenericArgument> { ... }
fn generic_types(&self) -> Vec<&Type> { ... }
fn first_generic_type(&self) -> CodamaResult<&Type> { ... }
fn single_generic_type(&self) -> CodamaResult<&Type> { ... }
}Required Methods§
Provided Methods§
Sourcefn to_string(&self) -> String
fn to_string(&self) -> String
Returns all segment idents joined by “::”.
E.g. for a::b<B>::c::Option<T> it returns a::b::c::Option.
Sourcefn prefix(&self) -> String
fn prefix(&self) -> String
Returns all segment idents joined by “::” except the last one.
E.g. for a::b<B>::c::Option<T> it returns a::b::c.
Sourcefn last(&self) -> &PathSegment
fn last(&self) -> &PathSegment
Returns the last segment.
Sourcefn is(&self, path: &str) -> bool
fn is(&self, path: &str) -> bool
Returns true if the path is equal to the given path including or excluding the prefix.
Sourcefn is_strict(&self, path: &str) -> bool
fn is_strict(&self, path: &str) -> bool
Returns true if the path is equal to the given path including the prefix.
Sourcefn generic_arguments(&self) -> Vec<&GenericArgument>
fn generic_arguments(&self) -> Vec<&GenericArgument>
Returns the generic arguments of the last segment.
E.g. for a::b::c::Option<'a, T, U> it returns GenericArguments(Some(['a, T, U])).
E.g. for a::b::c::u32 it returns GenericArguments(None).
Sourcefn generic_types(&self) -> Vec<&Type>
fn generic_types(&self) -> Vec<&Type>
Filters out all generic arguments that are not types.
E.g. for Option<'a, T, U> it returns [T, U].
Sourcefn first_generic_type(&self) -> CodamaResult<&Type>
fn first_generic_type(&self) -> CodamaResult<&Type>
Returns the first generic type argument if there is one.
E.g. for Vec<'a, T, U> it returns Ok(T).
Sourcefn single_generic_type(&self) -> CodamaResult<&Type>
fn single_generic_type(&self) -> CodamaResult<&Type>
Returns the first generic type argument if there is exactly one.
E.g. for Vec<'a, T> it returns Ok(T).