#[repr(C)]pub struct List<T> { /* private fields */ }Expand description
Mutable, reference-counted sequence of T, sharing its underlying
ListObj with C++. Cloning is cheap (it bumps the refcount) and yields a
handle to the same list.
Implementations§
Source§impl<T: ContainerElement> List<T>
impl<T: ContainerElement> List<T>
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the buffer holds before it is reallocated.
Sourcepub fn insert(&self, index: usize, value: T) -> Result<()>
pub fn insert(&self, index: usize, value: T) -> Result<()>
Inserts value at index, shifting the elements after it.
Sourcepub fn remove(&self, index: usize) -> Result<T>
pub fn remove(&self, index: usize) -> Result<T>
Removes and returns the element at index, shifting the elements after
it. If that element is not a T, the list is left untouched.
Sourcepub fn first(&self) -> Result<T>
pub fn first(&self) -> Result<T>
Returns the first element, or an INDEX_ERROR if the list is empty.
Sourcepub fn last(&self) -> Result<T>
pub fn last(&self) -> Result<T>
Returns the last element, or an INDEX_ERROR if the list is empty.
Sourcepub fn pop(&self) -> Result<T>
pub fn pop(&self) -> Result<T>
Removes and returns the last element, or an INDEX_ERROR if the list
is empty.
Sourcepub fn truncate(&self, len: usize)
pub fn truncate(&self, len: usize)
Shortens the list to len elements, dropping the rest; a no-op when it
is already that short. C++ resize when shrinking.
Sourcepub fn remove_range(&self, start: usize, end: usize) -> Result<()>
pub fn remove_range(&self, start: usize, end: usize) -> Result<()>
Removes the elements in start..end, shifting the ones after them.
Sourcepub fn insert_many<I: IntoIterator<Item = T>>(
&self,
index: usize,
iter: I,
) -> Result<()>
pub fn insert_many<I: IntoIterator<Item = T>>( &self, index: usize, iter: I, ) -> Result<()>
Inserts every item of iter, in order, at index, shifting the
elements after it. C++ insert(position, first, last).
Sourcepub fn reserve(&self, additional: usize) -> Result<()>
pub fn reserve(&self, additional: usize) -> Result<()>
Makes room for at least additional more elements without
reallocating again, like Vec::reserve. C++ reserve(n) takes the
absolute capacity instead.
Sourcepub fn extend<I: IntoIterator<Item = T>>(&self, iter: I) -> Result<()>
pub fn extend<I: IntoIterator<Item = T>>(&self, iter: I) -> Result<()>
Appends every item of iter, in order.
Sourcepub fn resize(&self, new_len: usize, value: T) -> Result<()>where
T: Clone,
pub fn resize(&self, new_len: usize, value: T) -> Result<()>where
T: Clone,
Resizes the list to new_len elements, dropping the tail or appending
clones of value. C++ resize.
Sourcepub fn iter(&self) -> ListIterator<'_, T> ⓘ
pub fn iter(&self) -> ListIterator<'_, T> ⓘ
Returns a double-ended iterator over the elements, yielding
Result<T>; see ListIterator.
Trait Implementations§
Source§impl<T: ContainerElement> AnyCompatible for List<T>
impl<T: ContainerElement> AnyCompatible for List<T>
Source§unsafe fn is_undefined(field: *const Self) -> bool
unsafe fn is_undefined(field: *const Self) -> bool
field, which holds a value of this type or all-zero bytes,
holds all-zero bytes that are no value of this type, as a null object
reference, a string of type index None or a zero device type: a field
that a creator left undefined for reflection to set, as C++ UnsafeInit
leaves a reference undefined (null). Unlike a C++ undefined reference,
it is no value; a nullable reference is Option<T>, whose None is a
defined value. Read moreSource§fn type_schema() -> String
fn type_schema() -> String
TypeTraits<T>::TypeSchema writes, which the type schemas of functions
and fields embed. Read moreunsafe fn check_any_strict(data: &TVMFFIAny) -> bool
Source§unsafe fn copy_to_any_view(src: &Self, data: &mut TVMFFIAny)
unsafe fn copy_to_any_view(src: &Self, data: &mut TVMFFIAny)
Source§unsafe fn move_to_any(src: Self, data: &mut TVMFFIAny)
unsafe fn move_to_any(src: Self, data: &mut TVMFFIAny)
Source§unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> Self
unsafe fn copy_from_any_view_after_check(data: &TVMFFIAny) -> Self
Source§unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> Self
unsafe fn move_from_any_after_check(data: &mut TVMFFIAny) -> Self
Source§unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<Self, ()>
unsafe fn try_cast_from_any_view(data: &TVMFFIAny) -> Result<Self, ()>
Source§fn get_mismatch_type_info(data: &TVMFFIAny) -> String
fn get_mismatch_type_info(data: &TVMFFIAny) -> String
Source§impl<T: ContainerElement> ArgIntoRef for &List<T>
impl<T: ContainerElement> ArgIntoRef for &List<T>
Source§impl<T: ContainerElement> ArgIntoRef for List<T>
impl<T: ContainerElement> ArgIntoRef for List<T>
Source§impl<T: ContainerElement> FromIterator<T> for List<T>
impl<T: ContainerElement> FromIterator<T> for List<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<'a, T: ContainerElement> IntoArgHolder for &'a List<T>
impl<'a, T: ContainerElement> IntoArgHolder for &'a List<T>
Source§impl<T: ContainerElement> IntoArgHolder for List<T>
impl<T: ContainerElement> IntoArgHolder for List<T>
Source§impl<'a, T: ContainerElement> IntoIterator for &'a List<T>
impl<'a, T: ContainerElement> IntoIterator for &'a List<T>
Source§impl<T> ObjectRefCore for List<T>
impl<T> ObjectRefCore for List<T>
type ContainerType = ListObj
fn data(this: &Self) -> &ObjectArc<ListObj>
fn into_data(this: Self) -> ObjectArc<ListObj>
Source§unsafe fn from_data(data: ObjectArc<ListObj>) -> Self
unsafe fn from_data(data: ObjectArc<ListObj>) -> Self
Source§fn same_as<Other: ObjectRefCore>(&self, other: &Other) -> bool
fn same_as<Other: ObjectRefCore>(&self, other: &Other) -> bool
Source§fn downcast_ref<T: ObjectCore>(&self) -> Option<&T>
fn downcast_ref<T: ObjectCore>(&self) -> Option<&T>
Auto Trait Implementations§
impl<T> Freeze for List<T>
impl<T> RefUnwindSafe for List<T>where
T: RefUnwindSafe,
impl<T> !Send for List<T>
impl<T> !Sync for List<T>
impl<T> Unpin for List<T>where
T: Unpin,
impl<T> UnwindSafe for List<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ObjectRefCast for Twhere
T: ObjectRefCore + AnyCompatible,
impl<T> ObjectRefCast for Twhere
T: ObjectRefCore + AnyCompatible,
Source§fn try_cast<B>(self) -> Result<B>where
B: ObjectRefCore + AnyCompatible,
fn try_cast<B>(self) -> Result<B>where
B: ObjectRefCore + AnyCompatible,
self and rewrap the underlying object as B without copying.