mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-16 23:55:42 +02:00
Inline format vars to make the format str simpler (#551)
This commit is contained in:
parent
86d8c4ae54
commit
5cdb73387f
@ -33,7 +33,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
||||
// and nothing else accesses that address range.
|
||||
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();
|
||||
|
||||
loop {
|
||||
if let Some(b) = uart.read_byte() {
|
||||
@ -55,7 +55,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
error!("{}", info);
|
||||
error!("{info}");
|
||||
system_off().unwrap();
|
||||
loop {}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
||||
let uart = unsafe { Uart::new(PL011_BASE_ADDRESS) };
|
||||
logger::init(uart, LevelFilter::Trace).unwrap();
|
||||
|
||||
info!("main({:#x}, {:#x}, {:#x}, {:#x})", x0, x1, x2, x3);
|
||||
info!("main({x0:#x}, {x1:#x}, {x2:#x}, {x3:#x})");
|
||||
|
||||
assert_eq!(x1, 42);
|
||||
|
||||
@ -44,7 +44,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
error!("{}", info);
|
||||
error!("{info}");
|
||||
system_off().unwrap();
|
||||
loop {}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ impl Error for ReadUsernameError {}
|
||||
impl Display for ReadUsernameError {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Self::IoError(e) => write!(f, "IO error: {}", e),
|
||||
Self::EmptyUsername(filename) => write!(f, "Found no username in {}", filename),
|
||||
Self::IoError(e) => write!(f, "IO error: {e}"),
|
||||
Self::EmptyUsername(filename) => write!(f, "Found no username in {filename}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
||||
// and nothing else accesses that address range.
|
||||
let rtc = unsafe { Rtc::new(PL031_BASE_ADDRESS) };
|
||||
let time = Utc.timestamp_opt(rtc.read().into(), 0).unwrap();
|
||||
info!("RTC: {}", time);
|
||||
info!("RTC: {time}");
|
||||
|
||||
// ANCHOR: main_end
|
||||
system_off().unwrap();
|
||||
@ -60,7 +60,7 @@ extern "C" fn main(x0: u64, x1: u64, x2: u64, x3: u64) {
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
error!("{}", info);
|
||||
error!("{info}");
|
||||
system_off().unwrap();
|
||||
loop {}
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ pub fn luhn(cc_number: &str) -> bool {
|
||||
fn main() {
|
||||
let cc_number = "1234 5678 1234 5670";
|
||||
println!(
|
||||
"Is {} a valid credit card number? {}",
|
||||
cc_number,
|
||||
"Is {cc_number} a valid credit card number? {}",
|
||||
if luhn(cc_number) { "yes" } else { "no" }
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user