mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-02 14:54:30 +00:00
Refactor terminator pop
This commit is contained in:
parent
424f5ab39c
commit
fb8525bad4
@ -223,13 +223,9 @@ impl<const N: usize> CString<N> {
|
|||||||
/// # Safety: caller must ensure to re-add the terminator after this function is called
|
/// # Safety: caller must ensure to re-add the terminator after this function is called
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn pop_terminator(&mut self) {
|
unsafe fn pop_terminator(&mut self) {
|
||||||
if cfg!(debug_assertions) {
|
debug_assert_eq!(self.vec.last(), Some(&0));
|
||||||
let popped = self.vec.pop();
|
|
||||||
|
|
||||||
assert_eq!(popped, Some(0));
|
unsafe { self.vec.pop_unchecked() };
|
||||||
} else {
|
|
||||||
unsafe { self.vec.pop_unchecked() };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a [`CString`] to a string slice without checking
|
/// Converts a [`CString`] to a string slice without checking
|
||||||
|
Loading…
x
Reference in New Issue
Block a user