Skip to content

Commit

Permalink
Add support for boxed values (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
VanceLongwill committed Jan 31, 2024
1 parent 087764d commit f0bf96f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion expunge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

use std::{
collections::{HashMap, HashSet},
ops::{Deref, DerefMut},
ops::{Deref, DerefMut}, sync::Arc,
};

pub use expunge_derive::*;
Expand Down Expand Up @@ -242,6 +242,14 @@ where
}
}

impl<T> Expunge for Box<T> where T: Expunge {
fn expunge(self) -> Self
where
Self: Sized {
Box::new((*self).expunge())
}
}

#[cfg(feature = "zeroize")]
impl<T> Expunge for Secret<T>
where
Expand Down
15 changes: 15 additions & 0 deletions expunge/tests/expunge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,18 @@ fn it_works_enum() {
let expunged = item.expunge();
assert_eq!(SensitiveItem::ZeroizableString("99".to_string()), expunged);
}

#[test]
fn it_returns_boxed() {
#[derive(Expunge)]
struct Location {
#[expunge]
city: String,
}

let location = Box::new(Location {
city: "New York".to_string(),
});

let _: Box<Location> = location.expunge();
}

0 comments on commit f0bf96f

Please sign in to comment.