pub struct Body { /* private fields */ }Expand description
Implementations§
source§impl Body
impl Body
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructs a new, empty Body with at least the specified capacity.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of structures in the body, also referred to as its ‘length’.
sourcepub fn get(&self, index: usize) -> Option<&Structure>
pub fn get(&self, index: usize) -> Option<&Structure>
Returns a reference to the structure at the given index, or None if the index is out of
bounds.
sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Structure>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Structure>
Returns a mutable reference to the structure at the given index, or None if the index is
out of bounds.
sourcepub fn insert(&mut self, index: usize, structure: impl Into<Structure>)
pub fn insert(&mut self, index: usize, structure: impl Into<Structure>)
Inserts a structure at position index within the body, shifting all structures after it
to the right.
Panics
Panics if index > len.
sourcepub fn push(&mut self, structure: impl Into<Structure>)
pub fn push(&mut self, structure: impl Into<Structure>)
Appends a structure to the back of the body.
Panics
Panics if the new capacity exceeds isize::MAX bytes.
sourcepub fn pop(&mut self) -> Option<Structure>
pub fn pop(&mut self) -> Option<Structure>
Removes the last structure from the body and returns it, or None if it is empty.
sourcepub fn remove(&mut self, index: usize) -> Structure
pub fn remove(&mut self, index: usize) -> Structure
Removes and returns the structure at position index within the body, shifting all
elements after it to the left.
Like Vec::remove, the structure is removed by shifting all of the structures that follow
it, preserving their relative order. This perturbs the index of all of those elements!
Panics
Panics if index is out of bounds.
Trait Implementations§
source§impl<T> Extend<T> for Bodywhere
T: Into<Structure>,
impl<T> Extend<T> for Bodywhere T: Into<Structure>,
source§fn extend<I>(&mut self, iterable: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iterable: I)where I: IntoIterator<Item = T>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)