diff --git a/Cargo.toml b/Cargo.toml index 8b0d0e8..7b35474 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "futures-signals-ext" version = "0.4.0" authors = ["martin.kolarik@smartcontrol.cz"] description = "Extension to futures-signals: MutableOption with combinators, spawning, predicate driven selections from SignalVec." -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" repository = "https://github.com/martin-kolarik/futures-signals-ext" homepage = "https://github.com/martin-kolarik/futures-signals-ext" diff --git a/src/entry.rs b/src/entry.rs index 8e472ff..452be51 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -133,7 +133,7 @@ impl<'a, V: Copy> Value<'a, V> { where V: PartialEq, { - if &self.value != &value { + if self.value != value { self.value = value; self.modified = true; } @@ -152,7 +152,7 @@ impl<'a, V: Copy> Value<'a, V> { } } -impl<'a, V: Copy> Deref for Value<'a, V> { +impl Deref for Value<'_, V> { type Target = V; fn deref(&self) -> &V { @@ -160,7 +160,7 @@ impl<'a, V: Copy> Deref for Value<'a, V> { } } -impl<'a, V: Copy> Drop for Value<'a, V> { +impl Drop for Value<'_, V> { fn drop(&mut self) { if self.modified && let Some(mut entry) = self.entry.take() @@ -301,7 +301,7 @@ impl<'a, V: Clone> ValueCloned<'a, V> { where V: PartialEq, { - if &self.value != &value { + if self.value != value { self.value = value; self.modified = true; } @@ -320,7 +320,7 @@ impl<'a, V: Clone> ValueCloned<'a, V> { } } -impl<'a, V: Clone> Deref for ValueCloned<'a, V> { +impl Deref for ValueCloned<'_, V> { type Target = V; fn deref(&self) -> &V { @@ -328,7 +328,7 @@ impl<'a, V: Clone> Deref for ValueCloned<'a, V> { } } -impl<'a, V: Clone> Drop for ValueCloned<'a, V> { +impl Drop for ValueCloned<'_, V> { fn drop(&mut self) { if self.modified && let Some(mut entry) = self.entry.take() @@ -339,17 +339,17 @@ impl<'a, V: Clone> Drop for ValueCloned<'a, V> { } pub trait MutableVecEntry { - fn entry<'a, F>(&'a self, f: F) -> Entry<'a, V> + fn entry(&self, f: F) -> Entry where F: FnMut(&V) -> bool; - fn entry_cloned<'a, F>(&'a self, f: F) -> EntryCloned<'a, V> + fn entry_cloned(&self, f: F) -> EntryCloned where F: FnMut(&V) -> bool; } impl MutableVecEntry for MutableVec { - fn entry<'a, F>(&'a self, f: F) -> Entry<'a, V> + fn entry(&self, f: F) -> Entry where F: FnMut(&V) -> bool, { @@ -358,7 +358,7 @@ impl MutableVecEntry for MutableVec { Entry { key, lock } } - fn entry_cloned<'a, F>(&'a self, f: F) -> EntryCloned<'a, V> + fn entry_cloned(&self, f: F) -> EntryCloned where F: FnMut(&V) -> bool, { diff --git a/src/option.rs b/src/option.rs index 9db0b8a..439d12e 100644 --- a/src/option.rs +++ b/src/option.rs @@ -96,42 +96,49 @@ impl MutableOption { self.0.lock_ref().as_ref().and_then(f) } - pub fn signal_some_default(&self) -> impl Signal + pub fn signal_some_default(&self) -> impl Signal + use where T: Default + Copy, { self.signal_map_some_default(|v| *v) } - pub fn signal_cloned_some_default(&self) -> impl Signal + pub fn signal_cloned_some_default(&self) -> impl Signal + use where T: Default + Clone, { self.signal_map_some_default(|v| v.clone()) } - pub fn signal_map(&self, mut f: F) -> impl Signal> + pub fn signal_map(&self, mut f: F) -> impl Signal> + use where F: FnMut(Option<&T>) -> Option, { self.0.signal_ref(move |v| f(v.as_ref())) } - pub fn signal_map_some(&self, mut f: F) -> impl Signal> + pub fn signal_map_some(&self, mut f: F) -> impl Signal> + use where F: FnMut(&T) -> U, { self.0.signal_ref(move |v| v.as_ref().map(&mut f)) } - pub fn signal_and_then_some(&self, mut f: F) -> impl Signal> + pub fn signal_and_then_some( + &self, + mut f: F, + ) -> impl Signal> + use where F: FnMut(&T) -> Option, { self.0.signal_ref(move |v| v.as_ref().and_then(&mut f)) } - pub fn signal_and_then_some_or(&self, mut f: F, default: U) -> impl Signal + pub fn signal_and_then_some_or( + &self, + mut f: F, + default: U, + ) -> impl Signal + use where F: FnMut(&T) -> Option, U: Clone, @@ -147,7 +154,7 @@ impl MutableOption { &self, mut f: F, default: D, - ) -> impl Signal + ) -> impl Signal + use where F: FnMut(&T) -> Option, D: FnOnce() -> U + Clone, @@ -156,7 +163,11 @@ impl MutableOption { .signal_ref(move |v| v.as_ref().and_then(&mut f).unwrap_or_else(default.clone())) } - pub fn signal_map_some_or(&self, mut f: F, default: U) -> impl Signal + pub fn signal_map_some_or( + &self, + mut f: F, + default: U, + ) -> impl Signal + use where F: FnMut(&T) -> U, U: Clone, @@ -165,7 +176,11 @@ impl MutableOption { .signal_ref(move |v| v.as_ref().map(&mut f).unwrap_or(default.clone())) } - pub fn signal_map_some_or_else(&self, mut f: F, default: D) -> impl Signal + pub fn signal_map_some_or_else( + &self, + mut f: F, + default: D, + ) -> impl Signal + use where F: FnMut(&T) -> U, D: FnOnce() -> U + Clone, @@ -174,7 +189,7 @@ impl MutableOption { .signal_ref(move |v| v.as_ref().map(&mut f).unwrap_or_else(default.clone())) } - pub fn signal_map_some_default(&self, mut f: F) -> impl Signal + pub fn signal_map_some_default(&self, mut f: F) -> impl Signal + use where F: FnMut(&T) -> U, U: Default, diff --git a/src/spawn.rs b/src/spawn.rs index 6c32de9..fce4528 100644 --- a/src/spawn.rs +++ b/src/spawn.rs @@ -43,7 +43,7 @@ pub trait SignalVecSpawn { #[cfg(not(target_os = "unknown"))] mod os { - use std::future::{ready, Future}; + use std::future::{Future, ready}; use futures_signals::{ signal::{Signal, SignalExt}, @@ -95,7 +95,7 @@ mod os { F: Fn(A) -> W + 'static, W: Future + 'static, { - artwrap::spawn_local(self.for_each(move |new| f(new))); + artwrap::spawn_local(self.for_each(f)); } } @@ -130,7 +130,7 @@ mod os { #[cfg(all(target_arch = "wasm32", feature = "spawn-local"))] mod wasm { - use std::future::{ready, Future}; + use std::future::{Future, ready}; use futures_signals::{ signal::{Signal, SignalExt},