Skip to content

Commit

Permalink
#72 add Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Jan 22, 2025
1 parent 91eedb7 commit 8388c27
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/views/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct Command<V, F> {
impl<V, F> Command<V, F>
where
V: View,
F: Fn(&mut Context) + 'static,
F: Fn(&mut Context) + Clone + 'static,
{
pub fn new(v: V, name: String, key: Option<HotKey>, f: F) -> Self {
Self {
Expand All @@ -27,7 +27,7 @@ where
impl<V, F> View for Command<V, F>
where
V: View,
F: Fn(&mut Context) + 'static,
F: Fn(&mut Context) + Clone + 'static,
{
fn process(
&self,
Expand Down Expand Up @@ -96,7 +96,7 @@ where
impl<V, F> private::Sealed for Command<V, F>
where
V: View,
F: Fn(&mut Context) + 'static,
F: Fn(&mut Context) + Clone + 'static,
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/views/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl<S, V, F> View for EnvView<S, V, F>
where
V: View,
S: Clone + Default + 'static,
F: Fn(S, &mut Context) -> V + 'static,
F: Fn(S, &mut Context) -> V + Clone + 'static,
{
fn process(
&self,
Expand Down Expand Up @@ -81,7 +81,7 @@ where
impl<S, V, F> private::Sealed for EnvView<S, V, F> {}

/// Reads from the environment.
pub fn env<S: Clone + Default + 'static, V: View, F: Fn(S, &mut Context) -> V + 'static>(
pub fn env<S: Clone + Default + 'static, V: View, F: Fn(S, &mut Context) -> V + Clone + 'static>(
f: F,
) -> impl View {
EnvView {
Expand Down
4 changes: 2 additions & 2 deletions src/views/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Focus<F> {
impl<V, F> View for Focus<F>
where
V: View,
F: Fn(bool) -> V + 'static,
F: Fn(bool) -> V + Clone + 'static,
{
fn process(
&self,
Expand Down Expand Up @@ -102,6 +102,6 @@ impl<F> private::Sealed for Focus<F> {}

/// Calls calls a function with true if the view subtree returned
/// by the function has the keyboard focus.
pub fn focus<V: View, F: Fn(bool) -> V + 'static>(f: F) -> impl View {
pub fn focus<V: View, F: Fn(bool) -> V + Clone + 'static>(f: F) -> impl View {
Focus { func: f }
}
4 changes: 2 additions & 2 deletions src/views/geom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Geom<V, F> {
impl<V, F> View for Geom<V, F>
where
V: View,
F: Fn(&mut Context, LocalSize, LocalToWorld) + 'static,
F: Fn(&mut Context, LocalSize, LocalToWorld) + Clone + 'static,
{
fn process(
&self,
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<V, F> private::Sealed for Geom<V, F> {}
impl<V, F> Geom<V, F>
where
V: View,
F: Fn(&mut Context, LocalSize, LocalToWorld) + 'static,
F: Fn(&mut Context, LocalSize, LocalToWorld) + Clone + 'static,
{
pub fn new(child: V, f: F) -> Self {
Self { child, func: f }
Expand Down
4 changes: 2 additions & 2 deletions src/views/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Handle<V, F, A, A2> {
impl<V, F, A, A2> Handle<V, F, A, A2>
where
V: View,
F: Fn(&mut Context, &A) -> A2 + 'static,
F: Fn(&mut Context, &A) -> A2 + Clone + 'static,
{
pub fn new(v: V, f: F) -> Self {
Self {
Expand All @@ -28,7 +28,7 @@ where
impl<V, F, A, A2> View for Handle<V, F, A, A2>
where
V: View,
F: Fn(&mut Context, &A) -> A2 + 'static,
F: Fn(&mut Context, &A) -> A2 + Clone + 'static,
A: 'static,
A2: 'static,
{
Expand Down
4 changes: 2 additions & 2 deletions src/views/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct KeyView<V, F> {
impl<V, F, A> KeyView<V, F>
where
V: View,
F: Fn(&mut Context, Key) -> A + 'static,
F: Fn(&mut Context, Key) -> A + Clone + 'static,
{
pub fn new(v: V, f: F) -> Self {
KeyView { child: v, func: f }
Expand All @@ -21,7 +21,7 @@ where
impl<V, F, A> View for KeyView<V, F>
where
V: View,
F: Fn(&mut Context, Key) -> A + 'static,
F: Fn(&mut Context, Key) -> A + Clone + 'static,
A: 'static,
{
fn process(
Expand Down
6 changes: 3 additions & 3 deletions src/views/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,23 @@ impl<ID, F> private::Sealed for List<ID, F> {}
/// ))
/// }));
/// ```
pub fn list<ID: Hash, V: View, F: Fn(&ID) -> V + 'static>(ids: Vec<ID>, f: F) -> List<ID, F> {
pub fn list<ID: Hash, V: View, F: Fn(&ID) -> V + Clone + 'static>(ids: Vec<ID>, f: F) -> List<ID, F> {
List {
orientation: ListOrientation::Vertical,
ids,
func: f,
}
}

pub fn hlist<ID: Hash, V: View, F: Fn(&ID) -> V + 'static>(ids: Vec<ID>, f: F) -> List<ID, F> {
pub fn hlist<ID: Hash, V: View, F: Fn(&ID) -> V + Clone + 'static>(ids: Vec<ID>, f: F) -> List<ID, F> {
List {
orientation: ListOrientation::Horizontal,
ids,
func: f,
}
}

pub fn zlist<ID: Hash, V: View, F: Fn(&ID) -> V + 'static>(ids: Vec<ID>, f: F) -> List<ID, F> {
pub fn zlist<ID: Hash, V: View, F: Fn(&ID) -> V + Clone + 'static>(ids: Vec<ID>, f: F) -> List<ID, F> {
List {
orientation: ListOrientation::Z,
ids,
Expand Down

0 comments on commit 8388c27

Please sign in to comment.