Struct rustre_core::id::IdRef
source · 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 Id
s, 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<'p, 'm> From<&'m Id> for IdRef<'p, 'm>
impl<'p, 'm> From<&'m Id> for IdRef<'p, 'm>
Converts the Id
to an IdRef
using IdRef::new_implicit
source§impl<'p, 'm> FromStr for IdRef<'p, 'm>
impl<'p, 'm> FromStr for IdRef<'p, 'm>
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.