Skip to content

Commit 4c40b60

Browse files
committed
src/vec: address pull-request feedback
1 parent f3b24a7 commit 4c40b60

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/vec/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ impl<T, S: VecStorage<T> + ?Sized> Drop for VecInner<T, S> {
12211221
#[cfg(feature = "alloc")]
12221222
/// Converts the given `alloc::vec::Vec<T>` into a `Vec<T, N>`.
12231223
impl<T, const N: usize> TryFrom<alloc::vec::Vec<T>> for Vec<T, N> {
1224-
type Error = ();
1224+
type Error = crate::CapacityError;
12251225

12261226
/// Converts the given `alloc::vec::Vec<T>` into a `Vec<T, N>`.
12271227
///
@@ -1233,7 +1233,7 @@ impl<T, const N: usize> TryFrom<alloc::vec::Vec<T>> for Vec<T, N> {
12331233

12341234
for e in alloc_vec {
12351235
// Push each element individually to allow handling capacity errors.
1236-
vec.push(e).map_err(|_| ())?;
1236+
vec.push(e)?;
12371237
}
12381238

12391239
Ok(vec)
@@ -1243,7 +1243,7 @@ impl<T, const N: usize> TryFrom<alloc::vec::Vec<T>> for Vec<T, N> {
12431243
#[cfg(feature = "alloc")]
12441244
/// Converts the given `Vec<T, N>` into an `alloc::vec::Vec<T>`.
12451245
impl<T, const N: usize> TryFrom<Vec<T, N>> for alloc::vec::Vec<T> {
1246-
type Error = ();
1246+
type Error = alloc::collections::TryReserveError;
12471247

12481248
/// Converts the given `Vec<T, N>` into an `alloc::vec::Vec<T>`.
12491249
///
@@ -1255,7 +1255,7 @@ impl<T, const N: usize> TryFrom<Vec<T, N>> for alloc::vec::Vec<T> {
12551255

12561256
// Allocate enough space for the elements, return an error if the
12571257
// allocation fails.
1258-
alloc_vec.try_reserve(vec.len()).map_err(|_| ())?;
1258+
alloc_vec.try_reserve_exact(vec.len())?;
12591259

12601260
// Transfer the elements, since we reserved enough space above, this
12611261
// should not fail due to OOM.

0 commit comments

Comments
 (0)