Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Improve props downcasting
Erik Kundt committed 2 years ago
commit 4e69e0ad7408ea4c337bf732e531aaa463c08caa
parent a92e684308f76596cfaeefee956a7c70efd861be
2 files changed +5 -7
modified src/ui/widget/container.rs
@@ -101,7 +101,7 @@ impl<'a: 'static, S, A> View<S, A> for Header<'a, S, A> {

    fn update(&mut self, state: &S) {
        if let Some(on_update) = self.on_update {
-
            if let Some(props) = (on_update)(state).downcast_ref::<HeaderProps<'_>>() {
+
            if let Some(props) = (on_update)(state).downcast_ref::<HeaderProps>() {
                self.props = props.clone();
            }
        }
@@ -264,7 +264,7 @@ impl<'a: 'static, S, A> View<S, A> for Footer<'a, S, A> {

    fn update(&mut self, state: &S) {
        if let Some(on_update) = self.on_update {
-
            if let Some(props) = (on_update)(state).downcast_ref::<FooterProps<'_>>() {
+
            if let Some(props) = (on_update)(state).downcast_ref::<FooterProps>() {
                self.props = props.clone();
            }
        }
@@ -306,9 +306,7 @@ where
    B: Backend,
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: &dyn Any) {
-
        let props = props
-
            .downcast_ref::<FooterProps<'_>>()
-
            .unwrap_or(&self.props);
+
        let props = props.downcast_ref::<FooterProps>().unwrap_or(&self.props);

        let widths = props
            .columns
modified src/ui/widget/text.rs
@@ -167,7 +167,7 @@ impl<'a: 'static, S, A> View<S, A> for Paragraph<'a, S, A> {

    fn update(&mut self, state: &S) {
        if let Some(on_update) = self.on_update {
-
            if let Some(props) = (on_update)(state).downcast_ref::<ParagraphProps<'_>>() {
+
            if let Some(props) = (on_update)(state).downcast_ref::<ParagraphProps>() {
                self.props = props.clone();
            }
        }
@@ -211,7 +211,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: &dyn Any) {
        let props = props
-
            .downcast_ref::<ParagraphProps<'_>>()
+
            .downcast_ref::<ParagraphProps>()
            .unwrap_or(&self.props);

        let block = Block::default()