pub enum AttrsRef<'a> {
Empty,
Slice(Box<[(NodeStr<'a>, ValueRef<'a>)]>),
}Expand description
Covariant attribute container for decoded nodes.
Uses Box<[T]> (16 bytes: ptr + len) instead of Vec<T> (24 bytes: ptr + len + cap)
or inline storage (which inflated NodeRef size). Zero-attr nodes skip allocation
entirely. The boxed slice is allocated once with exact size from the decoder.
Covariant in 'a (both Box and slices are covariant), compatible with yoke::Yokeable.
Variants§
Implementations§
Source§impl<'a> AttrsRef<'a>
impl<'a> AttrsRef<'a>
Sourcepub fn from_vec(v: Vec<(NodeStr<'a>, ValueRef<'a>)>) -> Self
pub fn from_vec(v: Vec<(NodeStr<'a>, ValueRef<'a>)>) -> Self
Build from a pre-filled Vec. Preferred path from the decoder which knows the exact attr count upfront.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_slice(&self) -> &[(NodeStr<'a>, ValueRef<'a>)]
pub fn iter(&self) -> impl Iterator<Item = &(NodeStr<'a>, ValueRef<'a>)>
Trait Implementations§
Source§impl<'a> Yokeable<'a> for AttrsRef<'static>
impl<'a> Yokeable<'a> for AttrsRef<'static>
Source§type Output = AttrsRef<'a>
type Output = AttrsRef<'a>
This type MUST be
Self with the 'static replaced with 'a, i.e. Self<'a>Source§fn transform_owned(self) -> Self::Output
fn transform_owned(self) -> Self::Output
Auto Trait Implementations§
impl<'a> Freeze for AttrsRef<'a>
impl<'a> RefUnwindSafe for AttrsRef<'a>
impl<'a> Send for AttrsRef<'a>
impl<'a> Sync for AttrsRef<'a>
impl<'a> Unpin for AttrsRef<'a>
impl<'a> UnsafeUnpin for AttrsRef<'a>
impl<'a> UnwindSafe for AttrsRef<'a>
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