Skip to content

Commit 29333b3

Browse files
committed
dprint fmt
1 parent b9641a7 commit 29333b3

File tree

21 files changed

+26
-54
lines changed

21 files changed

+26
-54
lines changed

src/android/interoperability/java/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// ANCHOR: hello
1616
//! Rust <-> Java FFI demo.
1717
18+
use jni::JNIEnv;
1819
use jni::objects::{JClass, JString};
1920
use jni::sys::jstring;
20-
use jni::JNIEnv;
2121

2222
/// HelloWorld::hello method implementation.
2323
// SAFETY: There is no other global function of this name.

src/bare-metal/aps/examples/src/exceptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
// ANCHOR: exceptions
1616
use log::error;
17-
use smccc::psci::system_off;
1817
use smccc::Hvc;
18+
use smccc::psci::system_off;
1919

2020
// SAFETY: There is no other global function of this name.
2121
#[unsafe(no_mangle)]

src/bare-metal/aps/examples/src/main_improved.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use crate::pl011::Uart;
2323
use core::fmt::Write;
2424
use core::panic::PanicInfo;
2525
use log::error;
26-
use smccc::psci::system_off;
2726
use smccc::Hvc;
27+
use smccc::psci::system_off;
2828

2929
/// Base address of the primary PL011 UART.
3030
const PL011_BASE_ADDRESS: *mut u32 = 0x900_0000 as _;

src/bare-metal/aps/examples/src/main_logger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ mod pl011;
2222

2323
use crate::pl011::Uart;
2424
use core::panic::PanicInfo;
25-
use log::{error, info, LevelFilter};
26-
use smccc::psci::system_off;
25+
use log::{LevelFilter, error, info};
2726
use smccc::Hvc;
27+
use smccc::psci::system_off;
2828

2929
/// Base address of the primary PL011 UART.
3030
const PL011_BASE_ADDRESS: *mut u32 = 0x900_0000 as _;

src/bare-metal/aps/examples/src/main_minimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use crate::pl011_minimal::Uart;
2323
use core::fmt::Write;
2424
use core::panic::PanicInfo;
2525
use log::error;
26-
use smccc::psci::system_off;
2726
use smccc::Hvc;
27+
use smccc::psci::system_off;
2828

2929
/// Base address of the primary PL011 UART.
3030
const PL011_BASE_ADDRESS: *mut u8 = 0x900_0000 as _;

src/bare-metal/microcontrollers/examples/src/bin/hal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern crate panic_halt as _;
2020

2121
use cortex_m_rt::entry;
2222
use embedded_hal::digital::OutputPin;
23-
use nrf52833_hal::gpio::{p0, Level};
23+
use nrf52833_hal::gpio::{Level, p0};
2424
use nrf52833_hal::pac::Peripherals;
2525

2626
#[entry]

src/bare-metal/useful-crates/tinyvec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ many elements are used and panics if you try to use more than are allocated.
88
<!-- mdbook-xgettext: skip -->
99

