Make the function bounds for map less restrictive

This commit is contained in:
Evan Almloff committed 2023-12-23 13:43:27 -06:00
1 parent bfacf94db4
commit a2fadc8d11
3 files changed
+30 -2

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ pub struct SignalMap<U: 'static + ?Sized> {
impl<U: ?Sized> SignalMap<U> {
/// Create a new mapped signal.
pub fn new<T: 'static>(signal: Signal<T>, mapping: fn(&T) -> &U) -> Self {
pub fn new<T: 'static>(signal: Signal<T>, mapping: impl Fn(&T) -> &U + 'static) -> Self {
Self {
origin_scope: signal.origin_scope(),
mapping: CopyValue::new(Box::new(move || Ref::map(signal.read(), |v| (mapping)(v)))),