* Fix #2612: adjust readable trait to allow try_peek Our implementation for Readable was inconsistent. We had a try_unchecked variant for read but not for peek. This resolves that by making a breaking change to the Readable interface. * fix doctests too
This commit is contained in:
1 parent
443b9a4af6
commit
e42b71b1ba
13 files changed
+102
-58
No files matched your search
@@ -1,7 +1,7 @@
|
||||
use crate::{read::Readable, Memo, ReadableRef};
|
||||
use crate::{read_impls, GlobalKey};
|
||||
use dioxus_core::prelude::ScopeId;
|
||||
use generational_box::UnsyncStorage;
|
||||
use generational_box::{BorrowResult, UnsyncStorage};
|
||||
use std::ops::Deref;
|
||||
|
||||
use crate::Signal;
|
||||
@@ -75,8 +75,8 @@ impl<T: PartialEq + 'static> Readable for GlobalMemo<T> {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
|
||||
self.memo().peek_unchecked()
|
||||
fn try_peek_unchecked(&self) -> BorrowResult<ReadableRef<'static, Self>> {
|
||||
self.memo().try_peek_unchecked()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::{read::Readable, ReadableRef};
|
||||
use crate::{write::Writable, GlobalKey};
|
||||
use crate::{WritableRef, Write};
|
||||
use dioxus_core::{prelude::ScopeId, Runtime};
|
||||
use generational_box::UnsyncStorage;
|
||||
use generational_box::{BorrowResult, UnsyncStorage};
|
||||
use std::ops::Deref;
|
||||
|
||||
use super::get_global_context;
|
||||
@@ -110,8 +110,8 @@ impl<T: 'static> Readable for GlobalSignal<T> {
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn peek_unchecked(&self) -> ReadableRef<'static, Self> {
|
||||
self.signal().peek_unchecked()
|
||||
fn try_peek_unchecked(&self) -> BorrowResult<ReadableRef<'static, Self>> {
|
||||
self.signal().try_peek_unchecked()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user