Skip to content

Commit c2a022d

Browse files
bors[bot]japaric
andauthored
Merge #292
292: make Deque::pop_{front,back}_unchecked public r=japaric a=japaric closes #268 Co-authored-by: Jorge Aparicio <[email protected]>
2 parents 622a676 + fbc5d5b commit c2a022d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Added
1111

1212
* Added support for AVR architecture.
13-
* Add Entry Api to IndexMap
14-
* Implement IntoIterator trait for Indexmap
15-
* Implement FromIterator for String
16-
* Add first/last API to IndexMap and IndexSet
13+
* Add `entry` API to `IndexMap`
14+
* Implement `IntoIterator` trait for `Indexmap`
15+
* Implement `FromIterator` for `String`
16+
* Add `first` and `last` methods to `IndexMap` and `IndexSet`
17+
* Add `pop_{front_back}_unchecked` methods to `Deque`
1718

1819
### Changed
1920

src/deque.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,13 @@ impl<T, const N: usize> Deque<T, N> {
271271
}
272272
}
273273

274-
/// Removes an item from the front of the deque and returns it
274+
/// Removes an item from the front of the deque and returns it, without checking that the deque
275+
/// is not empty
275276
///
276277
/// # Safety
277278
///
278-
/// This assumes the deque is not empty.
279-
pub(crate) unsafe fn pop_front_unchecked(&mut self) -> T {
279+
/// It's undefined behavior to call this on an empty deque
280+
pub unsafe fn pop_front_unchecked(&mut self) -> T {
280281
debug_assert!(!self.is_empty());
281282

282283
let index = self.front;
@@ -285,12 +286,13 @@ impl<T, const N: usize> Deque<T, N> {
285286
(self.buffer.get_unchecked_mut(index).as_ptr() as *const T).read()
286287
}
287288

288-
/// Removes an item from the back of the deque and returns it
289+
/// Removes an item from the back of the deque and returns it, without checking that the deque
290+
/// is not empty
289291
///
290292
/// # Safety
291293
///
292-
/// This assumes the deque is not empty.
293-
pub(crate) unsafe fn pop_back_unchecked(&mut self) -> T {
294+
/// It's undefined behavior to call this on an empty deque
295+
pub unsafe fn pop_back_unchecked(&mut self) -> T {
294296
debug_assert!(!self.is_empty());
295297

296298
self.full = false;

0 commit comments

Comments
 (0)