Skip to content

Commit

Permalink
Merge pull request #827 from gwenn/clippy
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
gwenn authored Nov 23, 2024
2 parents bc06b3e + 2c048ee commit 4b8f41a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
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

0 comments on commit 4b8f41a

Please sign in to comment.