Skip to content

Commit ded5898

Browse files
Fix clippy warnings
1 parent b59c0b0 commit ded5898

File tree

18 files changed

+41
-84
lines changed

18 files changed

+41
-84
lines changed

examples/column_view_datagrid/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ fn build_ui(application: &gtk::Application) {
3434

3535
(0..10000).for_each(|i| {
3636
store.append(&BoxedAnyObject::new(Row {
37-
col1: format!("col1 {}", i),
38-
col2: format!("col2 {}", i),
37+
col1: format!("col1 {i}"),
38+
col2: format!("col2 {i}"),
3939
}))
4040
});
4141
let sel = gtk::SingleSelection::new(Some(store));

examples/composite_template/ex_application_window/imp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl UtilityCallbacks {
6565
let mut res = String::new();
6666
for (index, value) in values.iter().enumerate() {
6767
res.push_str(value.get::<&str>().unwrap_or_else(|e| {
68-
panic!("Expected string value for argument {}: {}", index, e);
68+
panic!("Expected string value for argument {index}: {e}");
6969
}));
7070
}
7171
res

examples/dialog/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn dialog<W: IsA<gtk::Window>>(window: Rc<W>) {
6161
.modal(true)
6262
.buttons(gtk::ButtonsType::Close)
6363
.text("You answered")
64-
.secondary_text(&format!("Your answer: {:?}", answer))
64+
.secondary_text(&format!("Your answer: {answer:?}"))
6565
.build();
6666

6767
info_dialog.run_future().await;

examples/expressions/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn build_ui(app: &gtk::Application) {
4545
.chain_property::<Metadata>("title")
4646
.chain_closure_with_callback(|args| {
4747
let title: String = args[1].get().unwrap();
48-
format!("Title: {}", title)
48+
format!("Title: {title}")
4949
})
5050
.bind(&title_label, "label", gtk::Widget::NONE);
5151

@@ -87,7 +87,7 @@ fn data() -> gio::ListStore {
8787

8888
for i in 0..=100 {
8989
let metadata = Metadata::new();
90-
metadata.set_property("title", format!("Note ({})", i));
90+
metadata.set_property("title", format!("Note ({i})"));
9191

9292
let note = Note::new(&metadata);
9393
vector.push(note);

examples/list_box_model/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn build_ui(application: &gtk::Application) {
120120
window.set_child(Some(&vbox));
121121

122122
for i in 0..10 {
123-
model.append(&RowData::new(&format!("Name {}", i), i * 10));
123+
model.append(&RowData::new(&format!("Name {i}"), i * 10));
124124
}
125125

126126
window.show();

examples/virtual_methods/base_button/imp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(super) fn base_button_async_method(this: &BaseButtonInstance) -> PinnedFutur
5050
impl BaseButton {
5151
fn sync_method(&self, obj: &super::BaseButton, extra_text: Option<String>) {
5252
if let Some(text) = extra_text {
53-
obj.set_label(&format!("BaseButton sync: {}", text));
53+
obj.set_label(&format!("BaseButton sync: {text}"));
5454
} else {
5555
obj.set_label("BaseButton sync");
5656
}

examples/virtual_methods/derived_button/imp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl ButtonImpl for DerivedButton {}
1919
impl BaseButtonImpl for DerivedButton {
2020
fn sync_method(&self, obj: &BaseButton, extra_text: Option<String>) {
2121
if let Some(text) = extra_text {
22-
obj.set_label(&format!("DerivedButton sync {}", text));
22+
obj.set_label(&format!("DerivedButton sync {text}"));
2323
} else {
2424
obj.set_label("DerivedButton sync");
2525
}

gdk4-wayland/tests/check_gir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn check_gir_file() {
55
let res = gir_format_check::check_gir_file("Gir.toml");
6-
println!("{}", res);
6+
println!("{res}");
77
assert_eq!(res.nb_errors, 0);
88
}

gdk4-win32/tests/check_gir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn check_gir_file() {
55
let res = gir_format_check::check_gir_file("Gir.toml");
6-
println!("{}", res);
6+
println!("{res}");
77
assert_eq!(res.nb_errors, 0);
88
}

gdk4-x11/tests/check_gir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn check_gir_file() {
55
let res = gir_format_check::check_gir_file("Gir.toml");
6-
println!("{}", res);
6+
println!("{res}");
77
assert_eq!(res.nb_errors, 0);
88
}

gdk4/tests/check_gir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn check_gir_file() {
55
let res = gir_format_check::check_gir_file("Gir.toml");
6-
println!("{}", res);
6+
println!("{res}");
77
assert_eq!(res.nb_errors, 0);
88
}

gsk4/tests/check_gir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn check_gir_file() {
55
let res = gir_format_check::check_gir_file("Gir.toml");
6-
println!("{}", res);
6+
println!("{res}");
77
assert_eq!(res.nb_errors, 0);
88
}

gtk4-macros/src/template_callbacks_attribute.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ pub fn impl_template_callbacks(mut input: syn::ItemImpl, args: Args) -> TokenStr
163163
arg_names.push(name.clone());
164164
let unwrap_value = |ty, err_msg| {
165165
let index_err_msg = format!(
166-
"Failed to get argument `{}` at index {}: Closure invoked with only {{}} arguments",
167-
ident,
168-
index
166+
"Failed to get argument `{ident}` at index {index}: Closure invoked with only {{}} arguments",
169167
);
170168
quote! {
171169
let #name = <[#crate_ident::glib::Value]>::get(&values, #index)
@@ -177,8 +175,7 @@ pub fn impl_template_callbacks(mut input: syn::ItemImpl, args: Args) -> TokenStr
177175
match arg {
178176
syn::FnArg::Receiver(receiver) => {
179177
let err_msg = format!(
180-
"Wrong type for `self` in template callback `{}`: {{:?}}",
181-
ident
178+
"Wrong type for `self` in template callback `{ident}`: {{:?}}",
182179
);
183180
if receiver.reference.is_none() {
184181
Some(unwrap_value(quote! { #self_ty }, err_msg))
@@ -226,9 +223,7 @@ pub fn impl_template_callbacks(mut input: syn::ItemImpl, args: Args) -> TokenStr
226223
} else {
227224
let ty = typed.ty.as_ref();
228225
let err_msg = format!(
229-
"Wrong type for argument {} in template callback `{}`: {{:?}}",
230-
index,
231-
ident
226+
"Wrong type for argument {index} in template callback `{ident}`: {{:?}}",
232227
);
233228
Some(unwrap_value(ty.to_token_stream(), err_msg))
234229
}

gtk4/src/list_store.rs

+10-26
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,21 @@ impl ListStore {
4040
as u32;
4141
assert!(
4242
columns_and_values.len() <= n_columns as usize,
43-
"got values for {} columns but only {} columns exist",
43+
"got values for {} columns but only {n_columns} columns exist",
4444
columns_and_values.len(),
45-
n_columns
4645
);
4746
for (column, value) in columns_and_values {
4847
assert!(
4948
*column < n_columns,
50-
"got column {} which is higher than the number of columns {}",
51-
*column,
52-
n_columns
49+
"got column {column} which is higher than the number of columns {n_columns}",
5350
);
5451
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
5552
self.upcast_ref::<TreeModel>().to_glib_none().0,
5653
*column as c_int,
5754
));
5855
assert!(
5956
Value::type_transformable(value.value_type(), type_),
60-
"column {} is of type {} but found value of type {}",
61-
*column,
62-
type_,
57+
"column {column} is of type {type_} but found value of type {}",
6358
value.value_type()
6459
);
6560
}
@@ -96,8 +91,7 @@ impl ListStore {
9691
let safe_count = count as usize == new_order.len();
9792
debug_assert!(
9893
safe_count,
99-
"Incorrect `new_order` slice length. Expected `{}`, found `{}`.",
100-
count,
94+
"Incorrect `new_order` slice length. Expected `{count}`, found `{}`.",
10195
new_order.len()
10296
);
10397
let safe_values = new_order.iter().max().map_or(true, |&max| {
@@ -107,9 +101,8 @@ impl ListStore {
107101
debug_assert!(
108102
safe_values,
109103
"Some `new_order` slice values are out of range. Maximum safe value: \
110-
`{}`. The slice contents: `{:?}`",
104+
`{}`. The slice contents: `{new_order:?}`",
111105
count - 1,
112-
new_order
113106
);
114107
if safe_count && safe_values {
115108
ffi::gtk_list_store_reorder(
@@ -130,26 +123,21 @@ impl ListStore {
130123
as u32;
131124
assert!(
132125
columns_and_values.len() <= n_columns as usize,
133-
"got values for {} columns but only {} columns exist",
126+
"got values for {} columns but only {n_columns} columns exist",
134127
columns_and_values.len(),
135-
n_columns
136128
);
137129
for (column, value) in columns_and_values {
138130
assert!(
139131
*column < n_columns,
140-
"got column {} which is higher than the number of columns {}",
141-
*column,
142-
n_columns
132+
"got column {column} which is higher than the number of columns {n_columns}",
143133
);
144134
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
145135
self.upcast_ref::<TreeModel>().to_glib_none().0,
146136
*column as c_int,
147137
));
148138
assert!(
149139
Value::type_transformable(value.value_type(), type_),
150-
"column {} is of type {} but found value of type {}",
151-
*column,
152-
type_,
140+
"column {column} is of type {type_} but found value of type {}",
153141
value.value_type()
154142
);
155143
}
@@ -193,9 +181,7 @@ impl ListStore {
193181
as u32;
194182
assert!(
195183
column < columns,
196-
"got column {} which is higher than the number of columns {}",
197-
column,
198-
columns
184+
"got column {column} which is higher than the number of columns {columns}",
199185
);
200186

201187
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
@@ -204,9 +190,7 @@ impl ListStore {
204190
));
205191
assert!(
206192
Value::type_transformable(value.type_(), type_),
207-
"column {} is of type {} but found value of type {}",
208-
column,
209-
type_,
193+
"column {column} is of type {type_} but found value of type {}",
210194
value.type_()
211195
);
212196

gtk4/src/subclass/widget.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,7 @@ pub unsafe trait WidgetClassSubclassExt: ClassStruct {
10591059
let type_ = <Self::Type as ObjectSubclassType>::type_();
10601060
assert!(
10611061
SignalId::lookup(signal_name, type_).is_some(),
1062-
"Signal '{}' doesn't exists for type '{}'",
1063-
signal_name,
1064-
type_
1062+
"Signal '{signal_name}' doesn't exists for type '{type_}'",
10651063
);
10661064

10671065
let shortcut = crate::Shortcut::new(
@@ -1119,9 +1117,7 @@ pub unsafe trait WidgetClassSubclassExt: ClassStruct {
11191117
let type_ = <Self::Type as ObjectSubclassType>::type_();
11201118
assert!(
11211119
SignalId::lookup(signal_name, type_).is_some(),
1122-
"Signal '{}' doesn't exists for type '{}'",
1123-
signal_name,
1124-
type_
1120+
"Signal '{signal_name}' doesn't exists for type '{type_}'",
11251121
);
11261122

11271123
unsafe {

gtk4/src/tree_model.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ impl<O: IsA<TreeModel>> TreeModelExtManual for O {
2525
let total_columns = self.as_ref().n_columns();
2626
assert!(
2727
column < total_columns,
28-
"TreeModel has {} columns but TreeModelExt::get got {} passed as a column number",
29-
total_columns,
30-
column
28+
"TreeModel has {total_columns} columns but TreeModelExt::get got {column} passed as a column number",
3129
);
3230
unsafe {
3331
let mut value = glib::Value::uninitialized();

gtk4/src/tree_store.rs

+10-26
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,21 @@ impl TreeStore {
4242
as u32;
4343
assert!(
4444
columns_and_values.len() <= n_columns as usize,
45-
"got values for {} columns but only {} columns exist",
45+
"got values for {} columns but only {n_columns} columns exist",
4646
columns_and_values.len(),
47-
n_columns
4847
);
4948
for (column, value) in columns_and_values {
5049
assert!(
5150
*column < n_columns,
52-
"got column {} which is higher than the number of columns {}",
53-
*column,
54-
n_columns
51+
"got column {column} which is higher than the number of columns {n_columns}",
5552
);
5653
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
5754
self.upcast_ref::<TreeModel>().to_glib_none().0,
5855
*column as c_int,
5956
));
6057
assert!(
6158
Value::type_transformable(value.value_type(), type_),
62-
"column {} is of type {} but found value of type {}",
63-
*column,
64-
type_,
59+
"column {column} is of type {} but found value of type {type_}",
6560
value.value_type()
6661
);
6762
}
@@ -100,8 +95,7 @@ impl TreeStore {
10095
let safe_count = count as usize == new_order.len();
10196
debug_assert!(
10297
safe_count,
103-
"Incorrect `new_order` slice length. Expected `{}`, found `{}`.",
104-
count,
98+
"Incorrect `new_order` slice length. Expected `{count}`, found `{}`.",
10599
new_order.len()
106100
);
107101
let safe_values = new_order.iter().max().map_or(true, |&max| {
@@ -111,9 +105,8 @@ impl TreeStore {
111105
debug_assert!(
112106
safe_values,
113107
"Some `new_order` slice values are out of range. Maximum safe value: \
114-
`{}`. The slice contents: `{:?}`",
108+
`{}`. The slice contents: `{new_order:?}`",
115109
count - 1,
116-
new_order
117110
);
118111
if safe_count && safe_values {
119112
ffi::gtk_tree_store_reorder(
@@ -136,26 +129,21 @@ impl TreeStore {
136129
as u32;
137130
assert!(
138131
columns_and_values.len() <= n_columns as usize,
139-
"got values for {} columns but only {} columns exist",
132+
"got values for {} columns but only {n_columns} columns exist",
140133
columns_and_values.len(),
141-
n_columns
142134
);
143135
for (column, value) in columns_and_values {
144136
assert!(
145137
*column < n_columns,
146-
"got column {} which is higher than the number of columns {}",
147-
*column,
148-
n_columns
138+
"got column {column} which is higher than the number of columns {n_columns}",
149139
);
150140
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
151141
self.upcast_ref::<TreeModel>().to_glib_none().0,
152142
*column as c_int,
153143
));
154144
assert!(
155145
Value::type_transformable(value.value_type(), type_),
156-
"column {} is of type {} but found value of type {}",
157-
*column,
158-
type_,
146+
"column {column} is of type {type_} but found value of type {}",
159147
value.value_type()
160148
);
161149
}
@@ -201,9 +189,7 @@ impl TreeStore {
201189
as u32;
202190
assert!(
203191
column < columns,
204-
"got column {} which is higher than the number of columns {}",
205-
column,
206-
columns
192+
"got column {column} which is higher than the number of columns {columns}",
207193
);
208194

209195
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
@@ -212,9 +198,7 @@ impl TreeStore {
212198
));
213199
assert!(
214200
Value::type_transformable(value.type_(), type_),
215-
"column {} is of type {} but found value of type {}",
216-
column,
217-
type_,
201+
"column {column} is of type {type_} but found value of type {}",
218202
value.type_()
219203
);
220204

gtk4/tests/check_gir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#[test]
44
fn check_gir_file() {
55
let res = gir_format_check::check_gir_file("Gir.toml");
6-
println!("{}", res);
6+
println!("{res}");
77
assert_eq!(res.nb_errors, 0);
88
}

0 commit comments

Comments
 (0)