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

Skip to content
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 examples/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() -> io::Result<()> {
} else {
term.read_key()
}?;
term.write_line(&format!("You pressed {:?}", key))?;
term.write_line(&format!("You pressed {key:?}"))?;
if key == Key::Escape {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn do_stuff() -> io::Result<()> {

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

Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/common_term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ use crate::term::Term;

pub(crate) fn move_cursor_down(out: &Term, n: usize) -> io::Result<()> {
if n > 0 {
out.write_str(&format!("\x1b[{}B", n))
out.write_str(&format!("\x1b[{n}B"))
} else {
Ok(())
}
}

pub(crate) fn move_cursor_up(out: &Term, n: usize) -> io::Result<()> {
if n > 0 {
out.write_str(&format!("\x1b[{}A", n))
out.write_str(&format!("\x1b[{n}A"))
} else {
Ok(())
}
}
pub(crate) fn move_cursor_left(out: &Term, n: usize) -> io::Result<()> {
if n > 0 {
out.write_str(&format!("\x1b[{}D", n))
out.write_str(&format!("\x1b[{n}D"))
} else {
Ok(())
}
}

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

pub(crate) fn clear_chars(out: &Term, n: usize) -> io::Result<()> {
if n > 0 {
out.write_str(&format!("\x1b[{}D\x1b[0K", n))
out.write_str(&format!("\x1b[{n}D\x1b[0K"))
} else {
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl Term {
slf.flush()?;
}
Key::Enter => {
slf.write_through(format!("\n{}", initial).as_bytes())?;
slf.write_through(format!("\n{initial}").as_bytes())?;
break;
}
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion src/unix_term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,5 +390,5 @@ pub(crate) fn wants_emoji() -> bool {
}

pub(crate) fn set_title<T: Display>(title: T) {
print!("\x1b]0;{}\x07", title);
print!("\x1b]0;{title}\x07");
}
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ fn test_attributes_single() {
let attrs = Attributes::new().insert(attr);
assert_eq!(attrs.bits().collect::<Vec<_>>(), [attr as u16]);
assert_eq!(attrs.attrs().collect::<Vec<_>>(), [attr]);
assert_eq!(format!("{:?}", attrs), format!("{{{:?}}}", attr));
assert_eq!(format!("{attrs:?}"), format!("{{{:?}}}", attr));
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/windows_term/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
// (This error is given when reading a non-UTF8 file into a String, for example.)
Err(e) => {
let message = format!(
"Read invalid surrogate pair ({}, {}): {}",
unicode_char, next_surrogate, e
"Read invalid surrogate pair ({unicode_char}, {next_surrogate}): {e}",
);
Err(io::Error::new(io::ErrorKind::InvalidData, message))
}
Expand All @@ -480,7 +479,7 @@ pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
// Return an InvalidData error. This is the recommended value for UTF-related I/O errors.
// (This error is given when reading a non-UTF8 file into a String, for example.)
Err(e) => {
let message = format!("Read invalid utf16 {}: {}", unicode_char, e);
let message = format!("Read invalid utf16 {unicode_char}: {e}");
Err(io::Error::new(io::ErrorKind::InvalidData, message))
}
}
Expand Down Expand Up @@ -615,7 +614,7 @@ pub(crate) fn msys_tty_on(term: &Term) -> bool {
}

pub(crate) fn set_title<T: Display>(title: T) {
let buffer: Vec<u16> = OsStr::new(&format!("{}", title))
let buffer: Vec<u16> = OsStr::new(&format!("{title}"))
.encode_wide()
.chain(once(0))
.collect();
Expand Down
Loading