Skip to content

Commit

Permalink
Refactor format!("{}", arg) -> format!("{arg}")
Browse files Browse the repository at this point in the history
  • Loading branch information
hamirmahal authored Dec 31, 2024
1 parent b4d0436 commit 2f7f3c8
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 24 deletions.
4 changes: 2 additions & 2 deletions examples/camera_transformations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ async fn main() {
BLACK,
);
draw_text(
format!("rotation (mouse wheel) = {} degrees", rotation).as_str(),
format!("rotation (mouse wheel) = {rotation} degrees").as_str(),
10.0,
25.0,
15.0,
BLACK,
);
draw_text(
format!("zoom (ctrl + mouse wheel) = {:.2}", zoom).as_str(),
format!("zoom (ctrl + mouse wheel) = {zoom:.2}").as_str(),
10.0,
40.0,
15.0,
Expand Down
8 changes: 4 additions & 4 deletions examples/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ async fn main() {
clear_background(WHITE);
root_ui().window(hash!(), Vec2::new(20., 20.), Vec2::new(450., 200.), |ui| {
let (mouse_x, mouse_y) = mouse_position();
ui.label(None, &format!("Mouse position: {} {}", mouse_x, mouse_y));
ui.label(None, &format!("Mouse position: {mouse_x} {mouse_y}"));

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

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

if let Some(key) = get_last_key_pressed() {
ui.label(None, &format!("{:?}", key))
ui.label(None, &format!("{key:?}"))
}
});

Expand Down
2 changes: 1 addition & 1 deletion examples/first_person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async fn main() {
BLACK,
);
draw_text(
format!("Press <TAB> to toggle mouse grab: {}", grabbed).as_str(),
format!("Press <TAB> to toggle mouse grab: {grabbed}").as_str(),
10.0,
48.0 + 42.0,
30.0,
Expand Down
4 changes: 2 additions & 2 deletions examples/shadertoy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async fn main() {
ui.separator();

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

match uniform {
Expand Down Expand Up @@ -356,7 +356,7 @@ async fn main() {
error = None;
}
Err(err) => {
error = Some(format!("{:#?}", err));
error = Some(format!("{err:#?}"));
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ async fn main() {
.ui(&mut *root_ui(), |ui| {
for i in 0..30 {
Group::new(hash!("shop", i), Vec2::new(300., 80.)).ui(ui, |ui| {
ui.label(Vec2::new(10., 10.), &format!("Item N {}", i));
ui.label(Vec2::new(10., 10.), &format!("Item N {i}"));
ui.label(Vec2::new(260., 40.), "10/10");
ui.label(Vec2::new(200., 58.), &format!("{} kr", 800));
if ui.button(Vec2::new(260., 55.), "buy") {
data.inventory.push(format!("Item {}", i));
data.inventory.push(format!("Item {i}"));
}
});
}
Expand Down Expand Up @@ -198,10 +198,7 @@ async fn main() {

ui.input_text(hash!(), "<- input text 1", &mut data0);
ui.input_text(hash!(), "<- input text 2", &mut data1);
ui.label(
None,
&format!("Text entered: \"{}\" and \"{}\"", data0, data1),
);
ui.label(None, &format!("Text entered: \"{data0}\" and \"{data1}\""));

ui.separator();
});
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl From<image::ImageError> for Error {

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

Expand Down
2 changes: 1 addition & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn load_file(path: &str) -> Result<Vec<u8>, Error> {

#[cfg(not(target_os = "android"))]
let path = if let Some(ref pc_assets) = crate::get_context().pc_assets_folder {
format!("{}/{}", pc_assets, path)
format!("{pc_assets}/{path}")
} else {
path.to_string()
};
Expand Down
3 changes: 1 addition & 2 deletions src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ pub mod shaders {
.iter()
.find(|(name, _)| name == &filename)
.expect(&format!(
"Include file {} in not on \"includes\" list",
filename
"Include file {filename} in not on \"includes\" list"
));

let _ = res
Expand Down
4 changes: 2 additions & 2 deletions src/quad_gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl MagicSnapshotter {
},
snapshotter_shader::meta(),
)
.unwrap_or_else(|e| panic!("Failed to load shader: {}", e));
.unwrap_or_else(|e| panic!("Failed to load shader: {e}"));

let pipeline = ctx.new_pipeline(
&[BufferLayout::default()],
Expand Down Expand Up @@ -396,7 +396,7 @@ impl PipelinesStorage {
},
shader::meta(),
)
.unwrap_or_else(|e| panic!("Failed to load shader: {}", e));
.unwrap_or_else(|e| panic!("Failed to load shader: {e}"));

let params = PipelineParams {
color_blend: Some(BlendState::new(
Expand Down
2 changes: 1 addition & 1 deletion src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ pub fn build_textures_atlas() {

let texture = context.texture_batcher.atlas.texture();
let (w, h) = get_quad_context().texture_size(texture);
crate::telemetry::log_string(&format!("Atlas: {} {}", w, h));
crate::telemetry::log_string(&format!("Atlas: {w} {h}"));
}

#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ where
F: Fn(String, String) -> T + Send + Sync + 'static,
{
std::panic::set_hook(Box::new(move |info| {
let message = format!("{:?}", info);
let message = format!("{info:?}");
#[cfg(feature = "backtrace")]
let backtrace_string = format!("{:?}", backtrace::Backtrace::new());
#[cfg(not(feature = "backtrace"))]
Expand Down
2 changes: 1 addition & 1 deletion tests/back_to_the_future_coroutines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn back_to_the_future_coroutine() {
});
let mut i = 10;
loop {
println!("{}", i);
println!("{i}");
if player2.lock().unwrap().allow_movement {
break;
}
Expand Down

0 comments on commit 2f7f3c8

Please sign in to comment.