mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-09-21 06:41:54 +00:00
feat: add split method to use_state
This commit is contained in:
parent
6c3f5195f4
commit
156e3c21ba
1 changed files with 6 additions and 0 deletions
|
@ -285,6 +285,12 @@ impl<T: Clone> UseState<T> {
|
|||
|
||||
RefMut::map(slot, |rc| Rc::get_mut(rc).expect("the hard count to be 0"))
|
||||
}
|
||||
|
||||
/// Convert this handle to a tuple of the value and the handle itself.
|
||||
#[must_use]
|
||||
pub fn split(&self) -> (&T, &Self) {
|
||||
(&self.current_val, self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Clone for UseState<T> {
|
||||
|
|
Loading…
Reference in a new issue