Skip to content

Commit 2f7f3c8

Browse files
authored
Refactor format!("{}", arg) -> format!("{arg}")
1 parent b4d0436 commit 2f7f3c8

12 files changed

+20
-24
lines changed

examples/camera_transformations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ async fn main() {
128128
BLACK,
129129
);
130130
draw_text(
131-
format!("rotation (mouse wheel) = {} degrees", rotation).as_str(),
131+
format!("rotation (mouse wheel) = {rotation} degrees").as_str(),
132132
10.0,
133133
25.0,
134134
15.0,
135135
BLACK,
136136
);
137137
draw_text(
138-
format!("zoom (ctrl + mouse wheel) = {:.2}", zoom).as_str(),
138+
format!("zoom (ctrl + mouse wheel) = {zoom:.2}").as_str(),
139139
10.0,
140140
40.0,
141141
15.0,

examples/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ async fn main() {
88
clear_background(WHITE);
99
root_ui().window(hash!(), Vec2::new(20., 20.), Vec2::new(450., 200.), |ui| {
1010
let (mouse_x, mouse_y) = mouse_position();
11-
ui.label(None, &format!("Mouse position: {} {}", mouse_x, mouse_y));
11+
ui.label(None, &format!("Mouse position: {mouse_x} {mouse_y}"));
1212

1313
let (mouse_wheel_x, mouse_wheel_y) = mouse_wheel();
14-
ui.label(None, &format!("Mouse wheel x: {}", mouse_wheel_x));
15-
ui.label(None, &format!("Mouse wheel y: {}", mouse_wheel_y));
14+
ui.label(None, &format!("Mouse wheel x: {mouse_wheel_x}"));
15+
ui.label(None, &format!("Mouse wheel y: {mouse_wheel_y}"));
1616

1717
widgets::Group::new(hash!(), Vec2::new(200., 90.))
1818
.position(Vec2::new(240., 0.))
1919
.ui(ui, |ui| {
2020
ui.label(None, "Pressed kbd keys");
2121

2222
if let Some(key) = get_last_key_pressed() {
23-
ui.label(None, &format!("{:?}", key))
23+
ui.label(None, &format!("{key:?}"))
2424
}
2525
});
2626

examples/first_person.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async fn main() {
129129
BLACK,
130130
);
131131
draw_text(
132-
format!("Press <TAB> to toggle mouse grab: {}", grabbed).as_str(),
132+
format!("Press <TAB> to toggle mouse grab: {grabbed}").as_str(),
133133
10.0,
134134
48.0 + 42.0,
135135
30.0,

examples/shadertoy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async fn main() {
145145
ui.separator();
146146

147147
for (i, (name, uniform)) in uniforms.iter_mut().enumerate() {
148-
ui.label(None, &format!("{}", name));
148+
ui.label(None, &format!("{name}"));
149149
ui.same_line(120.0);
150150

151151
match uniform {
@@ -356,7 +356,7 @@ async fn main() {
356356
error = None;
357357
}
358358
Err(err) => {
359-
error = Some(format!("{:#?}", err));
359+
error = Some(format!("{err:#?}"));
360360
}
361361
}
362362
}

examples/ui.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ async fn main() {
156156
.ui(&mut *root_ui(), |ui| {
157157
for i in 0..30 {
158158
Group::new(hash!("shop", i), Vec2::new(300., 80.)).ui(ui, |ui| {
159-
ui.label(Vec2::new(10., 10.), &format!("Item N {}", i));
159+
ui.label(Vec2::new(10., 10.), &format!("Item N {i}"));
160160
ui.label(Vec2::new(260., 40.), "10/10");
161161
ui.label(Vec2::new(200., 58.), &format!("{} kr", 800));
162162
if ui.button(Vec2::new(260., 55.), "buy") {
163-
data.inventory.push(format!("Item {}", i));
163+
data.inventory.push(format!("Item {i}"));
164164
}
165165
});
166166
}
@@ -198,10 +198,7 @@ async fn main() {
198198

199199
ui.input_text(hash!(), "<- input text 1", &mut data0);
200200
ui.input_text(hash!(), "<- input text 2", &mut data1);
201-
ui.label(
202-
None,
203-
&format!("Text entered: \"{}\" and \"{}\"", data0, data1),
204-
);
201+
ui.label(None, &format!("Text entered: \"{data0}\" and \"{data1}\""));
205202

206203
ui.separator();
207204
});

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl From<image::ImageError> for Error {
3030

3131
impl std::fmt::Display for Error {
3232
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33-
write!(f, "error: {:?}", self)
33+
write!(f, "error: {self:?}")
3434
}
3535
}
3636

src/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub async fn load_file(path: &str) -> Result<Vec<u8>, Error> {
3131

3232
#[cfg(not(target_os = "android"))]
3333
let path = if let Some(ref pc_assets) = crate::get_context().pc_assets_folder {
34-
format!("{}/{}", pc_assets, path)
34+
format!("{pc_assets}/{path}")
3535
} else {
3636
path.to_string()
3737
};

src/material.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ pub mod shaders {
153153
.iter()
154154
.find(|(name, _)| name == &filename)
155155
.expect(&format!(
156-
"Include file {} in not on \"includes\" list",
157-
filename
156+
"Include file {filename} in not on \"includes\" list"
158157
));
159158

160159
let _ = res

src/quad_gl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl MagicSnapshotter {
149149
},
150150
snapshotter_shader::meta(),
151151
)
152-
.unwrap_or_else(|e| panic!("Failed to load shader: {}", e));
152+
.unwrap_or_else(|e| panic!("Failed to load shader: {e}"));
153153

154154
let pipeline = ctx.new_pipeline(
155155
&[BufferLayout::default()],
@@ -396,7 +396,7 @@ impl PipelinesStorage {
396396
},
397397
shader::meta(),
398398
)
399-
.unwrap_or_else(|e| panic!("Failed to load shader: {}", e));
399+
.unwrap_or_else(|e| panic!("Failed to load shader: {e}"));
400400

401401
let params = PipelineParams {
402402
color_blend: Some(BlendState::new(

src/texture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ pub fn build_textures_atlas() {
931931

932932
let texture = context.texture_batcher.atlas.texture();
933933
let (w, h) = get_quad_context().texture_size(texture);
934-
crate::telemetry::log_string(&format!("Atlas: {} {}", w, h));
934+
crate::telemetry::log_string(&format!("Atlas: {w} {h}"));
935935
}
936936

937937
#[doc(hidden)]

src/window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ where
124124
F: Fn(String, String) -> T + Send + Sync + 'static,
125125
{
126126
std::panic::set_hook(Box::new(move |info| {
127-
let message = format!("{:?}", info);
127+
let message = format!("{info:?}");
128128
#[cfg(feature = "backtrace")]
129129
let backtrace_string = format!("{:?}", backtrace::Backtrace::new());
130130
#[cfg(not(feature = "backtrace"))]

tests/back_to_the_future_coroutines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async fn back_to_the_future_coroutine() {
3030
});
3131
let mut i = 10;
3232
loop {
33-
println!("{}", i);
33+
println!("{i}");
3434
if player2.lock().unwrap().allow_movement {
3535
break;
3636
}

0 commit comments

Comments
 (0)