pub struct Array<'de> { /* private fields */ }Expand description
A growable array of TOML Items.
Arrays support indexing with usize via the [] operator, which returns
a MaybeItem — out-of-bounds access returns a None variant instead of
panicking. Use get / get_mut for
Option-based access, or iterate with a for loop.
Mutation methods (push, with_capacity)
require an Arena because array storage is arena-allocated.
Implementations§
Source§impl<'de> Array<'de>
impl<'de> Array<'de>
Sourcepub fn with_capacity(cap: u32, arena: &Arena) -> Self
pub fn with_capacity(cap: u32, arena: &Arena) -> Self
Creates an array with pre-allocated capacity.
Sourcepub fn with_single(value: Item<'de>, arena: &Arena) -> Self
pub fn with_single(value: Item<'de>, arena: &Arena) -> Self
Creates an array containing a single value.
Sourcepub fn push(&mut self, value: Item<'de>, arena: &Arena)
pub fn push(&mut self, value: Item<'de>, arena: &Arena)
Appends a value to the end of the array.
Sourcepub fn get(&self, index: usize) -> Option<&Item<'de>>
pub fn get(&self, index: usize) -> Option<&Item<'de>>
Returns a reference to the element at the given index.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Item<'de>>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Item<'de>>
Returns a mutable reference to the element at the given index.
Sourcepub fn pop(&mut self) -> Option<Item<'de>>
pub fn pop(&mut self) -> Option<Item<'de>>
Removes and returns the last element, or None if empty.
Sourcepub fn last_mut(&mut self) -> Option<&mut Item<'de>>
pub fn last_mut(&mut self) -> Option<&mut Item<'de>>
Returns a mutable reference to the last element.
Sourcepub fn as_mut_slice(&mut self) -> &mut [Item<'de>]
pub fn as_mut_slice(&mut self) -> &mut [Item<'de>]
Returns the contents as a mutable slice.
Trait Implementations§
Source§impl<'a, 'de> IntoIterator for &'a Array<'de>
impl<'a, 'de> IntoIterator for &'a Array<'de>
Source§impl<'a, 'de> IntoIterator for &'a mut Array<'de>
impl<'a, 'de> IntoIterator for &'a mut Array<'de>
Auto Trait Implementations§
impl<'de> Freeze for Array<'de>
impl<'de> RefUnwindSafe for Array<'de>
impl<'de> !Send for Array<'de>
impl<'de> !Sync for Array<'de>
impl<'de> Unpin for Array<'de>
impl<'de> UnsafeUnpin for Array<'de>
impl<'de> UnwindSafe for Array<'de>
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