pub struct ModPath {
pub kind: PathKind,
/* private fields */
}
Fields§
§kind: PathKind
Implementations§
source§impl ModPath
impl ModPath
pub fn from_src( db: &dyn ExpandDatabase, path: Path, span_for_range: &mut dyn FnMut(TextRange) -> SyntaxContextId, ) -> Option<ModPath>
pub fn from_tt( db: &dyn ExpandDatabase, tt: &[TokenTree<SpanData<SyntaxContextId>>], ) -> Option<ModPath>
pub fn from_segments( kind: PathKind, segments: impl IntoIterator<Item = Name>, ) -> ModPath
sourcepub const fn from_kind(kind: PathKind) -> ModPath
pub const fn from_kind(kind: PathKind) -> ModPath
Creates a ModPath
from a PathKind
, with no extra path segments.
pub fn segments(&self) -> &[Name]
pub fn push_segment(&mut self, segment: Name)
pub fn pop_segment(&mut self) -> Option<Name>
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of segments in the path (counting special segments like $crate
and
super
).
pub fn textual_len(&self) -> usize
pub fn is_ident(&self) -> bool
pub fn is_self(&self) -> bool
pub fn is_Self(&self) -> bool
sourcepub fn as_ident(&self) -> Option<&Name>
pub fn as_ident(&self) -> Option<&Name>
If this path is a single identifier, like foo
, return its name.
pub fn unescaped(&self) -> UnescapedModPath<'_>
pub fn display<'a>( &'a self, db: &'a dyn ExpandDatabase, edition: Edition, ) -> impl Display + 'a
Trait Implementations§
source§impl Extend<Name> for ModPath
impl Extend<Name> for ModPath
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Name>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Name>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl Ord for ModPath
impl Ord for ModPath
source§impl PartialOrd for ModPath
impl PartialOrd for ModPath
impl Eq for ModPath
impl StructuralPartialEq for ModPath
Auto Trait Implementations§
impl Freeze for ModPath
impl RefUnwindSafe for ModPath
impl Send for ModPath
impl Sync for ModPath
impl Unpin for ModPath
impl UnwindSafe for ModPath
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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