From 533ec30597eff526d4159d5e2b412416f9d5d752 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 22 Nov 2024 05:29:56 +0100 Subject: [PATCH] small change --- Cargo.toml | 3 ++- src/lib.rs | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c87093a..ae01d54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,5 +22,6 @@ crossterm = "0.28.1" regex = "1.11.1" lazy_static = "1.4" paste = "1.0.15" -osui-element = "0.1.1" +osui-element = "0.1.5" dyn-clone = "1.0.17" +flume = "=0.10.12" diff --git a/src/lib.rs b/src/lib.rs index ece152a..00c65a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ pub use app::run; pub mod prelude { pub use crate::ui::Color::*; pub use crate::{self as osui, css, rsx, rsx_elem, ui::*, Handler}; - pub use crate::{Element, Value, style}; + pub use crate::{style, Element, Value}; // useful for Element making pub use crate::{run_handler, Children, ElementCore, ElementWidget}; pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind}; @@ -93,7 +93,6 @@ pub trait ElementCore: Send + Sync { fn get_element_by_id(&mut self, id: &str) -> Option<&mut Element>; fn get_child(&mut self) -> Option<&mut Element>; fn set_styling(&mut self, styling: &HashMap); - fn type_id(&self) -> std::any::TypeId; } pub trait ElementWidget: ElementCore + std::fmt::Debug { @@ -141,7 +140,7 @@ impl std::fmt::Debug for Handler { ////////////////////////////////////////////////////////////////////////////////////////////////// /// Child enum of an `Element` -/// +/// /// # Example /// ``` /// // Check if it's text @@ -153,7 +152,7 @@ impl std::fmt::Debug for Handler { /// // do something /// } /// ``` -/// +/// /// # Useful for /// - `Element::event` /// - `Element::render` @@ -191,3 +190,8 @@ impl Children { } } } + +/// Converts a `Element` into the struct +pub fn convert(widget: &mut Box) -> &mut Box { + unsafe { &mut *(widget as *mut _ as *mut Box) } +} \ No newline at end of file