Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #827

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rustyline-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn get_field_by_attr<'a>(data: &'a Data, ident: &str) -> Option<(usize, &'a Fiel
attr.path().is_ident("rustyline")
&& attr
.parse_args::<Path>()
.map_or(false, |arg| arg.is_ident(ident))
.is_ok_and(|arg| arg.is_ident(ident))
})
});

Expand Down
2 changes: 1 addition & 1 deletion src/tty/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ impl PosixRawReader {
continue;
}
};
if sigwinch_pipe.map_or(false, |fd| readfds.contains(fd)) {
if sigwinch_pipe.is_some_and(|fd| readfds.contains(fd)) {
self.tty_in.get_ref().sigwinch()?;
return Err(ReadlineError::WindowResized);
} else if readfds.contains(tty_in) {
Expand Down
13 changes: 7 additions & 6 deletions src/undo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Changeset {
pub(crate) fn insert(&mut self, idx: usize, c: char) {
debug!(target: "rustyline", "Changeset::insert({}, {:?})", idx, c);
self.redos.clear();
if !c.is_alphanumeric() || !self.undos.last().map_or(false, |lc| lc.insert_seq(idx)) {
if !c.is_alphanumeric() || !self.undos.last().is_some_and(|lc| lc.insert_seq(idx)) {
self.undos.push(Self::insert_char(idx, c));
return;
}
Expand Down Expand Up @@ -188,7 +188,7 @@ impl Changeset {
|| !self
.undos
.last()
.map_or(false, |lc| lc.delete_seq(indx, string.as_ref().len()))
.is_some_and(|lc| lc.delete_seq(indx, string.as_ref().len()))
{
self.undos.push(Change::Delete {
idx: indx,
Expand Down Expand Up @@ -217,9 +217,10 @@ impl Changeset {

fn single_char(s: &str) -> bool {
let mut graphemes = s.graphemes(true);
graphemes.next().map_or(false, |grapheme| {
grapheme.chars().all(char::is_alphanumeric)
}) && graphemes.next().is_none()
graphemes
.next()
.is_some_and(|grapheme| grapheme.chars().all(char::is_alphanumeric))
&& graphemes.next().is_none()
}

pub(crate) fn replace<S: AsRef<str> + Into<String> + Debug>(
Expand All @@ -231,7 +232,7 @@ impl Changeset {
debug!(target: "rustyline", "Changeset::replace({}, {:?}, {:?})", indx, old_, new_);
self.redos.clear();

if !self.undos.last().map_or(false, |lc| lc.replace_seq(indx)) {
if !self.undos.last().is_some_and(|lc| lc.replace_seq(indx)) {
self.undos.push(Change::Replace {
idx: indx,
old: old_.into(),
Expand Down