Skip to content

Commit ffed37a

Browse files
committed
fix: remove unsafe code
1 parent 5f28806 commit ffed37a

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

reactive_graph/src/effect/immediate.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,16 @@ impl<S> Dispose for ImmediateEffect<S> {
7979

8080
impl ImmediateEffect<LocalStorage> {
8181
/// Creates a new effect, which runs immediately, then again as soon as any tracked signal changes.
82-
pub fn new<T, M>(mut fun: impl EffectFunction<T, M> + 'static) -> Self
82+
pub fn new<T, M>(
83+
fun: impl EffectFunction<T, M> + Send + Sync + 'static,
84+
) -> Self
8385
where
8486
T: Send + Sync + 'static,
8587
{
8688
if !cfg!(feature = "effects") {
8789
return Self { inner: None };
8890
}
8991

90-
let fun = {
91-
let thread_id = std::thread::current().id();
92-
93-
/// A wrapper type that is always `Send` and `Sync`.
94-
struct UnsafeSendSync<T>(T);
95-
unsafe impl<T> Send for UnsafeSendSync<T> {}
96-
unsafe impl<T> Sync for UnsafeSendSync<T> {}
97-
impl<F, T, M> EffectFunction<T, M> for UnsafeSendSync<F>
98-
where
99-
F: EffectFunction<T, M> + 'static,
100-
{
101-
fn run(&mut self, p: Option<T>) -> T {
102-
self.0.run(p)
103-
}
104-
}
105-
106-
UnsafeSendSync(move |v| {
107-
assert_eq!(thread_id, std::thread::current().id());
108-
fun.run(v)
109-
})
110-
};
111-
11292
let inner = inner::EffectInner::new(fun);
11393

11494
inner.update_if_necessary();

0 commit comments

Comments
 (0)