Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Fix compiler warnings
Erik Kundt committed 2 years ago
commit 668793a2ba0ffed76ca69be94effdfa772478738
parent a814e7d8add6d49cd0bb79fe69d0e3f86d731534
7 files changed +17 -14
modified src/issue/main.rs
@@ -35,6 +35,7 @@ Options
struct Options;

impl Options {
+
    #[allow(clippy::never_loop)]
    fn from_env() -> Result<Self, anyhow::Error> {
        use lexopt::prelude::*;

modified src/patch/main.rs
@@ -35,6 +35,7 @@ Options
struct Options;

impl Options {
+
    #[allow(clippy::never_loop)]
    fn from_env() -> Result<Self, anyhow::Error> {
        use lexopt::prelude::*;

modified src/ui/layout.rs
@@ -42,7 +42,7 @@ pub fn v_stack(
        .constraints(constraints)
        .split(area);

-
    widgets.into_iter().zip(layout.into_iter()).collect()
+
    widgets.into_iter().zip(layout).collect()
}

pub fn h_stack(
@@ -64,7 +64,7 @@ pub fn h_stack(
        .constraints(constraints)
        .split(area);

-
    widgets.into_iter().zip(layout.into_iter()).collect()
+
    widgets.into_iter().zip(layout).collect()
}

pub fn app_header(area: Rect, info_w: u16) -> AppHeader {
modified src/ui/state.rs
@@ -36,9 +36,8 @@ impl ItemState {
    pub fn select_previous(&mut self) -> Option<usize> {
        let old_index = self.selected();
        let new_index = match old_index {
-
            Some(selected) if selected == 0 => Some(0),
+
            Some(0) | None => Some(0),
            Some(selected) => Some(selected.saturating_sub(1)),
-
            None => Some(0),
        };

        if old_index != new_index {
@@ -102,9 +101,8 @@ impl FormState {
    pub fn focus_previous(&mut self) -> Option<usize> {
        let old_index = self.focus();
        let new_index = match old_index {
-
            Some(focus) if focus == 0 => Some(0),
+
            Some(0) | None => Some(0),
            Some(focus) => Some(focus.saturating_sub(1)),
-
            None => Some(0),
        };

        if old_index != new_index {
modified src/ui/widget/context.rs
@@ -132,7 +132,7 @@ pub struct ContextBar {
}

impl ContextBar {
-
    pub const PROP_EDIT_MODE: &str = "edit-mode";
+
    pub const PROP_EDIT_MODE: &'static str = "edit-mode";

    pub fn new(
        theme: Theme,
modified src/ui/widget/form.rs
@@ -182,12 +182,12 @@ pub struct Form {
}

impl Form {
-
    pub const CMD_FOCUS_PREVIOUS: &str = "cmd-focus-previous";
-
    pub const CMD_FOCUS_NEXT: &str = "cmd-focus-next";
-
    pub const CMD_NEWLINE: &str = "cmd-newline";
-
    pub const CMD_PASTE: &str = "cmd-paste";
+
    pub const CMD_FOCUS_PREVIOUS: &'static str = "cmd-focus-previous";
+
    pub const CMD_FOCUS_NEXT: &'static str = "cmd-focus-next";
+
    pub const CMD_NEWLINE: &'static str = "cmd-newline";
+
    pub const CMD_PASTE: &'static str = "cmd-paste";

-
    pub const PROP_ID: &str = "prop-id";
+
    pub const PROP_ID: &'static str = "prop-id";

    pub fn new(_theme: Theme, inputs: Vec<Box<dyn MockComponent>>) -> Self {
        let state = FormState::new(Some(0), inputs.len());
modified src/ui/widget/label.rs
@@ -95,7 +95,7 @@ pub struct Textarea {
}

impl Textarea {
-
    pub const PROP_DISPLAY_PROGRESS: &str = "display-progress";
+
    pub const PROP_DISPLAY_PROGRESS: &'static str = "display-progress";

    pub fn new(theme: Theme) -> Self {
        Self {
@@ -163,7 +163,10 @@ impl WidgetComponent for Textarea {
        self.len = body.len();
        self.height = (layout[0].height - 1) as usize;

-
        let body: String = body.iter().map(|line| format!("{}\n", line)).collect();
+
        let body: String = body.iter().fold(String::new(), |mut body, line| {
+
            body.push_str(&format!("{}\n", line));
+
            body
+
        });

        let paragraph = Paragraph::new(body)
            .scroll((self.offset as u16, 0))