diff --git a/expunge/src/lib.rs b/expunge/src/lib.rs index b596a66..341b704 100644 --- a/expunge/src/lib.rs +++ b/expunge/src/lib.rs @@ -72,7 +72,7 @@ use std::{ collections::{HashMap, HashSet}, - ops::{Deref, DerefMut}, + ops::{Deref, DerefMut}, sync::Arc, }; pub use expunge_derive::*; @@ -242,6 +242,14 @@ where } } +impl Expunge for Box where T: Expunge { + fn expunge(self) -> Self + where + Self: Sized { + Box::new((*self).expunge()) + } +} + #[cfg(feature = "zeroize")] impl Expunge for Secret where diff --git a/expunge/tests/expunge.rs b/expunge/tests/expunge.rs index a138f8d..b8a5b3e 100644 --- a/expunge/tests/expunge.rs +++ b/expunge/tests/expunge.rs @@ -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.expunge(); +}