Skip to main content

PathExtension

Trait PathExtension 

Source
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§

Source

fn get_self(&self) -> &Path

Provided Methods§

Source

fn idents(&self) -> Vec<String>

Returns all segment idents as strings

Source

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.

Source

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.

Source

fn last(&self) -> &PathSegment

Returns the last segment.

Source

fn last_str(&self) -> String

Returns the ident of the last segment as a string.

Source

fn is(&self, path: &str) -> bool

Returns true if the path is equal to the given path including or excluding the prefix.

Source

fn is_strict(&self, path: &str) -> bool

Returns true if the path is equal to the given path including the prefix.

Source

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).

Source

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].

Source

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).

Source

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).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PathExtension for Path

Source§

fn get_self(&self) -> &Path

Implementors§