pub struct CallPath<T = Ident> {
pub prefixes: Vec<Ident>,
pub suffix: T,
pub callpath_type: CallPathType,
}
Expand description
In the expression a::b::c()
, a
and b
are the prefixes and c
is the suffix.
c
can be any type T
, but in practice c
is either an Ident
or a TypeInfo
.
Fields§
§prefixes: Vec<Ident>
§suffix: T
§callpath_type: CallPathType
Implementations§
Source§impl CallPath
impl CallPath
pub fn fullpath(path: &[&str]) -> Self
Sourcepub fn rshift(&self) -> CallPath
pub fn rshift(&self) -> CallPath
Shifts the last prefix into the suffix, and removes the old suffix. Does nothing if prefixes are empty, or if the path is a full path and there is only a single prefix (which must be the package name, which is obligatory for full paths)
pub fn as_vec_string(&self) -> Vec<String>
Sourcepub fn ident_to_fullpath(suffix: Ident, namespace: &Namespace) -> CallPath
pub fn ident_to_fullpath(suffix: Ident, namespace: &Namespace) -> CallPath
Sourcepub fn to_import_path(
&self,
engines: &Engines,
namespace: &Namespace,
) -> CallPath
pub fn to_import_path( &self, engines: &Engines, namespace: &Namespace, ) -> CallPath
Convert a given CallPath into a call path suitable for a use
statement.
For example, given a path pkga::SOME_CONST
where pkga
is an internal library of a package named
my_project
, the corresponding call path is pkga::SOME_CONST
.
Paths to external libraries such std::lib1::lib2::my_obj
are left unchanged.
Source§impl<T: Clone> CallPath<T>
impl<T: Clone> CallPath<T>
Sourcepub fn to_fullpath(
&self,
engines: &Engines,
namespace: &Namespace,
) -> CallPath<T>
pub fn to_fullpath( &self, engines: &Engines, namespace: &Namespace, ) -> CallPath<T>
Convert a given CallPath to a symbol to a full CallPath to a program point in which the symbol can be resolved (assuming the given CallPath is a legal Sway path).
The resulting CallPath is not guaranteed to be located in the package where the symbol is declared. To obtain the path to the declaration, use [to_canonical_path].
The CallPath is converted within the current module of the supplied namespace.
For example, given a path pkga::SOME_CONST
where pkga
is an internal module of a
package named my_project
, the corresponding call path is
my_project::pkga::SOME_CONST
. This does not imply that SOME_CONST
is declared in the
my_project::pkga
, but only that the name SOME_CONST
is bound in my_project::pkga
.
Paths to external libraries such std::lib1::lib2::my_obj
are considered full already
and are left unchanged since std
is a root of the package std
.
Sourcepub fn to_fullpath_from_mod_path(
&self,
engines: &Engines,
namespace: &Namespace,
mod_path: &Vec<Ident>,
) -> CallPath<T>
pub fn to_fullpath_from_mod_path( &self, engines: &Engines, namespace: &Namespace, mod_path: &Vec<Ident>, ) -> CallPath<T>
Convert a given CallPath to a symbol to a full CallPath to a program point in which the symbol can be resolved (assuming the given CallPath is a legal Sway path).
The resulting CallPath is not guaranteed to be located in the package where the symbol is declared. To obtain the path to the declaration, use [to_canonical_path].
The CallPath is converted within the module given by mod_path
, which must be a legal
path to a module.
For example, given a path pkga::SOME_CONST
where pkga
is an internal module of a
package named my_project
, the corresponding call path is
my_project::pkga::SOME_CONST
. This does not imply that SOME_CONST
is declared in the
my_project::pkga
, but only that the name SOME_CONST
is bound in my_project::pkga
.
Paths to external libraries such std::lib1::lib2::my_obj
are considered full already
and are left unchanged since std
is a root of the package std
.
Source§impl CallPath
impl CallPath
Sourcepub fn to_canonical_path(
&self,
engines: &Engines,
namespace: &Namespace,
) -> CallPath
pub fn to_canonical_path( &self, engines: &Engines, namespace: &Namespace, ) -> CallPath
Convert a given CallPath to a symbol to a full CallPath to where the symbol is declared (assuming the given CallPath is a legal Sway path).
The CallPath is converted within the current module of the supplied namespace.
For example, given a path pkga::SOME_CONST
where pkga
is an internal module of a
package named my_project
, and SOME_CONST
is bound in the module my_project::pkga
, then
the corresponding call path is the full callpath to the declaration that SOME_CONST
is
bound to. This does not imply that SOME_CONST
is declared in the my_project::pkga
, since
the binding may be the result of an import.
Paths to external libraries such std::lib1::lib2::my_obj
are considered full already
and are left unchanged since std
is a root of the package std
.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for CallPath<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for CallPath<T>where
T: Deserialize<'de>,
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<CallPath> for QualifiedCallPath
impl From<CallPath> for QualifiedCallPath
Source§impl<T: Ord> Ord for CallPath<T>
impl<T: Ord> Ord for CallPath<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: OrdWithEngines> OrdWithEngines for CallPath<T>
impl<T: OrdWithEngines> OrdWithEngines for CallPath<T>
fn cmp(&self, other: &Self, ctx: &OrdWithEnginesContext<'_>) -> Ordering
Source§impl PartialEqWithEngines for CallPath
impl PartialEqWithEngines for CallPath
fn eq(&self, other: &Self, _ctx: &PartialEqWithEnginesContext<'_>) -> bool
Source§impl<T: PartialEqWithEngines> PartialEqWithEngines for CallPath<T>
impl<T: PartialEqWithEngines> PartialEqWithEngines for CallPath<T>
fn eq(&self, other: &Self, ctx: &PartialEqWithEnginesContext<'_>) -> bool
Source§impl<T: PartialOrd> PartialOrd for CallPath<T>
impl<T: PartialOrd> PartialOrd for CallPath<T>
Source§impl ResolveSymbols for CallPath
impl ResolveSymbols for CallPath
fn resolve_symbols( &mut self, _handler: &Handler, _ctx: SymbolResolveContext<'_>, )
impl<T: Eq> Eq for CallPath<T>
impl EqWithEngines for CallPath
impl<T: EqWithEngines> EqWithEngines for CallPath<T>
impl<T> StructuralPartialEq for CallPath<T>
Auto Trait Implementations§
impl<T> Freeze for CallPath<T>where
T: Freeze,
impl<T> RefUnwindSafe for CallPath<T>where
T: RefUnwindSafe,
impl<T> Send for CallPath<T>where
T: Send,
impl<T> Sync for CallPath<T>where
T: Sync,
impl<T> Unpin for CallPath<T>where
T: Unpin,
impl<T> UnwindSafe for CallPath<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AnyDebug for T
impl<T> AnyDebug for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Any
.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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
Source§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.