From 10b84c773eb2ee66ef4e7dad3c5827889a8d5444 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 9 Feb 2021 15:13:21 -0800 Subject: [PATCH] Make Option implement Finalize --- src/types/boxed.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/types/boxed.rs b/src/types/boxed.rs index 73c060ebc..3b9e6378a 100644 --- a/src/types/boxed.rs +++ b/src/types/boxed.rs @@ -370,7 +370,7 @@ impl Finalize for Vec { } } -// Smart Pointers +// Smart pointers and other wrappers impl Finalize for std::boxed::Box { fn finalize<'a, C: Context<'a>>(self, cx: &mut C) { @@ -378,6 +378,14 @@ impl Finalize for std::boxed::Box { } } +impl Finalize for Option { + fn finalize<'a, C: Context<'a>>(self, cx: &mut C) { + if let Some(v) = self { + v.finalize(cx); + } + } +} + impl Finalize for std::rc::Rc { fn finalize<'a, C: Context<'a>>(self, cx: &mut C) { if let Ok(v) = std::rc::Rc::try_unwrap(self) {