Skip to content

Commit

Permalink
#79 drop implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Apr 26, 2023
1 parent 3b16b5d commit 93f5097
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ctors.rs
Expand Up @@ -42,6 +42,16 @@ impl<K: Clone + PartialEq, V: Clone, const N: usize> Map<K, V, N> {
}
}

impl<K: Clone + PartialEq, V: Clone, const N: usize> Drop for Map<K, V, N> {
fn drop(&mut self) {
for i in 0..self.next {
unsafe {
self.pairs[i].assume_init_drop();
}
}
}
}

#[cfg(test)]
use anyhow::Result;

Expand All @@ -66,7 +76,6 @@ fn drops_correctly() -> Result<()> {
}

#[test]
#[ignore]
fn drops_keys() {
use std::rc::Rc;
let mut m: Map<Rc<()>, (), 8> = Map::new();
Expand All @@ -77,7 +86,6 @@ fn drops_keys() {
}

#[test]
#[ignore]
fn drops_values() {
use std::rc::Rc;
let mut m: Map<(), Rc<()>, 8> = Map::new();
Expand Down

0 comments on commit 93f5097

Please sign in to comment.