Skip to content

Commit

Permalink
Add test for drop behavior on array to vec conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsberry authored and Dirbaio committed Jan 1, 2024
1 parent fb78a9b commit 0a5fd1d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,23 @@ mod tests {
assert_eq!(v.as_slice(), &[1, 2, 3]);
}

#[test]
fn from_array_no_drop() {
struct Drops(Option<u8>);

impl Drop for Drops {
fn drop(&mut self) {
self.0 = None;
}
}

let v: Vec<Drops, 3> = Vec::from([Drops(Some(1)), Drops(Some(2)), Drops(Some(3))]);

assert_eq!(v[0].0, Some(1));
assert_eq!(v[1].0, Some(2));
assert_eq!(v[2].0, Some(3));
}

#[test]
fn starts_with() {
let v: Vec<_, 8> = Vec::from_slice(b"ab").unwrap();
Expand Down

0 comments on commit 0a5fd1d

Please sign in to comment.