Struct cxx::CxxVector [−][src]
#[repr(C, packed)]pub struct CxxVector<T> { /* fields omitted */ }
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> where
T: VectorElement,
[src]
impl<T> CxxVector<T> where
T: VectorElement,
[src]pub fn len(&self) -> usize
[src]
Returns the number of elements in the vector.
Matches the behavior of C++ std::vector<T>::size.
pub fn is_empty(&self) -> bool
[src]
Returns true if the vector contains no elements.
Matches the behavior of C++ std::vector<T>::empty.
pub fn get(&self, pos: usize) -> Option<&T>
[src]
Returns a reference to an element at the given position, or None
if
out of bounds.
pub fn index_mut(self: Pin<&mut Self>, pos: usize) -> Option<Pin<&mut T>>
[src]
Returns a pinned mutable reference to an element at the given position,
or None
if out of bounds.
pub unsafe fn get_unchecked(&self, pos: usize) -> &T
[src]
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.
pub unsafe fn index_unchecked_mut(
self: Pin<&mut Self>,
pos: usize
) -> Pin<&mut T>
[src]
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[].
pub fn as_slice(&self) -> &[T] where
T: ExternType<Kind = Trivial>,
[src]
T: ExternType<Kind = Trivial>,
Returns a slice to the underlying contiguous array of elements.
pub fn as_mut_slice(self: Pin<&mut Self>) -> &mut [T] where
T: ExternType<Kind = Trivial>,
[src]
T: ExternType<Kind = Trivial>,
Returns a slice to the underlying contiguous array of elements by mutable reference.
pub fn iter(&self) -> Iter<'_, T>ⓘ
[src]
Returns an iterator over elements of type &T
.
pub fn iter_mut(self: Pin<&mut Self>) -> IterMut<'_, T>ⓘ
[src]
Returns an iterator over elements of type Pin<&mut T>
.
pub fn push(self: Pin<&mut Self>, value: T) where
T: ExternType<Kind = Trivial>,
[src]
T: ExternType<Kind = Trivial>,
Appends an element to the back of the vector.
Matches the behavior of C++ std::vector<T>::push_back.
pub fn pop(self: Pin<&mut Self>) -> Option<T> where
T: ExternType<Kind = Trivial>,
[src]
T: ExternType<Kind = Trivial>,
Removes the last element from a vector and returns it, or None
if the
vector is empty.
Trait Implementations
impl<T> Debug for CxxVector<T> where
T: VectorElement + Debug,
[src]
impl<T> Debug for CxxVector<T> where
T: VectorElement + Debug,
[src]impl<'a, T> IntoIterator for &'a CxxVector<T> where
T: VectorElement,
[src]
impl<'a, T> IntoIterator for &'a CxxVector<T> where
T: VectorElement,
[src]impl<T> UniquePtrTarget for CxxVector<T> where
T: VectorElement,
[src]
impl<T> UniquePtrTarget for CxxVector<T> where
T: VectorElement,
[src]Auto Trait Implementations
impl<T> RefUnwindSafe for CxxVector<T> where
T: RefUnwindSafe,
impl<T> RefUnwindSafe for CxxVector<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for CxxVector<T> where
T: UnwindSafe,
impl<T> UnwindSafe for CxxVector<T> where
T: UnwindSafe,