rustdoc-mcp 0.6.4

mcp server for rustdocs
---
source: rustdoc-mcp/src/tests.rs
expression: result_std_vec_vec
---
Item: Vec
Kind: Struct
Visibility: Public
Defined at: alloc::vec::Vec

A contiguous growable array type, written as `Vec<T>`, short for 'vector'.

# Examples
[+255 lines elided]


```rust
struct Vec<T, A: Allocator = crate::alloc::Global> {
}
```


Associated Types:

• pub const fn new() -> Self
    Constructs a new, empty `Vec<T>`. [+9 more lines]

• pub const fn with_capacity(capacity: usize) -> Self
    Constructs a new, empty `Vec<T>` with at least the specified capacity. [+49 more lines]

• pub fn try_with_capacity(capacity: usize) -> Result<Self, TryReserveError>
    Constructs a new, empty `Vec<T>` with at least the specified capacity. [+9 more lines]

• pub const unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Self
    Creates a `Vec<T>` directly from a pointer, a length, and a capacity. [+97 more lines]

• pub const unsafe fn from_parts(ptr: NonNull<T>, length: usize, capacity: usize) -> Self
    Creates a `Vec<T>` directly from a `NonNull` pointer, a length, and a capacity. [+94 more lines]

• pub fn from_fn<F>(length: usize, f: F) -> Self
where
    F: FnMut(usize) -> T
    Creates a `Vec<T>` where each element is produced by calling `f` with [+42 more lines]

• pub const fn into_raw_parts(self) -> (*mut T, usize, usize)
    Decomposes a `Vec<T>` into its raw components: `(pointer, length, capacity)`. [+34 more lines]

• pub const fn into_parts(self) -> (NonNull<T>, usize, usize)
    Decomposes a `Vec<T>` into its raw components: `(NonNull pointer, length, capacity)`. [+32 more lines]

• pub const fn const_make_global(self) -> &'static [T]
where
    T: Freeze
    Interns the `Vec<T>`, making the underlying memory read-only. This method should be [+4 more lines]

• pub const fn with_capacity_in(capacity: usize, alloc: A) -> Self
    Constructs a new, empty `Vec<T, A>` with at least the specified capacity [+54 more lines]

• pub const fn push(&mut self, value: T)
    Appends an element to the back of a collection. [+19 more lines]

• pub const fn push_mut(&mut self, value: T) -> &mut T
    Appends an element to the back of a collection, returning a reference to it. [+24 more lines]

• pub const fn new_in(alloc: A) -> Self
    Constructs a new, empty `Vec<T, A>`. [+12 more lines]

• pub fn try_with_capacity_in(capacity: usize, alloc: A) -> Result<Self, TryReserveError>
    Constructs a new, empty `Vec<T, A>` with at least the specified capacity [+10 more lines]

• pub const unsafe fn from_raw_parts_in(ptr: *mut T, length: usize, capacity: usize, alloc: A) -> Self
    Creates a `Vec<T, A>` directly from a pointer, a length, a capacity, [+98 more lines]

• pub const unsafe fn from_parts_in(ptr: NonNull<T>, length: usize, capacity: usize, alloc: A) -> Self
    Creates a `Vec<T, A>` directly from a `NonNull` pointer, a length, a capacity, [+96 more lines]

• pub const fn into_raw_parts_with_alloc(self) -> (*mut T, usize, usize, A)
    Decomposes a `Vec<T>` into its raw components: `(pointer, length, capacity, allocator)`. [+36 more lines]

• pub const fn into_parts_with_alloc(self) -> (NonNull<T>, usize, usize, A)
    Decomposes a `Vec<T>` into its raw components: `(NonNull pointer, length, capacity, allocator)`. [+36 more lines]

• pub const fn capacity(&self) -> usize
    Returns the total number of elements the vector can hold without [+22 more lines]

• pub fn reserve(&mut self, additional: usize)
    Reserves capacity for at least `additional` more elements to be inserted [+16 more lines]

• pub fn reserve_exact(&mut self, additional: usize)
    Reserves the minimum capacity for at least `additional` more elements to [+23 more lines]

• pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
    Tries to reserve capacity for at least `additional` more elements to be inserted [+31 more lines]

• pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError>
    Tries to reserve the minimum capacity for at least `additional` [+37 more lines]

• pub fn shrink_to_fit(&mut self)
    Shrinks the capacity of the vector as much as possible. [+16 more lines]

• pub fn shrink_to(&mut self, min_capacity: usize)
    Shrinks the capacity of the vector with a lower bound. [+17 more lines]

• pub fn try_shrink_to_fit(&mut self) -> Result<(), TryReserveError>
    Tries to shrink the capacity of the vector as much as possible [+24 more lines]

• pub fn try_shrink_to(&mut self, min_capacity: usize) -> Result<(), TryReserveError>
    Shrinks the capacity of the vector with a lower bound. [+25 more lines]

• pub fn into_boxed_slice(self) -> Box<[T], A>
    Converts the vector into [`Box<[T]>`][owned slice]. [+24 more lines]

• pub fn truncate(&mut self, len: usize)
    Shortens the vector, keeping the first `len` elements and dropping [+41 more lines]

• pub const fn as_slice(&self) -> &[T]
    Extracts a slice containing the entire vector. [+10 more lines]

• pub const fn as_mut_slice(&mut self) -> &mut [T]
    Extracts a mutable slice of the entire vector. [+10 more lines]

• pub const fn as_ptr(&self) -> *const T
    Returns a raw pointer to the vector's buffer, or a dangling raw pointer [+52 more lines]

• pub const fn as_mut_ptr(&mut self) -> *mut T
    Returns a raw mutable pointer to the vector's buffer, or a dangling [+72 more lines]

