Skip to content

Commit

Permalink
cargo +nightly fix --edition
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed Nov 27, 2024
1 parent 4b8f41a commit 28b1646
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Event {
/// Return `i`th key event
#[must_use]
pub fn get(&self, i: usize) -> Option<&KeyEvent> {
if let Self::KeySeq(ref ks) = self {
if let &Self::KeySeq(ref ks) = self {
ks.get(i)
} else {
None
Expand Down
8 changes: 4 additions & 4 deletions src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ fn filename_complete(
if let Ok(read_dir) = dir.read_dir() {
let file_name = normalize(file_name);
for entry in read_dir.flatten() {
if let Some(s) = entry.file_name().to_str() {
match entry.file_name().to_str() { Some(s) => {
let ns = normalize(s);
if ns.starts_with(file_name.as_ref()) {
if let Ok(metadata) = fs::metadata(entry.path()) {
match fs::metadata(entry.path()) { Ok(metadata) => {
let mut path = String::from(dir_name) + s;
if metadata.is_dir() {
path.push(sep);
Expand All @@ -346,9 +346,9 @@ fn filename_complete(
display: String::from(s),
replacement: escape(path, esc_char, is_break_char, quote),
});
} // else ignore PermissionDenied
} _ => {}} // else ignore PermissionDenied
}
}
} _ => {}}
}
}
entries
Expand Down
8 changes: 4 additions & 4 deletions src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,25 @@ impl MemHistory {
.skip(self.len() - 1 - start)
.enumerate()
{
if let Some(cursor) = test(entry) {
match test(entry) { Some(cursor) => {
return Some(SearchResult {
idx: start - idx,
entry: Cow::Borrowed(entry),
pos: cursor,
});
}
} _ => {}}
}
None
}
SearchDirection::Forward => {
for (idx, entry) in self.entries.iter().skip(start).enumerate() {
if let Some(cursor) = test(entry) {
match test(entry) { Some(cursor) => {
return Some(SearchResult {
idx: idx + start,
entry: Cow::Borrowed(entry),
pos: cursor,
});
}
} _ => {}}
}
None
}
Expand Down
2 changes: 1 addition & 1 deletion src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ impl InputState<'_> {
) -> Result<Option<Cmd>> {
while let Some(subtrie) = self.custom_bindings.get_raw_descendant(evt) {
let snd_key = rdr.next_key(true)?;
if let Event::KeySeq(ref mut key_seq) = evt {
if let &mut Event::KeySeq(ref mut key_seq) = evt {
key_seq.push(snd_key);
} else {
break;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,13 @@ impl<H: Helper, I: History> Editor<H, I> {
.term
.create_reader(self.buffer.take(), &self.config, term_key_map);
if self.term.is_output_tty() && self.config.check_cursor_position() {
if let Err(e) = s.move_cursor_at_leftmost(&mut rdr) {
match s.move_cursor_at_leftmost(&mut rdr) { Err(e) => {
if let ReadlineError::WindowResized = e {
s.out.update_size();
} else {
return Err(e);
}
}
} _ => {}}
}
s.refresh_line()?;

Expand Down
24 changes: 12 additions & 12 deletions src/tty/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,14 @@ impl PosixRawReader {
} else if readfds.contains(tty_in) {
// prefer user input over external print
return self.next_key(single_esc_abort).map(Event::KeyPress);
} else if let Some(ref pipe_reader) = self.pipe_reader {
} else { match self.pipe_reader { Some(ref pipe_reader) => {
let mut guard = pipe_reader.lock().unwrap();
let mut buf = [0; 1];
guard.0.read_exact(&mut buf)?;
if let Ok(msg) = guard.1.try_recv() {
match guard.1.try_recv() { Ok(msg) => {
return Ok(Event::ExternalPrint(msg));
}
}
} _ => {}}
} _ => {}}}
}
}
}
Expand Down Expand Up @@ -1304,19 +1304,19 @@ impl Term for PosixTerminal {
let (tty_in, is_in_a_tty, tty_out, is_out_a_tty, close_on_drop) =
if behavior == Behavior::PreferTerm {
let tty = OpenOptions::new().read(true).write(true).open("/dev/tty");
if let Ok(tty) = tty {
match tty { Ok(tty) => {
let fd = tty.into_raw_fd();
let is_a_tty = is_a_tty(fd); // TODO: useless ?
(fd, is_a_tty, fd, is_a_tty, true)
} else {
} _ => {
(
libc::STDIN_FILENO,
is_a_tty(libc::STDIN_FILENO),
libc::STDOUT_FILENO,
is_a_tty(libc::STDOUT_FILENO),
false,
)
}
}}
} else {
(
libc::STDIN_FILENO,
Expand Down Expand Up @@ -1494,16 +1494,16 @@ impl super::ExternalPrinter for ExternalPrinter {
// write directly to stdout/stderr while not in raw mode
if !self.raw_mode.load(Ordering::SeqCst) {
write_all(self.tty_out, msg.as_str())?;
} else if let Ok(mut writer) = self.writer.0.lock() {
} else { match self.writer.0.lock() { Ok(mut writer) => {
self.writer
.1
.send(msg)
.map_err(|_| io::Error::from(ErrorKind::Other))?; // FIXME
writer.write_all(b"m")?;
writer.flush()?;
} else {
} _ => {
return Err(io::Error::from(ErrorKind::Other).into()); // FIXME
}
}}}
Ok(())
}
}
Expand Down Expand Up @@ -1655,10 +1655,10 @@ mod test {

#[test]
fn test_unsupported_term() {
std::env::set_var("TERM", "xterm");
unsafe { std::env::set_var("TERM", "xterm") };
assert!(!super::is_unsupported_term());

std::env::set_var("TERM", "dumb");
unsafe { std::env::set_var("TERM", "dumb") };
assert!(super::is_unsupported_term());
}

Expand Down
4 changes: 2 additions & 2 deletions src/undo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ impl Changeset {
pub(crate) fn last_insert(&self) -> Option<String> {
for change in self.undos.iter().rev() {
match change {
Change::Insert { ref text, .. } => return Some(text.clone()),
Change::Replace { ref new, .. } => return Some(new.clone()),
&Change::Insert { ref text, .. } => return Some(text.clone()),
&Change::Replace { ref new, .. } => return Some(new.clone()),
Change::End => {
continue;
}
Expand Down

0 comments on commit 28b1646

Please sign in to comment.