pub trait VectorMutOps:
Sealed
+ Into<VectorMut>
+ Sized {
type Immutable: VectorOps<Mutable = Self>;
// Required methods
fn len(&self) -> usize;
fn validity(&self) -> &MaskMut;
fn capacity(&self) -> usize;
fn reserve(&mut self, additional: usize);
fn clear(&mut self);
fn truncate(&mut self, len: usize);
fn extend_from_vector(&mut self, other: &Self::Immutable);
fn append_nulls(&mut self, n: usize);
fn freeze(self) -> Self::Immutable;
fn split_off(&mut self, at: usize) -> Self;
fn unsplit(&mut self, other: Self);
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Common operations for mutable vectors (all the variants of VectorMut).
Required Associated Types§
Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the number of elements in the vector, also referred to as its “length”.
Sourcefn validity(&self) -> &MaskMut
fn validity(&self) -> &MaskMut
Returns the validity mask of the vector, where true represents a valid element and
false represents a null element.
Note that while this returns a MaskMut (which is typically an owned type), the caller is
only allowed to inspect it via the shared reference.
Sourcefn capacity(&self) -> usize
fn capacity(&self) -> usize
Returns the total number of elements the vector can hold without reallocating.
Sourcefn reserve(&mut self, additional: usize)
fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more elements to be inserted in the given
vector.
The collection may reserve more space to speculatively avoid frequent reallocations. After
calling reserve, the capacity will be greater than or equal to self.len() + additional.
Does nothing if capacity is already sufficient.
Please let us know if you need reserve_exact functionality!
Sourcefn truncate(&mut self, len: usize)
fn truncate(&mut self, len: usize)
Shortens the buffer, keeping the first len bytes and dropping the rest.
If len is greater than the buffer’s current length, this has no effect.
Existing underlying capacity is preserved.
Sourcefn extend_from_vector(&mut self, other: &Self::Immutable)
fn extend_from_vector(&mut self, other: &Self::Immutable)
Extends the vector by appending elements from another vector.
§Panics
Panics if the other vector has the wrong type (for example, a
StructVector might have incorrect fields).
Sourcefn append_nulls(&mut self, n: usize)
fn append_nulls(&mut self, n: usize)
Appends n null elements to the vector.
Implementors should ensure that they correctly append “null” or garbage values to their elements in addition to adding nulls to their validity mask.
Sourcefn split_off(&mut self, at: usize) -> Self
fn split_off(&mut self, at: usize) -> Self
Splits the vector into two at the given index.
Afterward, self contains elements [0, at), and the returned vector contains elements
[at, capacity). It’s guaranteed that the memory does not move, that is, the address of
self does not change, and the address of the returned slice is at bytes after that.
This is an O(1) operation that just increases the reference count and sets a few indices.
§Panics
Panics if we try to split off more than the current capacity of the vector (if
at > capacity).
Sourcefn unsplit(&mut self, other: Self)
fn unsplit(&mut self, other: Self)
Absorbs a mutable vector that was previously split off.
If the two vectors were previously contiguous and not mutated in a way that causes
re-allocation i.e., if other was created by calling split_off() on this vector, then
this is an O(1) operation (simply decreases a reference count and sets a few indices).
Otherwise, this method falls back to self.extend_from_vector(other).
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.