Skip to content

Commit

Permalink
feat: implement Default for RwSignal and StoredValue (#1877)
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiaozero authored Oct 11, 2023
1 parent 4baa75c commit 2003044
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions leptos_reactive/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,12 @@ where
pub(crate) defined_at: &'static std::panic::Location<'static>,
}

impl<T: Default> Default for RwSignal<T> {
fn default() -> Self {
Self::new(Default::default())
}
}

impl<T> Clone for RwSignal<T> {
fn clone(&self) -> Self {
*self
Expand Down
6 changes: 6 additions & 0 deletions leptos_reactive/src/stored_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ where
ty: PhantomData<T>,
}

impl<T: Default> Default for StoredValue<T> {
fn default() -> Self {
Self::new(Default::default())
}
}

impl<T> Clone for StoredValue<T> {
fn clone(&self) -> Self {
*self
Expand Down

0 comments on commit 2003044

Please sign in to comment.