Skip to content

Commit

Permalink
#73 View now Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Jan 22, 2025
1 parent ad0f481 commit 52e50cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> LayoutArgs<'a> {
}

/// Trait for the unit of UI composition.
pub trait DynView: private::Sealed + 'static {
pub trait DynView: private::Sealed + DynClone + 'static {
/// Builds an AccessKit tree. The node ID for the subtree is returned. All generated nodes are accumulated.
fn access(
&self,
Expand Down Expand Up @@ -85,6 +85,6 @@ pub trait DynView: private::Sealed + 'static {
}
}

pub trait View: DynView {}
pub trait View: DynView + Clone {}

impl<V: DynView> View for V {}
impl<V: DynView + Clone> View for V {}
3 changes: 3 additions & 0 deletions src/views/anyview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use std::any::TypeId;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

dyn_clone::clone_trait_object!(DynView);

/// Struct for `any_view`
#[derive(Clone)]
pub struct AnyView {
child: Box<dyn DynView>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/viewtuple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::*;

/// Allows rui to iterate over a tuple of `Views`.
pub trait ViewTuple {
pub trait ViewTuple: Clone {
fn foreach_view<F: FnMut(&dyn DynView)>(&self, f: &mut F);
fn foreach_view_rev<F: FnMut(&dyn DynView)>(&self, f: &mut F);
fn len(&self) -> usize;
Expand Down

0 comments on commit 52e50cc

Please sign in to comment.