Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit 5b5aa1f

Browse files
committed
gtk: Fix some clippy warnings
1 parent 6cd1c36 commit 5b5aa1f

File tree

2 files changed

+18
-40
lines changed

2 files changed

+18
-40
lines changed

gtk/src/list_store.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,17 @@ impl<O: IsA<ListStore>> GtkListStoreExtManual for O {
6969
for (column, value) in columns_and_values {
7070
assert!(
7171
*column < n_columns,
72-
"got column {} which is higher than the number of columns {}",
72+
"got column {} which is higher than the number of columns {n_columns}",
7373
*column,
74-
n_columns
7574
);
7675
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
7776
self.as_ref().upcast_ref::<TreeModel>().to_glib_none().0,
7877
*column as c_int,
7978
));
8079
assert!(
8180
Value::type_transformable(value.value_type(), type_),
82-
"column {} is of type {} but found value of type {}",
81+
"column {} is of type {type_} but found value of type {}",
8382
*column,
84-
type_,
8583
value.value_type()
8684
);
8785
}
@@ -117,8 +115,7 @@ impl<O: IsA<ListStore>> GtkListStoreExtManual for O {
117115
let safe_count = count as usize == new_order.len();
118116
debug_assert!(
119117
safe_count,
120-
"Incorrect `new_order` slice length. Expected `{}`, found `{}`.",
121-
count,
118+
"Incorrect `new_order` slice length. Expected `{count}`, found `{}`.",
122119
new_order.len()
123120
);
124121
let safe_values = new_order.iter().max().map_or(true, |&max| {
@@ -128,9 +125,8 @@ impl<O: IsA<ListStore>> GtkListStoreExtManual for O {
128125
debug_assert!(
129126
safe_values,
130127
"Some `new_order` slice values are out of range. Maximum safe value: \
131-
`{}`. The slice contents: `{:?}`",
128+
`{}`. The slice contents: `{new_order:?}`",
132129
count - 1,
133-
new_order
134130
);
135131
if safe_count && safe_values {
136132
ffi::gtk_list_store_reorder(
@@ -148,26 +144,23 @@ impl<O: IsA<ListStore>> GtkListStoreExtManual for O {
148144
) as u32;
149145
assert!(
150146
columns_and_values.len() <= n_columns as usize,
151-
"got values for {} columns but only {} columns exist",
147+
"got values for {} columns but only {n_columns} columns exist",
152148
columns_and_values.len(),
153-
n_columns
154149
);
155150
for (column, value) in columns_and_values {
156151
assert!(
157152
*column < n_columns,
158-
"got column {} which is higher than the number of columns {}",
153+
"got column {} which is higher than the number of columns {n_columns}",
159154
*column,
160-
n_columns
161155
);
162156
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
163157
self.as_ref().upcast_ref::<TreeModel>().to_glib_none().0,
164158
*column as c_int,
165159
));
166160
assert!(
167161
Value::type_transformable(value.value_type(), type_),
168-
"column {} is of type {} but found value of type {}",
162+
"column {} is of type {type_} but found value of type {}",
169163
*column,
170-
type_,
171164
value.value_type()
172165
);
173166
}
@@ -198,9 +191,7 @@ impl<O: IsA<ListStore>> GtkListStoreExtManual for O {
198191
) as u32;
199192
assert!(
200193
column < columns,
201-
"got column {} which is higher than the number of columns {}",
202-
column,
203-
columns
194+
"got column {column} which is higher than the number of columns {columns}",
204195
);
205196

206197
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
@@ -209,9 +200,7 @@ impl<O: IsA<ListStore>> GtkListStoreExtManual for O {
209200
));
210201
assert!(
211202
Value::type_transformable(value.type_(), type_),
212-
"column {} is of type {} but found value of type {}",
213-
column,
214-
type_,
203+
"column {column} is of type {type_} but found value of type {}",
215204
value.type_()
216205
);
217206

gtk/src/tree_store.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,23 @@ impl<O: IsA<TreeStore>> TreeStoreExtManual for O {
6363
) as u32;
6464
assert!(
6565
columns_and_values.len() <= n_columns as usize,
66-
"got values for {} columns but only {} columns exist",
66+
"got values for {} columns but only {n_columns} columns exist",
6767
columns_and_values.len(),
68-
n_columns
6968
);
7069
for (column, value) in columns_and_values {
7170
assert!(
7271
*column < n_columns,
73-
"got column {} which is higher than the number of columns {}",
72+
"got column {} which is higher than the number of columns {n_columns}",
7473
*column,
75-
n_columns
7674
);
7775
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
7876
self.as_ref().upcast_ref::<TreeModel>().to_glib_none().0,
7977
*column as c_int,
8078
));
8179
assert!(
8280
Value::type_transformable(value.value_type(), type_),
83-
"column {} is of type {} but found value of type {}",
81+
"column {} is of type {type_} but found value of type {}",
8482
*column,
85-
type_,
8683
value.value_type()
8784
);
8885
}
@@ -119,8 +116,7 @@ impl<O: IsA<TreeStore>> TreeStoreExtManual for O {
119116
let safe_count = count as usize == new_order.len();
120117
debug_assert!(
121118
safe_count,
122-
"Incorrect `new_order` slice length. Expected `{}`, found `{}`.",
123-
count,
119+
"Incorrect `new_order` slice length. Expected `{count}`, found `{}`.",
124120
new_order.len()
125121
);
126122
let safe_values = new_order.iter().max().map_or(true, |&max| {
@@ -130,9 +126,8 @@ impl<O: IsA<TreeStore>> TreeStoreExtManual for O {
130126
debug_assert!(
131127
safe_values,
132128
"Some `new_order` slice values are out of range. Maximum safe value: \
133-
`{}`. The slice contents: `{:?}`",
129+
`{}`. The slice contents: `{new_order:?}`",
134130
count - 1,
135-
new_order
136131
);
137132
if safe_count && safe_values {
138133
ffi::gtk_tree_store_reorder(
@@ -158,19 +153,17 @@ impl<O: IsA<TreeStore>> TreeStoreExtManual for O {
158153
for (column, value) in columns_and_values {
159154
assert!(
160155
*column < n_columns,
161-
"got column {} which is higher than the number of columns {}",
156+
"got column {} which is higher than the number of columns {n_columns}",
162157
*column,
163-
n_columns
164158
);
165159
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
166160
self.as_ref().upcast_ref::<TreeModel>().to_glib_none().0,
167161
*column as c_int,
168162
));
169163
assert!(
170164
Value::type_transformable(value.value_type(), type_),
171-
"column {} is of type {} but found value of type {}",
165+
"column {} is of type {type_} but found value of type {}",
172166
*column,
173-
type_,
174167
value.value_type()
175168
);
176169
}
@@ -201,9 +194,7 @@ impl<O: IsA<TreeStore>> TreeStoreExtManual for O {
201194
) as u32;
202195
assert!(
203196
column < columns,
204-
"got column {} which is higher than the number of columns {}",
205-
column,
206-
columns
197+
"got column {column} which is higher than the number of columns {columns}",
207198
);
208199

209200
let type_ = from_glib(ffi::gtk_tree_model_get_column_type(
@@ -212,9 +203,7 @@ impl<O: IsA<TreeStore>> TreeStoreExtManual for O {
212203
));
213204
assert!(
214205
Value::type_transformable(value.type_(), type_),
215-
"column {} is of type {} but found value of type {}",
216-
column,
217-
type_,
206+
"column {column} is of type {type_} but found value of type {}",
218207
value.type_()
219208
);
220209

0 commit comments

Comments
 (0)