pub struct Path {
pub span: Span,
pub id: NodeID,
/* private fields */
}Expand description
A Path in a program.
Fields§
§span: SpanA span locating where the path occurred in the source.
id: NodeIDThe ID of the node.
Implementations§
Source§impl Path
impl Path
Sourcepub fn new(
user_program: Option<Identifier>,
qualifier: Vec<Identifier>,
identifier: Identifier,
span: Span,
id: NodeID,
) -> Self
pub fn new( user_program: Option<Identifier>, qualifier: Vec<Identifier>, identifier: Identifier, span: Span, id: NodeID, ) -> Self
Creates a new unresolved Path from the given components.
user_program: An optional program name (e.g.creditsincredits.aleo/Bar)qualifier: The namespace segments (e.g.,foo::barinfoo::bar::baz).identifier: The final item in the path (e.g.,baz).span: The source code span for this path.id: The node ID.
Sourcepub fn identifier(&self) -> &Identifier
pub fn identifier(&self) -> &Identifier
Returns the final identifier of the path (e.g., baz in foo::bar::baz).
Sourcepub fn qualifier(&self) -> &[Identifier]
pub fn qualifier(&self) -> &[Identifier]
Returns a slice of the qualifier segments (e.g., [foo, bar] in foo::bar::baz).
Sourcepub fn segments_iter(&self) -> impl Iterator<Item = Symbol> + '_
pub fn segments_iter(&self) -> impl Iterator<Item = Symbol> + '_
Returns an iterator over all segments as Symbols (qualifiers + identifier).
Sourcepub fn user_program(&self) -> Option<&Identifier>
pub fn user_program(&self) -> Option<&Identifier>
Returns the optional program identifier.
Sourcepub fn with_user_program(self, user_program: Identifier) -> Self
pub fn with_user_program(self, user_program: Identifier) -> Self
Returns self after setting it user_program field to user_program.
pub fn span(&self) -> Span
pub fn id(&self) -> NodeID
pub fn is_resolved(&self) -> bool
pub fn is_local(&self) -> bool
pub fn is_global(&self) -> bool
Sourcepub fn program(&self) -> Option<Symbol>
pub fn program(&self) -> Option<Symbol>
Returns the program symbol this path refers to, if known.
Priority:
- User-written program qualifier (e.g.
foo.aleo/bar::baz) - Resolved global target program
- None (unresolved or local)
Sourcepub fn try_local_symbol(&self) -> Option<Symbol>
pub fn try_local_symbol(&self) -> Option<Symbol>
Returns the Symbol if local, None if not.
Sourcepub fn try_global_location(&self) -> Option<&Location>
pub fn try_global_location(&self) -> Option<&Location>
Returns the Location if global, None if not.
Sourcepub fn expect_local_symbol(&self) -> Symbol
pub fn expect_local_symbol(&self) -> Symbol
Returns the Symbol if local, panics if not.
Sourcepub fn expect_global_location(&self) -> &Location
pub fn expect_global_location(&self) -> &Location
Returns the Location if global, panics if not.
Sourcepub fn with_updated_last_symbol(self, new_symbol: Symbol) -> Self
pub fn with_updated_last_symbol(self, new_symbol: Symbol) -> Self
Returns a new Path with the final identifier replaced by new_symbol.
This updates:
identifier.nametarget:Local(_)→Local(new_symbol)Global(Location)→ same location, but with the final path segment replacedUnresolved→ unchanged
Sourcepub fn resolve_as_global_in_module<I>(
self,
program: Symbol,
current_module: I,
) -> Selfwhere
I: IntoIterator<Item = Symbol>,
pub fn resolve_as_global_in_module<I>(
self,
program: Symbol,
current_module: I,
) -> Selfwhere
I: IntoIterator<Item = Symbol>,
Resolves this path as a global path using the current module context.
This method constructs an absolute global Location by combining:
- the current module path,
- any user-written qualifier segments, and
- the final identifier.
The resolution only affects the target field and preserves
the original user-written syntax of the path.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Path
impl<'de> Deserialize<'de> for Path
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 From<Identifier> for Path
impl From<Identifier> for Path
Source§fn from(value: Identifier) -> Self
fn from(value: Identifier) -> Self
Source§impl From<Path> for Expression
impl From<Path> for Expression
impl Eq for Path
impl StructuralPartialEq for Path
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
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<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
fn take_from_value<D>(
value: &mut Value,
field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.