mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-10-30 08:20:52 +08:00
lib: Fix compiler warnings
This commit is contained in:
@@ -35,6 +35,7 @@ Options
|
||||
struct Options;
|
||||
|
||||
impl Options {
|
||||
#[allow(clippy::never_loop)]
|
||||
fn from_env() -> Result<Self, anyhow::Error> {
|
||||
use lexopt::prelude::*;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ Options
|
||||
struct Options;
|
||||
|
||||
impl Options {
|
||||
#[allow(clippy::never_loop)]
|
||||
fn from_env() -> Result<Self, anyhow::Error> {
|
||||
use lexopt::prelude::*;
|
||||
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
+2
-4
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user