aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar James Hillyerd <james@hillyerd.com> 2021-06-06 14:56:00 -0700
committerGravatar James Hillyerd <james@hillyerd.com> 2021-06-06 14:56:00 -0700
commit064ff239f373daf93d73d73eaf7dc7bece05ef0e (patch)
treeee89c7588dbc841913e4a6a7c6e8a5e44fa94bc4 /src
parent3fd3eea9415da568de51f3fbcebc3a38403367a1 (diff)
downloadrtic-064ff239f373daf93d73d73eaf7dc7bece05ef0e.tar.gz
rtic-064ff239f373daf93d73d73eaf7dc7bece05ef0e.tar.zst
rtic-064ff239f373daf93d73d73eaf7dc7bece05ef0e.zip
Allow zero sized LinkedList
Diffstat (limited to 'src')
-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();