Browse Source

Add comments (#64)

César D. Rodas 1 year ago
parent
commit
905f7e0fc9
1 changed files with 16 additions and 5 deletions
  1. 16 5
      src/db/mod.rs

+ 16 - 5
src/db/mod.rs

@@ -42,7 +42,8 @@ pub struct RefValue<'a> {
 }
 
 impl<'a> RefValue<'a> {
-    /// test
+    /// Consumes the RefValue and a new cloned Value, only if the Value is
+    /// scalar, otherwise a WrongType error is returned (casted as a Value)
     #[inline(always)]
     pub fn into_inner(self) -> Value {
         self.slot
@@ -58,7 +59,7 @@ impl<'a> RefValue<'a> {
             .unwrap_or_default()
     }
 
-    /// test
+    /// Gets an optional reference to the read guarded value
     pub fn inner(&self) -> Option<RwLockReadGuard<'_, Value>> {
         self.slot
             .get(self.key)
@@ -66,7 +67,7 @@ impl<'a> RefValue<'a> {
             .map(|x| x.get())
     }
 
-    /// test
+    /// Gets an optional reference to the write guarded value
     pub fn inner_mut(&self) -> Option<RwLockWriteGuard<'_, Value>> {
         self.slot
             .get(self.key)
@@ -74,7 +75,12 @@ impl<'a> RefValue<'a> {
             .map(|x| x.get_mut())
     }
 
-    /// map_mut
+    /// map
+    ///
+    /// Maps an `Option<T>` to `Option<U>` by applying a function to a contained
+    /// value (if `Some`) or returns `None` (if `None`). The RefValue is
+    /// consumed so the underlying ReadGuard is dropped so slot is free as this
+    /// function returns
     #[inline(always)]
     pub fn map<T, F>(self, f: F) -> Option<T>
     where
@@ -86,7 +92,12 @@ impl<'a> RefValue<'a> {
         })
     }
 
-    /// map_mut
+    /// map_ut
+    ///
+    /// Maps an `Option<&mut T>` to `Option<&mut U>` by applying a function to a contained
+    /// value (if `Some`) or returns `None` (if `None`). The RefValue is
+    /// consumed so the underlying ReadGuard is dropped so slot is free as this
+    /// function returns
     #[inline(always)]
     pub fn map_mut<T, F>(self, f: F) -> Option<T>
     where