Implement Debug and ImplicitClone for TreeData (#164)

This commit is contained in:
Cecile Tonglet 2023-02-01 10:17:54 +01:00 committed by GitHub
parent 48b2ef302a
commit f5fdb429b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,12 +11,23 @@ use std::marker::PhantomData;
use std::rc::Rc;
use yew::prelude::*;
#[derive(Clone)]
#[derive(Debug)]
pub struct TreeData<T> {
tree: Rc<RefCell<id_tree::Tree<NodeData<T>>>>,
version: usize,
}
impl<T> Clone for TreeData<T> {
fn clone(&self) -> Self {
Self {
tree: self.tree.clone(),
version: self.version,
}
}
}
impl<T> yew::html::ImplicitClone for TreeData<T> {}
impl<T> PartialEq for TreeData<T> {
fn eq(&self, other: &Self) -> bool {
Rc::ptr_eq(&self.tree, &other.tree) && self.version == other.version
@ -63,6 +74,7 @@ pub struct TreeProps<T: Clone + PartialEq> {
pub class: Classes,
}
#[derive(Debug)]
pub struct NodeData<T> {
pub disabled: bool,
pub has_caret: bool,