rust: alloc: add `RawVec::try_with_capacity_in()` constructor
authorMiguel Ojeda <ojeda@kernel.org>
Thu, 10 Nov 2022 16:41:24 +0000 (17:41 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 4 Dec 2022 00:59:15 +0000 (01:59 +0100)
commit51d3a25ab3a4f1dd701b17f7340e36de8600e41e
treeb6634dc784239392b89db497403a7ac63ad1b956
parent25d176a4fad5841de1f85d2a4d69ce87416abc26
rust: alloc: add `RawVec::try_with_capacity_in()` constructor

Add the `RawVec::try_with_capacity_in()` constructor as the fallible
version of `RawVec::with_capacity_in()`.

The implementation follows the original.

The infallible constructor is implemented in terms of the private
`RawVec::allocate_in()` constructor, thus also add the private
`RawVec::try_allocate_in()` constructor following the other.

It will be used to implement `Vec::try_with_capacity{,_in}()` in
the next patch.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/alloc/raw_vec.rs