diff options
| author | bors <bors@rust-lang.org> | 2021-08-07 01:26:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-08-07 01:26:15 +0000 |
| commit | 996ff2e0a0f911f52bb1de6bdd0cfd5704de1fc9 (patch) | |
| tree | f10bdc2b1742f123ce140d43cb11d8f07dabfe92 /library/alloc/src/collections/vec_deque | |
| parent | db3cb435c1197ef3e3919c03b7f81ca8bffbd007 (diff) | |
| parent | a294aa8d3d7b73b7de60c629ae202194cffeb2f4 (diff) | |
| download | rust-996ff2e0a0f911f52bb1de6bdd0cfd5704de1fc9.tar.gz rust-996ff2e0a0f911f52bb1de6bdd0cfd5704de1fc9.zip | |
Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc
Hide allocator details from TryReserveError I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature. So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later. This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.
Diffstat (limited to 'library/alloc/src/collections/vec_deque')
| -rw-r--r-- | library/alloc/src/collections/vec_deque/mod.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 6bbddeb69b2..bea5cf11be5 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -19,6 +19,7 @@ use core::slice; use crate::alloc::{Allocator, Global}; use crate::collections::TryReserveError; +use crate::collections::TryReserveErrorKind; use crate::raw_vec::RawVec; use crate::vec::Vec; @@ -773,7 +774,7 @@ impl<T, A: Allocator> VecDeque<T, A> { let new_cap = used_cap .checked_add(additional) .and_then(|needed_cap| needed_cap.checked_next_power_of_two()) - .ok_or(TryReserveError::CapacityOverflow)?; + .ok_or(TryReserveErrorKind::CapacityOverflow)?; if new_cap > old_cap { self.buf.try_reserve_exact(used_cap, new_cap - used_cap)?; |
