Struct impl_tools_lib::SimplePath
source · pub struct SimplePath(_);
Expand description
Simple, allocation-free path representation
Implementations§
source§impl SimplePath
impl SimplePath
sourcepub fn new(path: &'static [&'static str]) -> Self
pub fn new(path: &'static [&'static str]) -> Self
Construct, verifying validity
If the first component is an empty string, this is treated as a leading
colon (e.g. ["", "abc", "Def"] ==
::abc::Def`). No other component may
be empty. At least one non-empty component is required.
Panics if requirements are not met.
sourcepub fn matches(&self, path: &Path) -> bool
pub fn matches(&self, path: &Path) -> bool
True if this matches a syn::Path
This must match the path exactly, with two exceptions:
- if
path
has no leading colon butself
does (empty first component), the paths may still match - if the first component of
self
iscore
oralloc
but the first component ofpath
isstd
, the paths may still match
sourcepub fn matches_ident(&self, ident: &Ident) -> bool
pub fn matches_ident(&self, ident: &Ident) -> bool
True if the last component matches a syn::Ident
sourcepub fn matches_ident_or_path(&self, path: &Path) -> bool
pub fn matches_ident_or_path(&self, path: &Path) -> bool
If input path
has a single component with no leading colon, then
match via Self::matches_ident
; otherwise match via
Self::matches
.