pub struct DynList<T, Typ = DoubleLinked>{ /* private fields */ }Expand description
A list of objects that all implement a trait.
See the crate documentation for more info.
Implementations§
Source§impl<T, Typ> DynList<T, Typ>
impl<T, Typ> DynList<T, Typ>
Sourcepub unsafe fn push_ptr(&mut self, value: *mut T)
pub unsafe fn push_ptr(&mut self, value: *mut T)
Moves a dyn trait from a pointer and pushes it to the end of the list.
This moves the data out of the passed-in pointer, rendering it no longer dereferenceable.
§Safety
The pointer must be dereferenceable.
Sourcepub fn push_boxed(&mut self, value: Box<T>)
pub fn push_boxed(&mut self, value: Box<T>)
Moves a dyn trait out of a box and pushes it to the end of the list.
In addition to adding items from boxes, it also does not require the
dyn trait object to implement FromImpl.
Sourcepub fn push<U>(&mut self, value: U)where
T: FromImpl<U>,
pub fn push<U>(&mut self, value: U)where
T: FromImpl<U>,
Pushes an element onto the list.
This requires that the trait object implements FromImpl for U.
On nightly, it is implemented for all trait implementations, but on stable requires
using the impl_from_impl macro on the trait.
See also Self::push_boxed and Self::push_ptr.
Sourcepub fn extend_from_other<Typ2>(&mut self, other: DynList<T, Typ2>)where
Typ2: ListType<T>,
pub fn extend_from_other<Typ2>(&mut self, other: DynList<T, Typ2>)where
Typ2: ListType<T>,
Moves all items from another DynList into this one, adding them to the end in order.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity to hold exactly what is stored in the list.
Sourcepub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T, Typ> ⓘ
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T, Typ> ⓘ
Iterates through items in this list mutably.
Note: if using with dyn Any, review Rust’s advice about calling its methods!
You will need to derference the item before calling a method from Any.
Sourcepub fn into_ptrs_iter(self) -> IntoPtrsIter<T, Typ> ⓘ
pub fn into_ptrs_iter(self) -> IntoPtrsIter<T, Typ> ⓘ
Move elements out of the list, yielding pointers to them.
The pointers are valid until the iterator is dropped, at which point they are all deallocated.
Yielded pointers will not have their contents dropped, so it is safe to move the data out of them. Any remaining unyielded pointers will have their contents dropped once the iterator is dropped.
Sourcepub fn into_box_iter(self) -> IntoBoxedIter<T, Typ> ⓘ
pub fn into_box_iter(self) -> IntoBoxedIter<T, Typ> ⓘ
Moves elements out of the list, moving them into boxes.
Sourcepub fn cursor<'a>(&'a mut self) -> Option<Cursor<'a, T, Typ>>
pub fn cursor<'a>(&'a mut self) -> Option<Cursor<'a, T, Typ>>
Creates a cursor located at the beginning of the list.
Unlike an iterator, the Cursor is lending, but provides the iters::Cursor::drop_after
method for dropping a section of the list.
Returns None if the list is empty.
Trait Implementations§
impl<T, Typ> Eq for DynList<T, Typ>
Source§impl<U, T, Typ> Extend<U> for DynList<T, Typ>
impl<U, T, Typ> Extend<U> for DynList<T, Typ>
Source§fn extend<I: IntoIterator<Item = U>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = U>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)