summaryrefslogtreecommitdiffstats
path: root/rust/alloc/raw_vec.rs
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2022-11-10 17:41:25 +0100
committerMiguel Ojeda <ojeda@kernel.org>2022-12-04 01:59:15 +0100
commitfeadd062871704b1de2111d06008ee24a8f03d02 (patch)
tree105dd87b80eff06d37c904f60a9b905e26229c76 /rust/alloc/raw_vec.rs
parent51d3a25ab3a4f1dd701b17f7340e36de8600e41e (diff)
downloadlinux-feadd062871704b1de2111d06008ee24a8f03d02.tar.gz
linux-feadd062871704b1de2111d06008ee24a8f03d02.tar.bz2
linux-feadd062871704b1de2111d06008ee24a8f03d02.zip
rust: alloc: add `Vec::try_with_capacity{,_in}()` constructors
Add `Vec::try_with_capacity()` and `Vec::try_with_capacity_in()` as the fallible versions of `Vec::with_capacity()` and `Vec::with_capacity_in()`, respectively. The implementations follow the originals and use the previously added `RawVec::try_with_capacity_in()`. In turn, `Vec::try_with_capacity()` will be used to implement the `CString` type (which wraps a `Vec<u8>`) in a later patch. Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/alloc/raw_vec.rs')
-rw-r--r--rust/alloc/raw_vec.rs1
1 files changed, 0 insertions, 1 deletions
diff --git a/rust/alloc/raw_vec.rs b/rust/alloc/raw_vec.rs
index c342f3843972..eb77db5def55 100644
--- a/rust/alloc/raw_vec.rs
+++ b/rust/alloc/raw_vec.rs
@@ -135,7 +135,6 @@ impl<T, A: Allocator> RawVec<T, A> {
/// Like `try_with_capacity`, but parameterized over the choice of
/// allocator for the returned `RawVec`.
- #[allow(dead_code)]
#[inline]
pub fn try_with_capacity_in(capacity: usize, alloc: A) -> Result<Self, TryReserveError> {
Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc)