aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/linked_list.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/linked_list.rs b/src/linked_list.rs
index 6a9836ee..3a0bda0e 100644
--- a/src/linked_list.rs
+++ b/src/linked_list.rs
@@ -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 {
@@ -558,6 +563,13 @@ mod tests {
}
#[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();
ll.push(1).unwrap();