1010
```rust,editable,compile_fail
11-
use tinyvec::{array_vec, ArrayVec};
11+
use tinyvec::{ArrayVec, array_vec};
1212
1313
fn main() {
1414
let mut numbers: ArrayVec<[u32; 5]> = array_vec!(42, 66);

src/closures/capturing.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ A closure can capture variables from the environment where it was defined.
1010
fn main() {
1111
let max_value = 5;
1212
let clamp = |v| {
13-
if v > max_value {
14-
max_value
15-
} else {
16-
v
17-
}
13+
if v > max_value { max_value } else { v }
1814
};
1915
2016
dbg!(clamp(1));

src/concurrency/async-control-flow/select.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ the resulting variables. The `statement` result becomes the result of the
1717

1818
```rust,editable,compile_fail
1919
use tokio::sync::mpsc;
20-
use tokio::time::{sleep, Duration};
20+
use tokio::time::{Duration, sleep};
2121
2222
#[tokio::main]
2323
async fn main() {

src/concurrency/async-exercises/dining-philosophers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// ANCHOR: solution
1616
// ANCHOR: Philosopher
1717
use std::sync::Arc;
18-
use tokio::sync::{mpsc, Mutex};
18+
use tokio::sync::{Mutex, mpsc};
1919
use tokio::time;
2020

2121
struct Chopstick;

src/concurrency/async-pitfalls/async-traits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ with some caveats:
2222
```rust,editable,compile_fail
2323
use async_trait::async_trait;
2424
use std::time::Instant;
25-
use tokio::time::{sleep, Duration};
25+
use tokio::time::{Duration, sleep};
2626
2727
#[async_trait]
2828
trait Sleeper {

src/concurrency/async-pitfalls/pin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ location.
2020
```rust,editable,compile_fail
2121
use tokio::sync::{mpsc, oneshot};
2222
use tokio::task::spawn;
23-
use tokio::time::{sleep, Duration};
23+
use tokio::time::{Duration, sleep};
2424
2525
// A work item. In this case, just sleep for the given time and respond
2626
// with a message on the `respond_on` channel.

src/control-flow-basics/functions.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ minutes: 3
88

99
```rust,editable
1010
fn gcd(a: u32, b: u32) -> u32 {
11-
if b > 0 {
12-
gcd(b, a % b)
13-
} else {
14-
a
15-
}
11+
if b > 0 { gcd(b, a % b) } else { a }
1612
}
1713
1814
fn main() {

src/error-handling/anyhow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ writing out trait impls explicitly for custom error types.
1515
[`thiserror`]: https://docs.rs/thiserror/
1616

1717
```rust,editable,compile_fail
18-
use anyhow::{bail, Context, Result};
18+
use anyhow::{Context, Result, bail};
1919
use std::fs;
2020
use std::io::Read;
2121
use thiserror::Error;

src/exercises/bare-metal/compass/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ use embedded_hal::digital::InputPin;
2626
use lsm303agr::{
2727
AccelMode, AccelOutputDataRate, Lsm303agr, MagMode, MagOutputDataRate,
2828
};
29+
use microbit::Board;
2930
use microbit::display::blocking::Display;
3031
use microbit::hal::twim::Twim;
3132
use microbit::hal::uarte::{Baudrate, Parity, Uarte};
3233
use microbit::hal::{Delay, Timer};
3334
use microbit::pac::twim0::frequency::FREQUENCY_A;
34-
use microbit::Board;
3535

3636
const COMPASS_SCALE: i32 = 30000;
3737
const ACCELEROMETER_SCALE: i32 = 700;

src/exercises/bare-metal/rtc/src/exceptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
use arm_gic::gicv3::GicV3;
1616
use log::{error, info, trace};
17-
use smccc::psci::system_off;
1817
use smccc::Hvc;
18+
use smccc::psci::system_off;
1919

2020
// SAFETY: There is no other global function of this name.
2121
#[unsafe(no_mangle)]

src/exercises/bare-metal/rtc/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ mod pl011;
2424
mod pl031;
2525

2626
use crate::pl031::Rtc;
27-
use arm_gic::{irq_enable, wfi, IntId, Trigger};
27+
use arm_gic::{IntId, Trigger, irq_enable, wfi};
2828
use chrono::{TimeZone, Utc};
2929
use core::hint::spin_loop;
3030
// ANCHOR: imports
3131
use crate::pl011::Uart;
3232
use arm_gic::gicv3::GicV3;
3333
use core::panic::PanicInfo;
34-
use log::{error, info, trace, LevelFilter};
35-
use smccc::psci::system_off;
34+
use log::{LevelFilter, error, info, trace};
3635
use smccc::Hvc;
36+
use smccc::psci::system_off;
3737

3838
/// Base addresses of the GICv3.
3939
const GICD_BASE_ADDRESS: *mut u64 = 0x800_0000 as _;

src/generics/generic-functions.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ Rust supports generics, which lets you abstract algorithms or data structures
99

1010
```rust,editable
1111
fn pick<T>(cond: bool, left: T, right: T) -> T {
12-
if cond {
13-
left
14-
} else {
15-
right
16-
}
12+
if cond { left } else { right }
1713
}
1814
1915
fn main() {
@@ -31,19 +27,11 @@ fn main() {
3127

3228
```rust
3329
fn pick_i32(cond: bool, left: i32, right: i32) -> i32 {
34-
if cond {
35-
left
36-
} else {
37-
right
38-
}
30+
if cond { left } else { right }
3931
}
4032

4133
fn pick_char(cond: bool, left: char, right: char) -> char {
42-
if cond {
43-
left
44-
} else {
45-
right
46-
}
34+
if cond { left } else { right }
4735
}
4836
```
4937

src/lifetimes/lifetime-annotations.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ job.
2929
struct Point(i32, i32);
3030
3131
fn left_most(p1: &Point, p2: &Point) -> &Point {
32-
if p1.0 < p2.0 {
33-
p1
34-
} else {
35-
p2
36-
}
32+
if p1.0 < p2.0 { p1 } else { p2 }
3733
}
3834
3935
fn main() {

src/user-defined-types/const.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ const DIGEST_SIZE: usize = 3;
1414
const FILL_VALUE: u8 = calculate_fill_value();
1515
1616
const fn calculate_fill_value() -> u8 {
17-
if DIGEST_SIZE < 10 {
18-
42
19-
} else {
20-
13
21-
}
17+
if DIGEST_SIZE < 10 { 42 } else { 13 }
2218
}
2319
2420
fn compute_digest(text: &str) -> [u8; DIGEST_SIZE] {

xtask/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! `cargo xtask install-tools` and the logic defined here will install
2020
//! the tools.
2121
22-
use anyhow::{anyhow, Ok, Result};
22+
use anyhow::{Ok, Result, anyhow};
2323
use clap::Parser;
2424
use std::env;
2525
use std::process::Command;

0 commit comments

Comments
 (0)