Struct Path
struct Path { ... }
A path at which a named item is exported (e.g. std::collections::HashMap).
Fields
leading_colon: Option<PathSep>segments: Punctuated<PathSegment, PathSep>
Implementations
impl Path
fn parse_mod_style(input: ParseStream<'_>) -> Result<Self>Parse a
Pathcontaining no path arguments on any of its segments.Example
use ; use ; // A simplified single `use` statement like: // // use std::collections::HashMap; // // Note that generic parameters are not allowed in a `use` statement // so the following must not be accepted. // // use a::<b>::c;
impl Path
fn is_ident<I>(self: &Self, ident: &I) -> bool where I: ?Sized, Ident: PartialEq<I>Determines whether this is a path of length 1 equal to the given ident.
For them to compare equal, it must be the case that:
- the path has no leading colon,
- the number of path segments is 1,
- the first path segment has no angle bracketed or parenthesized path arguments, and
- the ident of the first path segment is equal to the given one.
Example
use TokenStream; use ;fn get_ident(self: &Self) -> Option<&Ident>If this path consists of a single ident, returns the ident.
A path is considered an ident if:
- the path has no leading colon,
- the number of path segments is 1, and
- the first path segment has no angle bracketed or parenthesized path arguments.
fn require_ident(self: &Self) -> Result<&Ident>An error if this path is not a single ident, as defined in
get_ident.
impl Clone for Path
fn clone(self: &Self) -> Self
impl Debug for Path
fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result
impl Eq for Path
impl Freeze for Path
impl Hash for Path
fn hash<H>(self: &Self, state: &mut H) where H: Hasher
impl Parse for Path
fn parse(input: ParseStream<'_>) -> Result<Self>
impl PartialEq for Path
fn eq(self: &Self, other: &Self) -> bool
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl ToTokens for Path
fn to_tokens(self: &Self, tokens: &mut TokenStream)
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
impl<T> Any for Path
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Path
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Path
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Path
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Path
fn from(segment: T) -> Self
impl<T> From for Path
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Spanned for Path
fn span(self: &Self) -> Span
impl<T> ToOwned for Path
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Path
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Path
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Path
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>