diff --git a/cranelift/entity/src/packed_option.rs b/cranelift/entity/src/packed_option.rs index 36f97d6d4da2..fd1451802a8f 100644 --- a/cranelift/entity/src/packed_option.rs +++ b/cranelift/entity/src/packed_option.rs @@ -7,8 +7,8 @@ //! This module provides a `PackedOption` for types that have a reserved value that can be used //! to represent `None`. -use core::fmt; -use core::mem; +use core::{fmt, mem}; +use wasmtime_core::{alloc::TryClone, error::OutOfMemory}; #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; @@ -30,6 +30,15 @@ pub trait ReservedValue { #[repr(transparent)] pub struct PackedOption(T); +impl TryClone for PackedOption +where + T: ReservedValue + TryClone, +{ + fn try_clone(&self) -> Result { + Ok(Self(self.0.try_clone()?)) + } +} + impl PackedOption { /// Returns `true` if the packed option is a `None` value. pub fn is_none(&self) -> bool {