mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
Allow zero sized LinkedList
This commit is contained in:
parent
3fd3eea941
commit
064ff239f3
1 changed files with 12 additions and 0 deletions
|
@ -269,6 +269,11 @@ where
|
||||||
let len = N::U16;
|
let len = N::U16;
|
||||||
let mut free = 0;
|
let mut free = 0;
|
||||||
|
|
||||||
|
if len == 0 {
|
||||||
|
list.free = LinkedIndex::none();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize indexes
|
// Initialize indexes
|
||||||
while free < len - 1 {
|
while free < len - 1 {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -557,6 +562,13 @@ mod tests {
|
||||||
assert!(ll.is_empty())
|
assert!(ll.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_zero_size() {
|
||||||
|
let ll: LinkedList<u32, Max, U0> = LinkedList::new();
|
||||||
|
|
||||||
|
assert!(ll.is_full());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rejected_push() {
|
fn test_rejected_push() {
|
||||||
let mut ll: LinkedList<u32, Max, U3> = LinkedList::new();
|
let mut ll: LinkedList<u32, Max, U3> = LinkedList::new();
|
||||||
|
|
Loading…
Reference in a new issue