pub struct ContextEntry { /* private fields */ }Expand description
Records contextual information for traversal decisions.
Implementations§
Source§impl ContextEntry
impl ContextEntry
Sourcepub fn new(
name: impl Into<String>,
kind: ContextKind,
attributes: Vec<Attribute>,
) -> Self
pub fn new( name: impl Into<String>, kind: ContextKind, attributes: Vec<Attribute>, ) -> Self
Builds a new context entry with the provided attributes.
§Examples
use whitaker_common::attributes::{Attribute, AttributeKind, AttributePath};
use whitaker_common::context::{ContextEntry, ContextKind};
let entry = ContextEntry::new(
"demo",
ContextKind::Function,
vec![Attribute::new(AttributePath::from("test"), AttributeKind::Outer)],
);
assert_eq!(entry.name(), "demo");Sourcepub fn function(name: impl Into<String>, attributes: Vec<Attribute>) -> Self
pub fn function(name: impl Into<String>, attributes: Vec<Attribute>) -> Self
Convenience constructor for function contexts.
§Examples
use whitaker_common::attributes::{Attribute, AttributeKind, AttributePath};
use whitaker_common::context::ContextEntry;
let entry = ContextEntry::function(
"demo",
vec![Attribute::new(AttributePath::from("test"), AttributeKind::Outer)],
);
assert!(entry.kind().matches_function());Sourcepub const fn kind(&self) -> &ContextKind
pub const fn kind(&self) -> &ContextKind
Returns the entry kind.
Sourcepub fn attributes(&self) -> &[Attribute]
pub fn attributes(&self) -> &[Attribute]
Returns a snapshot of the entry attributes.
Sourcepub fn attributes_mut(&mut self) -> &mut Vec<Attribute>
pub fn attributes_mut(&mut self) -> &mut Vec<Attribute>
Returns a mutable reference to the attributes for in-place updates.
Sourcepub fn push_attribute(&mut self, attribute: Attribute)
pub fn push_attribute(&mut self, attribute: Attribute)
Adds an attribute to the entry.
Trait Implementations§
Source§impl Clone for ContextEntry
impl Clone for ContextEntry
Source§fn clone(&self) -> ContextEntry
fn clone(&self) -> ContextEntry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextEntry
impl Debug for ContextEntry
impl Eq for ContextEntry
Source§impl PartialEq for ContextEntry
impl PartialEq for ContextEntry
impl StructuralPartialEq for ContextEntry
Auto Trait Implementations§
impl Freeze for ContextEntry
impl RefUnwindSafe for ContextEntry
impl Send for ContextEntry
impl Sync for ContextEntry
impl Unpin for ContextEntry
impl UnsafeUnpin for ContextEntry
impl UnwindSafe for ContextEntry
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