pub enum ModulePath {
Std,
ExplicitRue {
path: String,
},
Simple {
path: String,
},
}Expand description
Represents a parsed import path with its resolution strategy.
This enum categorizes import paths to determine how they should be resolved. Each variant corresponds to a different resolution strategy.
Variants§
Std
Standard library import: @import("std")
This is a special case that is currently not supported during const eval.
ExplicitRue
Import with explicit .gruel extension: @import("foo.gruel")
The path is taken as-is and matched against loaded file paths.
Simple
Simple module import: @import("foo") or @import("utils/strings")
Resolution tries:
{path}.gruel- standard file_{basename}.gruel- facade file for directory modules
For nested paths like utils/strings, we look for utils/strings.gruel.
Implementations§
Source§impl ModulePath
impl ModulePath
Sourcepub fn parse(import_path: &str) -> Self
pub fn parse(import_path: &str) -> Self
Parse an import path string into a structured ModulePath.
This determines the kind of import based on the path format.
§Examples
ModulePath::parse("std") => ModulePath::Std
ModulePath::parse("foo.gruel") => ModulePath::ExplicitRue { path: "foo.gruel" }
ModulePath::parse("foo") => ModulePath::Simple { path: "foo" }
ModulePath::parse("utils/strings") => ModulePath::Simple { path: "utils/strings" }Sourcepub fn resolve<'a, I>(&self, loaded_paths: I) -> Option<String>
pub fn resolve<'a, I>(&self, loaded_paths: I) -> Option<String>
Resolve this import path against a collection of loaded file paths.
Returns Some(resolved_path) if a match is found, or None if the
module cannot be found.
The resolution order is:
- Exact match (for ExplicitRue)
- Standard file match (
{path}.gruel) - Path suffix match (for nested paths)
- Facade file match (
_{basename}.gruel)
Trait Implementations§
Source§impl Clone for ModulePath
impl Clone for ModulePath
Source§fn clone(&self) -> ModulePath
fn clone(&self) -> ModulePath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModulePath
impl Debug for ModulePath
Source§impl PartialEq for ModulePath
impl PartialEq for ModulePath
impl Eq 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,
§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
§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
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>
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].