✨ Implementa Debug en comp./tipos principales
This commit is contained in:
parent
c3feff9efd
commit
a0b14aec36
21 changed files with 61 additions and 32 deletions
|
|
@ -7,6 +7,7 @@ use parking_lot::RwLock;
|
|||
pub use parking_lot::RwLockReadGuard as ComponentReadGuard;
|
||||
pub use parking_lot::RwLockWriteGuard as ComponentWriteGuard;
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use std::vec::IntoIter;
|
||||
|
||||
|
|
@ -17,6 +18,15 @@ use std::vec::IntoIter;
|
|||
#[derive(AutoDefault, Clone)]
|
||||
pub struct Child(Option<Arc<RwLock<dyn Component>>>);
|
||||
|
||||
impl fmt::Debug for Child {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self.0 {
|
||||
None => write!(f, "Child(None)"),
|
||||
Some(c) => write!(f, "Child({})", c.read().name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Child {
|
||||
/// Crea un nuevo `Child` a partir de un componente.
|
||||
pub fn with(component: impl Component) -> Self {
|
||||
|
|
@ -71,6 +81,15 @@ impl Child {
|
|||
#[derive(AutoDefault, Clone)]
|
||||
pub struct Typed<C: Component>(Option<Arc<RwLock<C>>>);
|
||||
|
||||
impl<C: Component> fmt::Debug for Typed<C> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self.0 {
|
||||
None => write!(f, "Typed(None)"),
|
||||
Some(c) => write!(f, "Typed({})", c.read().name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Component> Typed<C> {
|
||||
/// Crea un nuevo `Typed` a partir de un componente.
|
||||
pub fn with(component: C) -> Self {
|
||||
|
|
@ -202,7 +221,7 @@ pub enum TypedOp<C: Component> {
|
|||
/// Esta lista permite añadir, modificar, renderizar y consultar componentes hijo en orden de
|
||||
/// inserción, soportando operaciones avanzadas como inserción relativa o reemplazo por
|
||||
/// identificador.
|
||||
#[derive(AutoDefault, Clone)]
|
||||
#[derive(AutoDefault, Clone, Debug)]
|
||||
pub struct Children(Vec<Child>);
|
||||
|
||||
impl Children {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue