Struct CxxVector

struct CxxVector<T> { ... }

Binding to C++ std::vector<T, std::allocator<T>>.

Invariants

As an invariant of this API and the static analysis of the cxx::bridge macro, in Rust code we can never obtain a CxxVector by value. Instead in Rust code we will only ever look at a vector behind a reference or smart pointer, as in &CxxVector<T> or UniquePtr<CxxVector<T>>.

Implementations

impl<T> CxxVector<T>

fn new() -> UniquePtr<Self>

Constructs a new heap allocated vector, wrapped by UniquePtr.

The C++ vector is default constructed.

fn len(self: &Self) -> usize

Returns the number of elements in the vector.

Matches the behavior of C++ std::vector<T>::size.

fn is_empty(self: &Self) -> bool

Returns true if the vector contains no elements.

Matches the behavior of C++ std::vector<T>::empty.

fn get(self: &Self, pos: usize) -> Option<&T>

Returns a reference to an element at the given position, or None if out of bounds.

fn index_mut(self: Pin<&mut Self>, pos: usize) -> Option<Pin<&mut T>>

Returns a pinned mutable reference to an element at the given position, or None if out of bounds.

unsafe fn get_unchecked(self: &Self, pos: usize) -> &T

Returns a reference to an element without doing bounds checking.

This is generally not recommended, use with caution! Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Matches the behavior of C++ std::vector<T>::operator[] const.

unsafe fn index_unchecked_mut(self: Pin<&mut Self>, pos: usize) -> Pin<&mut T>

Returns a pinned mutable reference to an element without doing bounds checking.

This is generally not recommended, use with caution! Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Matches the behavior of C++ std::vector<T>::operator[].

fn as_slice(self: &Self) -> &[T]
where
    T: ExternType<Kind = Trivial>

Returns a slice to the underlying contiguous array of elements.

fn as_mut_slice(self: Pin<&mut Self>) -> &mut [T]
where
    T: ExternType<Kind = Trivial>

Returns a slice to the underlying contiguous array of elements by mutable reference.

fn iter(self: &Self) -> Iter<'_, T>

Returns an iterator over elements of type &T.

fn iter_mut(self: Pin<&mut Self>) -> IterMut<'_, T>

Returns an iterator over elements of type Pin<&mut T>.

fn push(self: Pin<&mut Self>, value: T)
where
    T: ExternType<Kind = Trivial>

Appends an element to the back of the vector.

Matches the behavior of C++ std::vector<T>::push_back.

fn pop(self: Pin<&mut Self>) -> Option<T>
where
    T: ExternType<Kind = Trivial>

Removes the last element from a vector and returns it, or None if the vector is empty.

impl<T> Any for CxxVector<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for CxxVector<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for CxxVector<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> Debug for CxxVector<T>

fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result

impl<T> Freeze for CxxVector<T>

impl<T> From for CxxVector<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for CxxVector<T>

impl<T> Send for CxxVector<T>

impl<T> Sync for CxxVector<T>

impl<T> UniquePtrTarget for CxxVector<T>

impl<T> Unpin for CxxVector<T>

impl<T> UnsafeUnpin for CxxVector<T>

impl<T> UnwindSafe for CxxVector<T>

impl<T, U> Into for CxxVector<T>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for CxxVector<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for CxxVector<T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>