• pub const fn as_non_null(&mut self) -> NonNull<T>
    Returns a `NonNull` pointer to the vector's buffer, or a dangling [+55 more lines]

• pub const fn allocator(&self) -> &A
    Returns a reference to the underlying allocator.

• pub unsafe fn set_len(&mut self, new_len: usize)
    Forces the length of the vector to `new_len`. [+85 more lines]

• pub fn swap_remove(&mut self, index: usize) -> T
    Removes an element from the vector and returns it. [+23 more lines]

• pub fn insert(&mut self, index: usize, element: T)
    Inserts an element at position `index` within the vector, shifting all [+21 more lines]

• pub fn insert_mut(&mut self, index: usize, element: T) -> &mut T
    Inserts an element at position `index` within the vector, shifting all [+21 more lines]

• pub fn remove(&mut self, index: usize) -> T
    Removes and returns the element at position `index` within the vector, [+22 more lines]

• pub fn try_remove(&mut self, index: usize) -> Option<T>
    Remove and return the element at position `index` within the vector, [+18 more lines]

• pub fn retain<F>(&mut self, f: F)
where
    F: FnMut(&T) -> bool
    Retains only the elements specified by the predicate. [+23 more lines]

• pub fn retain_mut<F>(&mut self, f: F)
where
    F: FnMut(&mut T) -> bool
    Retains only the elements specified by the predicate, passing a mutable reference to it. [+17 more lines]

• pub fn dedup_by_key<F, K>(&mut self, key: F)
where
    F: FnMut(&mut T) -> K,
    K: PartialEq
    Removes all but the first of consecutive elements in the vector that resolve to the same [+13 more lines]

• pub fn dedup_by<F>(&mut self, same_bucket: F)
where
    F: FnMut(&mut T, &mut T) -> bool
    Removes all but the first of consecutive elements in the vector satisfying a given equality [+17 more lines]

• pub fn push_within_capacity(&mut self, value: T) -> Result<&mut T, T>
    Appends an element and returns a reference to it if there is sufficient spare capacity, [+34 more lines]

• pub fn pop(&mut self) -> Option<T>
    Removes the last element from a vector and returns it, or [`None`] if it [+18 more lines]

• pub fn pop_if<impl FnOnce(&mut T) -> bool: FnOnce(&mut T) -> bool>(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T>
    Removes and returns the last element from a vector if the predicate [+13 more lines]

• pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T, A>>
    Returns a mutable reference to the last item in the vector, or [+20 more lines]

• pub fn append(&mut self, other: &mut Self)
    Moves all the elements of `other` into `self`, leaving `other` empty. [+14 more lines]

• pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, A>
where
    R: RangeBounds<usize>
    Removes the subslice indicated by the given range from the vector, [+31 more lines]

• pub fn clear(&mut self)
    Clears the vector, removing all values. [+13 more lines]

• pub const fn len(&self) -> usize
    Returns the number of elements in the vector, also referred to [+8 more lines]

• pub const fn is_empty(&self) -> bool
    Returns `true` if the vector contains no elements. [+10 more lines]

• pub fn split_off(&mut self, at: usize) -> Self
where
    A: Clone
    Splits the collection into two at the given index. [+23 more lines]

• pub fn resize_with<F>(&mut self, new_len: usize, f: F)
where
    F: FnMut() -> T
    Resizes the `Vec` in-place so that `len` is equal to `new_len`. [+29 more lines]

• pub fn leak<'a>(self) -> &'a mut [T]
where
    A: 'a
    Consumes and leaks the `Vec`, returning a mutable reference to the contents, [+27 more lines]

• pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]
    Returns the remaining spare capacity of the vector as a slice of [+27 more lines]

• pub fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit<T>])
    Returns vector content as a slice of `T`, along with the remaining spare [+50 more lines]

• pub fn into_chunks<const N: usize>(self) -> Vec<[T; N], A>
    Groups every `N` elements in the `Vec<T>` into chunks to produce a `Vec<[T; N]>`, dropping [+23 more lines]

• pub fn recycle<U>(self) -> Vec<U, A>
where
    U: Recyclable<T>
    This clears out this `Vec` and recycles the allocation into a new `Vec`. [+48 more lines]

• pub fn resize(&mut self, new_len: usize, value: T)
    Resizes the `Vec` in-place so that `len` is equal to `new_len`. [+26 more lines]

• pub fn extend_from_slice(&mut self, other: &[T])
    Clones and appends all elements in a slice to the `Vec`. [+21 more lines]

• pub fn extend_from_within<R>(&mut self, src: R)
where
    R: RangeBounds<usize>
    Given a range `src`, clones a slice of elements in that range and appends it to the end. [+24 more lines]

• pub fn into_flattened(self) -> Vec<T, A>
    Takes a `Vec<[T; N]>` and flattens it into a `Vec<T>`. [+18 more lines]

• pub fn dedup(&mut self)
    Removes consecutive repeated elements in the vector according to the [+13 more lines]

• pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Splice<'_, <I as >::IntoIter, A>
where
    R: RangeBounds<usize>,
    I: IntoIterator<Item = T>
    Creates a splicing iterator that replaces the specified range in the vector [+42 more lines]

• pub fn extract_if<F, R>(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A>
where
    F: FnMut(&mut T) -> bool,
    R: RangeBounds<usize>
    Creates an iterator which uses a closure to determine if an element in the range should be removed. [+73 more lines]


std traits: Any, AsMut<Vec<T, A>>, AsMut<[T]>, AsRef<Vec<T, A>>, AsRef<[T]>, Borrow<T>, Borrow<[T]>, BorrowMut<T>, BorrowMut<[T]>, Clone [+51 more]