pub struct ModulePath {
pub head: PathHead,
pub segments: Vec<Name>,
/* private fields */
}Expand description
A path as spelled in source: its head and its segments, with the syntax that spells it. Serialises as the text, so the wire is what the user wrote.
Fields§
§head: PathHead§segments: Vec<Name>Implementations§
Source§impl ModulePath
impl ModulePath
pub fn new( syntax: PathSyntax, head: PathHead, segments: impl IntoIterator<Item = impl Into<Name>>, ) -> Self
pub fn syntax(&self) -> PathSyntax
pub fn first(&self) -> Option<&Name>
pub fn last(&self) -> Option<&Name>
pub fn is_empty(&self) -> bool
Sourcepub fn strip_prefix(&self, prefix: &ModulePath) -> Option<&[Name]>
pub fn strip_prefix(&self, prefix: &ModulePath) -> Option<&[Name]>
The segments after prefix, when this path continues it: same head,
its segments first.
Sourcepub fn continues(&self, prefix: &ModulePath) -> bool
pub fn continues(&self, prefix: &ModulePath) -> bool
Whether this path continues prefix by at least one segment.
Sourcepub fn with_segments(
&self,
segments: impl IntoIterator<Item = impl Into<Name>>,
) -> Self
pub fn with_segments( &self, segments: impl IntoIterator<Item = impl Into<Name>>, ) -> Self
The same path with segments in place of its own.
Sourcepub fn prefix(&self, index: usize) -> Self
pub fn prefix(&self, index: usize) -> Self
The path up to and including segment index: what a token in the
middle of a path names.
Sourcepub fn segment_at(&self, offset: usize) -> Option<usize>
pub fn segment_at(&self, offset: usize) -> Option<usize>
Which segment is spelled at byte offset from the path’s start, as
its syntax writes it; None on a separator or the head.
Sourcepub fn spell_segments(&self, segments: &[Name]) -> String
pub fn spell_segments(&self, segments: &[Name]) -> String
segments alone, spelled in this path’s syntax: the tail after a
group’s prefix.
Trait Implementations§
Source§impl Clone for ModulePath
impl Clone for ModulePath
Source§impl Debug for ModulePath
impl Debug for ModulePath
Source§impl<'de> Deserialize<'de> for ModulePath
A path read back from text carries no syntax; :: anywhere means
scoped, anything else Posix.
impl<'de> Deserialize<'de> for ModulePath
A path read back from text carries no syntax; :: anywhere means
scoped, anything else Posix.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ModulePath
impl Display for ModulePath
impl Eq for ModulePath
Source§impl Hash for ModulePath
impl Hash for ModulePath
Source§impl Ord for ModulePath
impl Ord for ModulePath
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for ModulePath
impl PartialEq for ModulePath
Source§impl PartialOrd for ModulePath
impl PartialOrd for ModulePath
Source§impl Serialize for ModulePath
impl Serialize for ModulePath
impl StructuralPartialEq for ModulePath
Auto Trait Implementations§
impl Freeze for ModulePath
impl RefUnwindSafe for ModulePath
impl Send for ModulePath
impl Sync for ModulePath
impl Unpin for ModulePath
impl UnsafeUnpin for ModulePath
impl UnwindSafe for ModulePath
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