pub struct ModulePath(/* private fields */);Expand description
A module’s package-relative display path (e.g. util, internal/math). For
single-file scripts this is just the script filename. A thin newtype today;
later multi-file steps extend it with resolution helpers.
Implementations§
Source§impl ModulePath
impl ModulePath
pub fn as_str(&self) -> &str
Sourcepub fn resolve_relative(
&self,
specifier: &str,
) -> Result<ModulePath, RelativeImportError>
pub fn resolve_relative( &self, specifier: &str, ) -> Result<ModulePath, RelativeImportError>
Resolve a relative-path import specifier (./util, ../math) against
self, the importing module’s package-relative path. Resolution is
directory-relative like ES/Node: the base is the importer’s directory —
self minus its last path segment.
A segment stack seeded with that directory walks the specifier’s
/-split segments: . and empty segments are skipped, .. pops (an
empty stack means it climbed above the package root → EscapesRoot),
anything else is pushed. A trailing .ts or .subm extension is stripped. The
result has no ./, no .., no source extension, and / separators.
Callers must classify with is_relative_specifier first — a package
specifier passed here would be misread as a path.
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
impl<'de> Deserialize<'de> for ModulePath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ModulePath
impl Display for ModulePath
impl Eq for ModulePath
Source§impl From<&str> for ModulePath
impl From<&str> for ModulePath
Source§impl From<String> for ModulePath
impl From<String> 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,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.