Skip to main content

InstanceOccurrence

Struct InstanceOccurrence 

Source
pub struct InstanceOccurrence { /* private fields */ }
Expand description

Retains one occurrence’s identity, immediate parent, and local mapping ranges.

Parent/site pairs distinguish repeated uses of shared children. Root occurrences have neither a parent nor an inclusion site. No record owns another record.

use adam_rs::{Sheet, TemplateBuilder};
let template = TemplateBuilder::new().finish()?;
let instance = template.instantiate(&mut Sheet::new(), &[])?;
let root = &instance.occurrences()[0];
assert_eq!(root.template(), &template.id());
assert!(root.parent().is_none());
assert!(root.inclusion_site().is_none());
assert_eq!(instance.occurrence(root.id()).unwrap().id(), root.id());

Implementations§

Source§

impl InstanceOccurrence

Source

pub fn conditionals(&self) -> &[ConditionalId]

Borrows live conditional identities in this definition’s authored order.

These identities remain usable after the template is dropped.

§Examples
let template = adam_rs::TemplateBuilder::new().finish()?;
let instance = template.instantiate(&mut adam_rs::Sheet::new(), &[])?;
assert!(instance.occurrences()[0].conditionals().is_empty());
Source

pub fn id(&self) -> &OccurrenceId

Borrows this occurrence’s expansion-scoped identity.

§Examples

See the occurrence example.

Source

pub fn template(&self) -> &TemplateId

Borrows the identity of the expanded recipe.

§Examples

See the occurrence example.

Source

pub fn parent(&self) -> Option<&OccurrenceId>

Borrows the immediate parent identity, or returns None for the root.

§Examples

See the occurrence example.

Source

pub fn inclusion_site(&self) -> Option<&RelationshipSlot>

Borrows the inclusion group in the parent’s namespace, or returns None for the root.

§Examples

See the occurrence example.

Trait Implementations§

Source§

impl Debug for InstanceOccurrence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.