Skip to content

Commit ba4bf6c

Browse files
committed
tidy clippy linting
1 parent f9c067b commit ba4bf6c

File tree

9 files changed

+23
-20
lines changed

9 files changed

+23
-20
lines changed

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.51.0"

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ jobs:
8686
uses: actions-rs/cargo@v1
8787
with:
8888
command: clippy
89-
args: -- -D warnings
9089
- name: Format check
9190
uses: actions-rs/cargo@v1
9291
with:

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//! * Other kind of prompts
1919
//! * Editor launching
2020
21+
#![deny(clippy::all)]
22+
2123
#[cfg(feature = "completion")]
2224
pub use completion::Completion;
2325
pub use console;

src/paging.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ impl<'a> Paging<'a> {
5959
self.pages = (self.items_len as f64 / self.capacity as f64).ceil() as usize;
6060
}
6161

62-
if self.active != (self.pages > 1) {
62+
if self.active == (self.pages > 1) {
63+
self.activity_transition = false;
64+
} else {
6365
self.active = self.pages > 1;
6466
self.activity_transition = true;
6567
// Clear everything to prevent "ghost" lines in terminal when a resize happened
6668
self.term.clear_last_lines(self.capacity)?;
67-
} else {
68-
self.activity_transition = false;
6969
}
7070

7171
if cursor_pos != !0

src/prompts/confirm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ impl Confirm<'_> {
9898
///
9999
/// The dialog is rendered on stderr.
100100
///
101-
/// Result contains `bool` if user answered "yes" or "no" or `default` (configured in [default](#method.default)) if pushes enter.
102-
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
101+
/// Result contains `bool` if user answered "yes" or "no" or `default` (configured in [`default`](Self::default) if pushes enter.
102+
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
103103
#[inline]
104104
pub fn interact(&self) -> io::Result<bool> {
105105
self.interact_on(&Term::stderr())
@@ -109,7 +109,7 @@ impl Confirm<'_> {
109109
///
110110
/// The dialog is rendered on stderr.
111111
///
112-
/// Result contains `Some(bool)` if user answered "yes" or "no" or `Some(default)` (configured in [default](#method.default)) if pushes enter,
112+
/// Result contains `Some(bool)` if user answered "yes" or "no" or `Some(default)` (configured in [`default`](Self::default)) if pushes enter,
113113
/// or `None` if user cancelled with 'Esc' or 'q'.
114114
#[inline]
115115
pub fn interact_opt(&self) -> io::Result<Option<bool>> {
@@ -137,7 +137,7 @@ impl Confirm<'_> {
137137
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
138138
}
139139

140-
/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
140+
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
141141
///
142142
/// ## Examples
143143
/// ```rust,no_run

src/prompts/multi_select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl MultiSelect<'_> {
5858
self.defaults = val
5959
.to_vec()
6060
.iter()
61-
.cloned()
61+
.copied()
6262
.chain(repeat(false))
6363
.take(self.items.len())
6464
.collect();
@@ -130,7 +130,7 @@ impl MultiSelect<'_> {
130130
/// The user can select the items with the 'Space' bar and on 'Enter' the indices of selected items will be returned.
131131
/// The dialog is rendered on stderr.
132132
/// Result contains `Vec<index>` if user hit 'Enter'.
133-
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
133+
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
134134
#[inline]
135135
pub fn interact(&self) -> io::Result<Vec<usize>> {
136136
self.interact_on(&Term::stderr())
@@ -170,7 +170,7 @@ impl MultiSelect<'_> {
170170
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
171171
}
172172

173-
/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
173+
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
174174
///
175175
/// ## Examples
176176
/// ```rust,no_run

src/prompts/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl Select<'_> {
167167
/// The user can select the items with the 'Space' bar or 'Enter' and the index of selected item will be returned.
168168
/// The dialog is rendered on stderr.
169169
/// Result contains `index` if user selected one of items using 'Enter'.
170-
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
170+
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
171171
#[inline]
172172
pub fn interact(&self) -> io::Result<usize> {
173173
self.interact_on(&Term::stderr())
@@ -207,7 +207,7 @@ impl Select<'_> {
207207
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
208208
}
209209

210-
/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
210+
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
211211
///
212212
/// ## Examples
213213
/// ```rust,no_run

src/prompts/sort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Sort<'_> {
102102
/// The user can order the items with the 'Space' bar and the arrows. On 'Enter' ordered list of the incides of items will be returned.
103103
/// The dialog is rendered on stderr.
104104
/// Result contains `Vec<index>` if user hit 'Enter'.
105-
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
105+
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
106106
#[inline]
107107
pub fn interact(&self) -> io::Result<Vec<usize>> {
108108
self.interact_on(&Term::stderr())
@@ -142,7 +142,7 @@ impl Sort<'_> {
142142
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
143143
}
144144

145-
/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
145+
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
146146
///
147147
/// ## Examples
148148
/// ```rust,no_run

src/theme.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,16 @@ impl Theme for ColorfulTheme {
506506
text: &str,
507507
active: bool,
508508
) -> fmt::Result {
509-
let details = match active {
510-
true => (
509+
let details = if active {
510+
(
511511
&self.active_item_prefix,
512512
self.active_item_style.apply_to(text),
513-
),
514-
false => (
513+
)
514+
} else {
515+
(
515516
&self.inactive_item_prefix,
516517
self.inactive_item_style.apply_to(text),
517-
),
518+
)
518519
};
519520

520521
write!(f, "{} {}", details.0, details.1)

0 commit comments

Comments
 (0)