]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust: bql: add BqlRefCell::get_mut()
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 17 Sep 2025 10:10:45 +0000 (12:10 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 14 Oct 2025 09:03:59 +0000 (11:03 +0200)
This method is rarely useful in QEMU due to the pervasiveness of
shared references, but add it for when a &mut BqlRefCell<> is used.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/bql/src/cell.rs

index 24ab294b60d084eed4da1230777c8a96b8998c84..54cfe6145c534d35efdc2985917295f0511befd1 100644 (file)
@@ -580,6 +580,23 @@ impl<T> BqlRefCell<T> {
         }
     }
 
+    /// Returns a mutable reference to the underlying data in this cell,
+    /// while the owner already has a mutable reference to the cell.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use bql::BqlRefCell;
+    ///
+    /// let mut c = BqlRefCell::new(5);
+    ///
+    /// *c.get_mut() = 10;
+    /// ```
+    #[inline]
+    pub const fn get_mut(&mut self) -> &mut T {
+        self.value.get_mut()
+    }
+
     /// Returns a raw pointer to the underlying data in this cell.
     ///
     /// # Examples