Преглед на файлове

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>
 {