Skip to content

Commit 2cde642

Browse files
committed
Use new format macro syntax
1 parent 6965937 commit 2cde642

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+117
-179
lines changed

bindings-generator/src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ mod tests {
785785
];
786786
tests.iter().for_each(|(class_name, expected)| {
787787
let actual = module_name_from_class_name(class_name);
788-
assert_eq!(*expected, actual, "Input: {}", class_name);
788+
assert_eq!(*expected, actual, "Input: {class_name}");
789789
});
790790
}
791791
}

bindings-generator/src/class_docs.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,10 @@ impl GodotXmlDocs {
6767
if let Some(property_name) = node.attribute("name") {
6868
if !property_name.contains('/') {
6969
if node.has_attribute("setter") {
70-
self.add_fn(
71-
class,
72-
&format!("set_{}", property_name),
73-
desc,
74-
&[],
75-
);
70+
self.add_fn(class, &format!("set_{property_name}"), desc, &[]);
7671
}
7772
if node.has_attribute("getter") {
78-
self.add_fn(
79-
class,
80-
&format!("get_{}", property_name),
81-
desc,
82-
&[],
83-
);
73+
self.add_fn(class, &format!("get_{property_name}"), desc, &[]);
8474
}
8575
}
8676
}
@@ -187,10 +177,7 @@ impl GodotXmlDocs {
187177

188178
// Info for GDScript blocks
189179
let godot_doc = if godot_doc.contains("[codeblock]") {
190-
format!(
191-
"_Sample code is GDScript unless otherwise noted._\n\n{}",
192-
godot_doc
193-
)
180+
format!("_Sample code is GDScript unless otherwise noted._\n\n{godot_doc}")
194181
} else {
195182
godot_doc
196183
};
@@ -213,9 +200,9 @@ impl GodotXmlDocs {
213200
let text = &c[2];
214201

215202
if text.is_empty() {
216-
format!("<{url}>", url = url)
203+
format!("<{url}>")
217204
} else {
218-
format!("[{text}]({url})", text = text, url = url)
205+
format!("[{text}]({url})")
219206
}
220207
});
221208

@@ -247,11 +234,7 @@ impl GodotXmlDocs {
247234
let godot_ty = &c[2];
248235
let rust_ty = Self::translate_type(godot_ty);
249236

250-
format!(
251-
"[`{godot_ty}`][{rust_ty}]",
252-
godot_ty = godot_ty,
253-
rust_ty = rust_ty
254-
)
237+
format!("[`{godot_ty}`][{rust_ty}]")
255238
});
256239

257240
godot_doc.to_string()

bindings-generator/src/documentation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn list_base_classes(output: &mut impl Write, api: &Api, parent_name: &str) -> G
149149
if let Some(parent) = api.find_class(parent_name) {
150150
let class_link = class_doc_link(parent);
151151

152-
writeln!(output, " - {}", class_link)?;
152+
writeln!(output, " - {class_link}")?;
153153

154154
if !parent.base_class.is_empty() {
155155
list_base_classes(output, api, &parent.base_class)?;

bindings-generator/src/godot_version.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ pub fn parse_godot_version(version_str: &str) -> Result<GodotVersion, Box<dyn Er
1515

1616
let caps = regex.captures(version_str).ok_or("Regex capture failed")?;
1717

18-
let fail = || {
19-
format!(
20-
"Version substring could not be matched in '{}'",
21-
version_str
22-
)
23-
};
18+
let fail = || format!("Version substring could not be matched in '{version_str}'");
2419

2520
Ok(GodotVersion {
2621
major: caps.get(1).ok_or_else(fail)?.as_str().parse::<u8>()?,

bindings-generator/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub fn generate_method_table(api: &Api, class: &GodotClass) -> TokenStream {
200200
} = m.get_name();
201201

202202
let rust_ident = format_ident!("{}", rust_name);
203-
let original_name = format!("{}\0", original_name);
203+
let original_name = format!("{original_name}\0");
204204

205205
if !skip_method(m, rust_name) {
206206
assert!(original_name.ends_with('\0'), "original_name must be null terminated");

bindings-generator/src/special_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn generate_singleton_getter(class: &GodotClass) -> TokenStream {
113113
class.name.as_ref()
114114
};
115115

116-
let singleton_name = format!("{}\0", s_name);
116+
let singleton_name = format!("{s_name}\0");
117117

118118
assert!(
119119
singleton_name.ends_with('\0'),

gdnative-async/src/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<C: NativeClass, F: AsyncMethod<C>> Method<C> for Async<F> {
209209
Some(Err(err)) => {
210210
log::error(
211211
Self::site().unwrap_or_default(),
212-
format_args!("unable to spawn future: {}", err),
212+
format_args!("unable to spawn future: {err}"),
213213
);
214214
Variant::nil()
215215
}

gdnative-async/src/rt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ pub fn register_runtime_with_prefix<S>(handle: &InitHandle, prefix: S)
107107
where
108108
S: Display,
109109
{
110-
handle.add_class_as::<bridge::SignalBridge>(format!("{}SignalBridge", prefix));
111-
handle.add_class_as::<func_state::FuncState>(format!("{}FuncState", prefix));
110+
handle.add_class_as::<bridge::SignalBridge>(format!("{prefix}SignalBridge"));
111+
handle.add_class_as::<func_state::FuncState>(format!("{prefix}FuncState"));
112112
}
113113

114114
/// Releases all observers still in use. This should be called in the

gdnative-bindings/build.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,15 @@ fn generate(
9292
for (class, code) in &binding_res.class_bindings {
9393
let mod_name = gen::module_name_from_class_name(&class.name);
9494

95-
let mod_path = out_path.join(format!("{}.rs", mod_name));
95+
let mod_path = out_path.join(format!("{mod_name}.rs"));
9696
let mut mod_output = BufWriter::new(File::create(&mod_path).unwrap());
9797

9898
write!(
9999
&mut mod_output,
100100
r#"
101-
{content}
101+
{code}
102102
use super::*;
103103
"#,
104-
content = code,
105104
)
106105
.unwrap();
107106

@@ -152,7 +151,7 @@ fn format_file_if_needed(output_rs: &Path) {
152151
Ok(_) => println!("Done."),
153152
Err(err) => {
154153
println!("Failed.");
155-
println!("Error: {}", err);
154+
println!("Error: {err}");
156155
}
157156
}
158157
}

gdnative-core/src/core_types/byte_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ godot_test!(
4949
godot_test!(
5050
test_byte_array_debug {
5151
let arr = (0..8).collect::<ByteArray>();
52-
assert_eq!(format!("{:?}", arr), "[0, 1, 2, 3, 4, 5, 6, 7]");
52+
assert_eq!(format!("{arr:?}"), "[0, 1, 2, 3, 4, 5, 6, 7]");
5353
}
5454
);

0 commit comments

Comments
 (0)