Allow zero sized LinkedList

This commit is contained in:
James Hillyerd 2021-06-06 14:56:00 -07:00
parent 3fd3eea941
commit 064ff239f3

View file

@ -269,6 +269,11 @@ where
let len = N::U16;
let mut free = 0;
if len == 0 {
list.free = LinkedIndex::none();
return list;
}
// Initialize indexes
while free < len - 1 {
unsafe {
@ -557,6 +562,13 @@ mod tests {
assert!(ll.is_empty())
}
#[test]
fn test_zero_size() {
let ll: LinkedList<u32, Max, U0> = LinkedList::new();
assert!(ll.is_full());
}
#[test]
fn test_rejected_push() {
let mut ll: LinkedList<u32, Max, U3> = LinkedList::new();