pub struct IdRef<'p, 'm> { /* private fields */ }Expand description
Reference to a node, param, variable, type, package, model, etc., as it appears in the usage / call site
This may be identical to an Id, but can also be preceded by a package name
(package::member).
§Example values
- Implicit packages (equivalent to simple Ids):
sin,a,state - Explicit package:
Lustre::add,Alu::shift_right
§Usage
Like Ids, IdRefs don’t store their source span. The same tips apply.
§Name resolution semantics
Implementations§
Source§impl<'p, 'm> IdRef<'p, 'm>
impl<'p, 'm> IdRef<'p, 'm>
pub fn new( package: Option<impl Into<Cow<'p, Id>>>, member: impl Into<Cow<'m, Id>>, ) -> Self
Sourcepub fn new_implicit(member: impl Into<Cow<'m, Id>>) -> Self
pub fn new_implicit(member: impl Into<Cow<'m, Id>>) -> Self
Creates an IdRef with an implicit (absent) package name
Sourcepub fn new_lustre(member: impl Into<Cow<'m, Id>>) -> Self
pub fn new_lustre(member: impl Into<Cow<'m, Id>>) -> Self
Creates an IdRef with Lustre:: for a package name
pub fn as_package(&self) -> Option<&Id>
pub fn as_member(&self) -> &Id
Sourcepub fn as_member_implicit(&self) -> Option<&Id>
pub fn as_member_implicit(&self) -> Option<&Id>
Retrieves the member, only if this IdRef has no explicit package
Can be used to attempt local resolution of an identifier, which only makes sense when no package is specified.
pub fn member_eq(&self, other: &Id) -> bool
pub fn into_inner(self) -> (Option<Cow<'p, Id>>, Cow<'m, Id>)
Trait Implementations§
Source§impl FromStr for IdRef<'_, '_>
impl FromStr for IdRef<'_, '_>
Parses an IdRef from a &str
Most of the time, the actual Rustre parser will be used instead of this function. It exists mostly for convenience and interoperability. Please note that this implementation is infallible, and won’t check for invalid chars in identifiers.