瀏覽代碼

Add Deref and DerefMut impls to Serialized<T>.

Kestrel 2 月之前
父節點
當前提交
6c079dcad6
共有 1 個文件被更改,包括 15 次插入0 次删除
  1. 15 0
      microrm/src/schema.rs

+ 15 - 0
microrm/src/schema.rs

@@ -161,6 +161,21 @@ impl<T: serde::Serialize + serde::de::DeserializeOwned + Clone> AsMut<T> for Ser
     }
 }
 
+impl<T: serde::Serialize + serde::de::DeserializeOwned + Clone> std::ops::Deref for Serialized<T> {
+    type Target = T;
+    fn deref(&self) -> &Self::Target {
+        &self.wrapped
+    }
+}
+
+impl<T: serde::Serialize + serde::de::DeserializeOwned + Clone> std::ops::DerefMut
+    for Serialized<T>
+{
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.wrapped
+    }
+}
+
 impl<T: 'static + serde::Serialize + serde::de::DeserializeOwned + std::fmt::Debug + Clone> Datum
     for Serialized<T>
 {