From 0df6a8f2ac2995687b225e9b72e33db85625cdf0 Mon Sep 17 00:00:00 2001 From: serzhiio Date: Sun, 28 May 2023 20:09:09 +0400 Subject: [PATCH 1/2] Added `.with_mut_silent()` fn --- packages/fermi/src/hooks/atom_ref.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/fermi/src/hooks/atom_ref.rs b/packages/fermi/src/hooks/atom_ref.rs index d2fa3f21..600a0e02 100644 --- a/packages/fermi/src/hooks/atom_ref.rs +++ b/packages/fermi/src/hooks/atom_ref.rs @@ -4,6 +4,7 @@ use std::{ cell::{Ref, RefCell, RefMut}, rc::Rc, }; +use std::ops::DerefMut; /// /// @@ -70,6 +71,12 @@ impl UseAtomRef { self.value.borrow() } + /// This is silent operation + /// call `.force_update()` manually if required + pub fn with_mut_silent(&self, cb: impl FnOnce(&mut T)) { + cb(self.write_silent().deref_mut()) + } + pub fn write(&self) -> RefMut { self.root.force_update(self.ptr); self.value.borrow_mut() From 0439072a45d5cadcf9d6197dc99aa73d2f504871 Mon Sep 17 00:00:00 2001 From: serzhiio Date: Sun, 28 May 2023 20:24:39 +0400 Subject: [PATCH 2/2] upd --- packages/fermi/src/hooks/atom_ref.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/fermi/src/hooks/atom_ref.rs b/packages/fermi/src/hooks/atom_ref.rs index 600a0e02..95732c49 100644 --- a/packages/fermi/src/hooks/atom_ref.rs +++ b/packages/fermi/src/hooks/atom_ref.rs @@ -4,7 +4,6 @@ use std::{ cell::{Ref, RefCell, RefMut}, rc::Rc, }; -use std::ops::DerefMut; /// /// @@ -74,7 +73,7 @@ impl UseAtomRef { /// This is silent operation /// call `.force_update()` manually if required pub fn with_mut_silent(&self, cb: impl FnOnce(&mut T)) { - cb(self.write_silent().deref_mut()) + cb(&mut *self.write_silent()) } pub fn write(&self) -> RefMut {