Skip to content

Commit

Permalink
tidy clippy linting
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Dec 5, 2021
1 parent f9c067b commit 8d6db24
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions .clippy.toml
@@ -0,0 +1 @@
msrv = "1.51.0"
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -86,7 +86,6 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Format check
uses: actions-rs/cargo@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -18,6 +18,9 @@
//! * Other kind of prompts
//! * Editor launching

#![deny(clippy::all)]
#![warn(clippy::pedantic)]

#[cfg(feature = "completion")]
pub use completion::Completion;
pub use console;
Expand Down
6 changes: 3 additions & 3 deletions src/paging.rs
Expand Up @@ -59,13 +59,13 @@ impl<'a> Paging<'a> {
self.pages = (self.items_len as f64 / self.capacity as f64).ceil() as usize;
}

if self.active != (self.pages > 1) {
if self.active == (self.pages > 1) {
self.activity_transition = false;
} else {
self.active = self.pages > 1;
self.activity_transition = true;
// Clear everything to prevent "ghost" lines in terminal when a resize happened
self.term.clear_last_lines(self.capacity)?;
} else {
self.activity_transition = false;
}

if cursor_pos != !0
Expand Down
8 changes: 4 additions & 4 deletions src/prompts/confirm.rs
Expand Up @@ -98,8 +98,8 @@ impl Confirm<'_> {
///
/// The dialog is rendered on stderr.
///
/// Result contains `bool` if user answered "yes" or "no" or `default` (configured in [default](#method.default)) if pushes enter.
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
/// Result contains `bool` if user answered "yes" or "no" or `default` (configured in [`default`](Confirm::default) if pushes enter.
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
#[inline]
pub fn interact(&self) -> io::Result<bool> {
self.interact_on(&Term::stderr())
Expand All @@ -109,7 +109,7 @@ impl Confirm<'_> {
///
/// The dialog is rendered on stderr.
///
/// Result contains `Some(bool)` if user answered "yes" or "no" or `Some(default)` (configured in [default](#method.default)) if pushes enter,
/// Result contains `Some(bool)` if user answered "yes" or "no" or `Some(default)` (configured in [`default`](Confirm::default)) if pushes enter,
/// or `None` if user cancelled with 'Esc' or 'q'.
#[inline]
pub fn interact_opt(&self) -> io::Result<Option<bool>> {
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Confirm<'_> {
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
}

/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
///
/// ## Examples
/// ```rust,no_run
Expand Down
6 changes: 3 additions & 3 deletions src/prompts/multi_select.rs
Expand Up @@ -58,7 +58,7 @@ impl MultiSelect<'_> {
self.defaults = val
.to_vec()
.iter()
.cloned()
.copied()
.chain(repeat(false))
.take(self.items.len())
.collect();
Expand Down Expand Up @@ -130,7 +130,7 @@ impl MultiSelect<'_> {
/// The user can select the items with the 'Space' bar and on 'Enter' the indices of selected items will be returned.
/// The dialog is rendered on stderr.
/// Result contains `Vec<index>` if user hit 'Enter'.
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
#[inline]
pub fn interact(&self) -> io::Result<Vec<usize>> {
self.interact_on(&Term::stderr())
Expand Down Expand Up @@ -170,7 +170,7 @@ impl MultiSelect<'_> {
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
}

/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
///
/// ## Examples
/// ```rust,no_run
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/select.rs
Expand Up @@ -167,7 +167,7 @@ impl Select<'_> {
/// The user can select the items with the 'Space' bar or 'Enter' and the index of selected item will be returned.
/// The dialog is rendered on stderr.
/// Result contains `index` if user selected one of items using 'Enter'.
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
#[inline]
pub fn interact(&self) -> io::Result<usize> {
self.interact_on(&Term::stderr())
Expand Down Expand Up @@ -207,7 +207,7 @@ impl Select<'_> {
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
}

/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
///
/// ## Examples
/// ```rust,no_run
Expand Down
4 changes: 2 additions & 2 deletions src/prompts/sort.rs
Expand Up @@ -102,7 +102,7 @@ impl Sort<'_> {
/// 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.
/// The dialog is rendered on stderr.
/// Result contains `Vec<index>` if user hit 'Enter'.
/// This unlike [interact_opt](#method.interact_opt) does not allow to quit with 'Esc' or 'q'.
/// This unlike [`interact_opt`](Self::interact_opt) does not allow to quit with 'Esc' or 'q'.
#[inline]
pub fn interact(&self) -> io::Result<Vec<usize>> {
self.interact_on(&Term::stderr())
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Sort<'_> {
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Quit not allowed in this case"))
}

/// Like [interact_opt](#method.interact_opt) but allows a specific terminal to be set.
/// Like [`interact_opt`](Self::interact_opt) but allows a specific terminal to be set.
///
/// ## Examples
/// ```rust,no_run
Expand Down
11 changes: 6 additions & 5 deletions src/theme.rs
Expand Up @@ -506,15 +506,16 @@ impl Theme for ColorfulTheme {
text: &str,
active: bool,
) -> fmt::Result {
let details = match active {
true => (
let details = if active {
(
&self.active_item_prefix,
self.active_item_style.apply_to(text),
),
false => (
)
} else {
(
&self.inactive_item_prefix,
self.inactive_item_style.apply_to(text),
),
)
};

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

0 comments on commit 8d6db24

Please sign in to comment.