mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-28 04:50:34 +00:00
Merge #292
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:
commit
c2a022d9be
@ -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
|
||||
|
||||
|
14
src/deque.rs
14
src/deque.rs
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user