Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12b1f44

Browse files
committed
Apply fixes from clippy 1.88
1 parent 863e217 commit 12b1f44

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

examples/keyboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() -> io::Result<()> {
1212
} else {
1313
term.read_key()
1414
}?;
15-
term.write_line(&format!("You pressed {:?}", key))?;
15+
term.write_line(&format!("You pressed {key:?}"))?;
1616
if key == Key::Escape {
1717
break;
1818
}

examples/term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn do_stuff() -> io::Result<()> {
2323

2424
write!(&term, "To edit: ")?;
2525
let res = term.read_line_initial_text("default")?;
26-
writeln!(&term, "\n{}", res)?;
26+
writeln!(&term, "\n{res}")?;
2727

2828
Ok(())
2929
}

src/common_term.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ use crate::term::Term;
44

55
pub(crate) fn move_cursor_down(out: &Term, n: usize) -> io::Result<()> {
66
if n > 0 {
7-
out.write_str(&format!("\x1b[{}B", n))
7+
out.write_str(&format!("\x1b[{n}B"))
88
} else {
99
Ok(())
1010
}
1111
}
1212

1313
pub(crate) fn move_cursor_up(out: &Term, n: usize) -> io::Result<()> {
1414
if n > 0 {
15-
out.write_str(&format!("\x1b[{}A", n))
15+
out.write_str(&format!("\x1b[{n}A"))
1616
} else {
1717
Ok(())
1818
}
1919
}
2020
pub(crate) fn move_cursor_left(out: &Term, n: usize) -> io::Result<()> {
2121
if n > 0 {
22-
out.write_str(&format!("\x1b[{}D", n))
22+
out.write_str(&format!("\x1b[{n}D"))
2323
} else {
2424
Ok(())
2525
}
2626
}
2727

2828
pub(crate) fn move_cursor_right(out: &Term, n: usize) -> io::Result<()> {
2929
if n > 0 {
30-
out.write_str(&format!("\x1b[{}C", n))
30+
out.write_str(&format!("\x1b[{n}C"))
3131
} else {
3232
Ok(())
3333
}
@@ -40,7 +40,7 @@ pub(crate) fn move_cursor_to(out: &Term, x: usize, y: usize) -> io::Result<()> {
4040

4141
pub(crate) fn clear_chars(out: &Term, n: usize) -> io::Result<()> {
4242
if n > 0 {
43-
out.write_str(&format!("\x1b[{}D\x1b[0K", n))
43+
out.write_str(&format!("\x1b[{n}D\x1b[0K"))
4444
} else {
4545
Ok(())
4646
}

src/term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl Term {
351351
slf.flush()?;
352352
}
353353
Key::Enter => {
354-
slf.write_through(format!("\n{}", initial).as_bytes())?;
354+
slf.write_through(format!("\n{initial}").as_bytes())?;
355355
break;
356356
}
357357
_ => (),

src/unix_term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,5 +390,5 @@ pub(crate) fn wants_emoji() -> bool {
390390
}
391391

392392
pub(crate) fn set_title<T: Display>(title: T) {
393-
print!("\x1b]0;{}\x07", title);
393+
print!("\x1b]0;{title}\x07");
394394
}

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ fn test_attributes_single() {
10681068
let attrs = Attributes::new().insert(attr);
10691069
assert_eq!(attrs.bits().collect::<Vec<_>>(), [attr as u16]);
10701070
assert_eq!(attrs.attrs().collect::<Vec<_>>(), [attr]);
1071-
assert_eq!(format!("{:?}", attrs), format!("{{{:?}}}", attr));
1071+
assert_eq!(format!("{attrs:?}"), format!("{{{:?}}}", attr));
10721072
}
10731073
}
10741074

src/windows_term/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@ pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
469469
// (This error is given when reading a non-UTF8 file into a String, for example.)
470470
Err(e) => {
471471
let message = format!(
472-
"Read invalid surrogate pair ({}, {}): {}",
473-
unicode_char, next_surrogate, e
472+
"Read invalid surrogate pair ({unicode_char}, {next_surrogate}): {e}",
474473
);
475474
Err(io::Error::new(io::ErrorKind::InvalidData, message))
476475
}
@@ -480,7 +479,7 @@ pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
480479
// Return an InvalidData error. This is the recommended value for UTF-related I/O errors.
481480
// (This error is given when reading a non-UTF8 file into a String, for example.)
482481
Err(e) => {
483-
let message = format!("Read invalid utf16 {}: {}", unicode_char, e);
482+
let message = format!("Read invalid utf16 {unicode_char}: {e}");
484483
Err(io::Error::new(io::ErrorKind::InvalidData, message))
485484
}
486485
}
@@ -615,7 +614,7 @@ pub(crate) fn msys_tty_on(term: &Term) -> bool {
615614
}
616615

617616
pub(crate) fn set_title<T: Display>(title: T) {
618-
let buffer: Vec<u16> = OsStr::new(&format!("{}", title))
617+
let buffer: Vec<u16> = OsStr::new(&format!("{title}"))
619618
.encode_wide()
620619
.chain(once(0))
621620
.collect();

0 commit comments

Comments
 (0)