Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Improve boxed property conversion
Erik Kundt committed 2 years ago
commit 86811000e8682a72d22e14fb51cb2b31b95cbf14
parent e2346edc6fbc6466af6a78c0f9cd6a4612d1a5fe
4 files changed +7 -7
modified src/ui/widget.rs
@@ -193,7 +193,7 @@ where
        use ratatui::widgets::Table;

        let props = props
-
            .and_then(|props| ShortcutsProps::from_boxed_any(props))
+
            .and_then(ShortcutsProps::from_boxed_any)
            .unwrap_or(self.props.clone());

        let mut shortcuts = props.shortcuts.iter().peekable();
@@ -471,7 +471,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
        let props = props
-
            .and_then(|props| TableProps::<'_, R>::from_boxed_any(props))
+
            .and_then(TableProps::<'_, R>::from_boxed_any)
            .unwrap_or(self.props.clone());

        let widths: Vec<Constraint> = self
modified src/ui/widget/container.rs
@@ -121,7 +121,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
        let props = props
-
            .and_then(|props| HeaderProps::from_boxed_any(props))
+
            .and_then(HeaderProps::from_boxed_any)
            .unwrap_or(self.props.clone());

        let widths: Vec<Constraint> = props
@@ -309,7 +309,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
        let props = props
-
            .and_then(|props| FooterProps::from_boxed_any(props))
+
            .and_then(FooterProps::from_boxed_any)
            .unwrap_or(self.props.clone());

        let widths = props
@@ -465,7 +465,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
        let props = props
-
            .and_then(|props| ContainerProps::from_boxed_any(props))
+
            .and_then(ContainerProps::from_boxed_any)
            .unwrap_or(self.props.clone());

        let header_h = if self.header.is_some() { 3 } else { 0 };
modified src/ui/widget/input.rs
@@ -200,7 +200,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
        let props = props
-
            .and_then(|props| TextFieldProps::from_boxed_any(props))
+
            .and_then(TextFieldProps::from_boxed_any)
            .unwrap_or(self.props.clone());

        let layout = Layout::vertical(Constraint::from_lengths([1, 1])).split(area);
modified src/ui/widget/text.rs
@@ -218,7 +218,7 @@ where
{
    fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
        let props = props
-
            .and_then(|props| ParagraphProps::from_boxed_any(props))
+
            .and_then(ParagraphProps::from_boxed_any)
            .unwrap_or(self.props.clone());

        let [content_area] = Layout::horizontal([Constraint::Min(1)])