1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-13 22:26:34 +02:00

Consistently inline formatting arguments (#2413)

This commit is contained in:
Martin Geisler 2024-10-21 14:01:21 -04:00 committed by GitHub
parent ce56ea551e
commit 8bfff0d95a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 12 additions and 12 deletions

View File

@ -35,7 +35,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
// nothing else accesses that address range. // nothing else accesses that address range.
let mut uart = unsafe { Uart::new(PL011_BASE_ADDRESS) }; let mut uart = unsafe { Uart::new(PL011_BASE_ADDRESS) };
writeln!(uart, "main({:#x}, {:#x}, {:#x}, {:#x})", x0, x1, x2, x3).unwrap(); writeln!(uart, "main({x0:#x}, {x1:#x}, {x2:#x}, {x3:#x})").unwrap();
system_off::<Hvc>().unwrap(); system_off::<Hvc>().unwrap();
} }

View File

@ -31,7 +31,7 @@ async fn main() {
let results = future::join_all(futures_iter).await; let results = future::join_all(futures_iter).await;
let page_sizes_dict: HashMap<&str, Result<usize>> = let page_sizes_dict: HashMap<&str, Result<usize>> =
urls.into_iter().zip(results.into_iter()).collect(); urls.into_iter().zip(results.into_iter()).collect();
println!("{:?}", page_sizes_dict); println!("{page_sizes_dict:?}");
} }
``` ```

View File

@ -20,7 +20,7 @@ fn main() {
let mut p2 = p1.clone(); // Clone trait adds `clone` method. let mut p2 = p1.clone(); // Clone trait adds `clone` method.
p2.name = String::from("EldurScrollz"); p2.name = String::from("EldurScrollz");
// Debug trait adds support for printing with `{:?}`. // Debug trait adds support for printing with `{:?}`.
println!("{:?} vs. {:?}", p1, p2); println!("{p1:?} vs. {p2:?}");
} }
``` ```

View File

@ -130,6 +130,6 @@ fn main() {
left: Box::new(Expression::Value(20)), left: Box::new(Expression::Value(20)),
right: Box::new(Expression::Value(10)), right: Box::new(Expression::Value(10)),
}; };
println!("expr: {:?}", expr); println!("expr: {expr:?}");
println!("result: {:?}", eval(expr)); println!("result: {:?}", eval(expr));
} }

View File

@ -21,9 +21,9 @@ lets you execute different code depending on whether a value matches a pattern:
use std::time::Duration; use std::time::Duration;
fn sleep_for(secs: f32) { fn sleep_for(secs: f32) {
if let Ok(dur) = Duration::try_from_secs_f32(secs) { if let Ok(duration) = Duration::try_from_secs_f32(secs) {
std::thread::sleep(dur); std::thread::sleep(duration);
println!("slept for {:?}", dur); println!("slept for {duration:?}");
} }
} }

View File

@ -24,7 +24,7 @@ impl std::ops::Add for Point {
fn main() { fn main() {
let p1 = Point { x: 10, y: 20 }; let p1 = Point { x: 10, y: 20 };
let p2 = Point { x: 100, y: 200 }; let p2 = Point { x: 100, y: 200 };
println!("{:?} + {:?} = {:?}", p1, p2, p1 + p2); println!("{p1:?} + {p2:?} = {:?}", p1 + p2);
} }
``` ```

View File

@ -38,7 +38,7 @@ fn main() -> Result<()> {
let mut buffer = Vec::new(); let mut buffer = Vec::new();
log(&mut buffer, "Hello")?; log(&mut buffer, "Hello")?;
log(&mut buffer, "World")?; log(&mut buffer, "World")?;
println!("Logged: {:?}", buffer); println!("Logged: {buffer:?}");
Ok(()) Ok(())
} }
``` ```

View File

@ -91,7 +91,7 @@ impl DirectoryIterator {
// SAFETY: path.as_ptr() cannot be NULL. // SAFETY: path.as_ptr() cannot be NULL.
let dir = unsafe { ffi::opendir(path.as_ptr()) }; let dir = unsafe { ffi::opendir(path.as_ptr()) };
if dir.is_null() { if dir.is_null() {
Err(format!("Could not open {:?}", path)) Err(format!("Could not open {path:?}"))
} else { } else {
Ok(DirectoryIterator { path, dir }) Ok(DirectoryIterator { path, dir })
} }

View File

@ -22,8 +22,8 @@ enum PlayerMove {
} }
fn main() { fn main() {
let m: PlayerMove = PlayerMove::Run(Direction::Left); let player_move: PlayerMove = PlayerMove::Run(Direction::Left);
println!("On this turn: {:?}", m); println!("On this turn: {player_move:?}");
} }
``` ```