File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77//! This module provides a `PackedOption<T>` for types that have a reserved value that can be used
88//! to represent `None`.
99
10- use core:: fmt;
11- use core :: mem ;
10+ use core:: { fmt, mem } ;
11+ use wasmtime_core :: { alloc :: TryClone , error :: OutOfMemory } ;
1212
1313#[ cfg( feature = "enable-serde" ) ]
1414use serde_derive:: { Deserialize , Serialize } ;
@@ -30,6 +30,15 @@ pub trait ReservedValue {
3030#[ repr( transparent) ]
3131pub struct PackedOption < T : ReservedValue > ( T ) ;
3232
33+ impl < T > TryClone for PackedOption < T >
34+ where
35+ T : ReservedValue + TryClone ,
36+ {
37+ fn try_clone ( & self ) -> Result < Self , OutOfMemory > {
38+ Ok ( Self ( self . 0 . try_clone ( ) ?) )
39+ }
40+ }
41+
3342impl < T : ReservedValue > PackedOption < T > {
3443 /// Returns `true` if the packed option is a `None` value.
3544 pub fn is_none ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments