Skip to content

Commit

Permalink
Merge pull request #680 from jrose-signal/Optional-Finalize
Browse files Browse the repository at this point in the history
Make Option<T: Finalize> implement Finalize
  • Loading branch information
kjvalencik authored Feb 10, 2021
2 parents 8af9d22 + 10b84c7 commit d775895
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/types/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,22 @@ impl<T: Finalize> Finalize for Vec<T> {
}
}

// Smart Pointers
// Smart pointers and other wrappers

impl<T: Finalize> Finalize for std::boxed::Box<T> {
fn finalize<'a, C: Context<'a>>(self, cx: &mut C) {
(*self).finalize(cx);
}
}

impl<T: Finalize> Finalize for Option<T> {
fn finalize<'a, C: Context<'a>>(self, cx: &mut C) {
if let Some(v) = self {
v.finalize(cx);
}
}
}

impl<T: Finalize> Finalize for std::rc::Rc<T> {
fn finalize<'a, C: Context<'a>>(self, cx: &mut C) {
if let Ok(v) = std::rc::Rc::try_unwrap(self) {
Expand Down

0 comments on commit d775895

Please sign in to comment.