erase the original readable type

This commit is contained in:
Evan Almloff committed 2024-02-07 11:19:39 -06:00
1 parent c8937cb4df
commit 8689509eb5
9 files changed
+99 -175

No files matched your search

+5 -19
View File
@@ -1,6 +1,6 @@
use crate::read::Readable;
use crate::{read::Readable, ReadableRef};
use dioxus_core::prelude::{IntoAttributeValue, ScopeId};
use generational_box::{AnyStorage, UnsyncStorage};
use generational_box::UnsyncStorage;
use std::{mem::MaybeUninit, ops::Deref};
use crate::{ReadOnlySignal, Signal};
@@ -53,29 +53,15 @@ impl<T: PartialEq + 'static> GlobalMemo<T> {
impl<T: PartialEq + 'static> Readable for GlobalMemo<T> {
type Target = T;
type Ref<R: ?Sized + 'static> = generational_box::GenerationalRef<std::cell::Ref<'static, R>>;
fn map_ref<I: ?Sized, U: ?Sized, F: FnOnce(&I) -> &U>(
ref_: Self::Ref<I>,
f: F,
) -> Self::Ref<U> {
<UnsyncStorage as AnyStorage>::map(ref_, f)
}
fn try_map_ref<I: ?Sized, U: ?Sized, F: FnOnce(&I) -> Option<&U>>(
ref_: Self::Ref<I>,
f: F,
) -> Option<Self::Ref<U>> {
<UnsyncStorage as AnyStorage>::try_map(ref_, f)
}
type Storage = UnsyncStorage;
#[track_caller]
fn try_read(&self) -> Result<Self::Ref<T>, generational_box::BorrowError> {
fn try_read(&self) -> Result<ReadableRef<Self>, generational_box::BorrowError> {
self.signal().try_read()
}
#[track_caller]
fn peek(&self) -> Self::Ref<T> {
fn peek(&self) -> ReadableRef<Self> {
self.signal().peek()
}
}
+5 -19
View File
@@ -1,8 +1,8 @@
use crate::read::Readable;
use crate::write::Writable;
use crate::Write;
use crate::{read::Readable, ReadableRef};
use dioxus_core::prelude::{IntoAttributeValue, ScopeId};
use generational_box::{AnyStorage, UnsyncStorage};
use generational_box::UnsyncStorage;
use std::{mem::MaybeUninit, ops::Deref};
use super::get_global_context;
@@ -68,29 +68,15 @@ impl<T: 'static> GlobalSignal<T> {
impl<T: 'static> Readable for GlobalSignal<T> {
type Target = T;
type Ref<R: ?Sized + 'static> = generational_box::GenerationalRef<std::cell::Ref<'static, R>>;
fn map_ref<I: ?Sized, U: ?Sized, F: FnOnce(&I) -> &U>(
ref_: Self::Ref<I>,
f: F,
) -> Self::Ref<U> {
<UnsyncStorage as AnyStorage>::map(ref_, f)
}
fn try_map_ref<I: ?Sized, U: ?Sized, F: FnOnce(&I) -> Option<&U>>(
ref_: Self::Ref<I>,
f: F,
) -> Option<Self::Ref<U>> {
<UnsyncStorage as AnyStorage>::try_map(ref_, f)
}
type Storage = UnsyncStorage;
#[track_caller]
fn try_read(&self) -> Result<Self::Ref<T>, generational_box::BorrowError> {
fn try_read(&self) -> Result<ReadableRef<Self>, generational_box::BorrowError> {
self.signal().try_read()
}
#[track_caller]
fn peek(&self) -> Self::Ref<T> {
fn peek(&self) -> ReadableRef<Self> {
self.signal().peek()
}
}