pub struct TemplateUse { /* private fields */ }Expand description
A use of a registered template as a node’s archetype, made by
MappingBuilder::template_node.
The template’s holes are bound, in declaration order, to picks stored in the mapping.
§Examples
use lower_lang::{templates, Arch, MappingBuilder, Pick};
let mut b = MappingBuilder::<u8>::new();
let while_loop = b.template(templates::while_loop())?;
b.template_node(4, while_loop, &[Pick::NthNode(0), Pick::NthNode(1), Pick::Absent]);
let mapping = b.build()?;
assert!(matches!(mapping.rule_for(&4), Some(Arch::Template(_))));Implementations§
Source§impl TemplateUse
impl TemplateUse
Sourcepub const fn template(&self) -> TemplateId
pub const fn template(&self) -> TemplateId
The template this node instantiates.
§Examples
use lower_lang::{templates, Arch, MappingBuilder, Pick};
let mut b = MappingBuilder::<u8>::new();
let t = b.template(templates::logical_and())?;
b.template_node(1, t, &[Pick::Nth(0), Pick::Nth(2)]);
let m = b.build()?;
let Some(Arch::Template(used)) = m.rule_for(&1) else { unreachable!() };
assert_eq!(used.template(), t);Trait Implementations§
Source§impl Clone for TemplateUse
impl Clone for TemplateUse
impl Copy for TemplateUse
Source§impl Debug for TemplateUse
impl Debug for TemplateUse
impl Eq for TemplateUse
Source§impl Hash for TemplateUse
impl Hash for TemplateUse
Source§impl PartialEq for TemplateUse
impl PartialEq for TemplateUse
impl StructuralPartialEq for TemplateUse
Auto Trait Implementations§
impl Freeze for TemplateUse
impl RefUnwindSafe for TemplateUse
impl Send for TemplateUse
impl Sync for TemplateUse
impl Unpin for TemplateUse
impl UnsafeUnpin for TemplateUse
impl UnwindSafe for TemplateUse
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
Mutably borrows from an owned value. Read more