292: make Deque::pop_{front,back}_unchecked public r=japaric a=japaric

closes #268 

Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
This commit is contained in:
bors[bot] 2022-05-12 11:07:44 +00:00 committed by GitHub
commit c2a022d9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -10,10 +10,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
* Added support for AVR architecture.
* Add Entry Api to IndexMap
* Implement IntoIterator trait for Indexmap
* Implement FromIterator for String
* Add first/last API to IndexMap and IndexSet
* Add `entry` API to `IndexMap`
* Implement `IntoIterator` trait for `Indexmap`
* Implement `FromIterator` for `String`
* Add `first` and `last` methods to `IndexMap` and `IndexSet`
* Add `pop_{front_back}_unchecked` methods to `Deque`
### Changed

View File

@ -271,12 +271,13 @@ impl<T, const N: usize> Deque<T, N> {
}
}
/// Removes an item from the front of the deque and returns it
/// Removes an item from the front of the deque and returns it, without checking that the deque
/// is not empty
///
/// # Safety
///
/// This assumes the deque is not empty.
pub(crate) unsafe fn pop_front_unchecked(&mut self) -> T {
/// It's undefined behavior to call this on an empty deque
pub unsafe fn pop_front_unchecked(&mut self) -> T {
debug_assert!(!self.is_empty());
let index = self.front;
@ -285,12 +286,13 @@ impl<T, const N: usize> Deque<T, N> {
(self.buffer.get_unchecked_mut(index).as_ptr() as *const T).read()
}
/// Removes an item from the back of the deque and returns it
/// Removes an item from the back of the deque and returns it, without checking that the deque
/// is not empty
///
/// # Safety
///
/// This assumes the deque is not empty.
pub(crate) unsafe fn pop_back_unchecked(&mut self) -> T {
/// It's undefined behavior to call this on an empty deque
pub unsafe fn pop_back_unchecked(&mut self) -> T {
debug_assert!(!self.is_empty());
self.full = false;