-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I found some oddness in terms of saturating and wrapping:
This test fails, because the vecs are the same ([1,2,3]). I assume saturating means the ArrayDeque should be [1,2,3], and wrapping means it evicts old items, so I assume this should be [4,5,3] (since it fills up to [1,2,3], then evicts [1,2] to make room for [4,5]). If Wrapping and Saturating give the same behavior, is there a reason to have a different types?
#[test]
fn test_bug2_extend_trait_wrapping() {
let mut wrapping: ArrayDeque<i32, 3, Wrapping> = ArrayDeque::new();
wrapping.push_back(1);
wrapping.extend([2, 3, 4, 5]);
let mut saturating: ArrayDeque<i32, 3, Saturating> = ArrayDeque::new();
saturating.push_back(1).unwrap();
saturating.extend([2, 3, 4, 5]);
let sat_vec: Vec<_> = saturating.iter().collect();
let wrap_vec: Vec<_> = wrapping.iter().collect();
assert_ne!(
sat_vec, wrap_vec,
"wrapping and saturating should be different, got: {:?}, {:?}",
sat_vec, wrap_vec
);
}Metadata
Metadata
Assignees
Labels
No labels