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

Commit 3d700cb

Browse files
Fix clippy lints
1 parent 8d12723 commit 3d700cb

File tree

22 files changed

+36
-39
lines changed

22 files changed

+36
-39
lines changed

examples/cairo_threads/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn build_ui(application: &gtk::Application) {
8787
// Draw an arc with a weirdly calculated radius
8888
image.with_surface(|surface| {
8989
let cr = Context::new(surface).expect("Can't create a Cairo context");
90-
draw_slow(&cr, delay, x, y, 1.2_f64.powi(((n as i32) << thread_num) % 32));
90+
draw_slow(&cr, delay, x, y, 1.2_f64.powi((n << thread_num) % 32));
9191
surface.flush();
9292
});
9393

examples/communication_thread/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ fn start_communication_thread(mut sender: mpsc::Sender<String>) {
4949
loop {
5050
// Instead of a counter, your application code will
5151
// block here on TCP or serial communications.
52-
let data = format!("Counter = {}!", counter);
53-
println!("Thread received data: {}", data);
52+
let data = format!("Counter = {counter}!");
53+
println!("Thread received data: {data}");
5454
match sender.try_send(data) {
5555
Ok(_) => {}
5656
Err(err) => {

examples/dialog_async/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async fn dialog<W: IsA<gtk::Window>>(window: W) {
5050
.modal(true)
5151
.buttons(gtk::ButtonsType::Close)
5252
.text("You answered")
53-
.secondary_text(&format!("Your answer: {:?}", answer))
53+
.secondary_text(&format!("Your answer: {answer:?}"))
5454
.build();
5555

5656
info_dialog.run_future().await;

examples/gtk_builder_signal/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn build_ui(application: &gtk::Application) {
3030
}),
3131
)
3232
} else {
33-
panic!("Unknown handler name {}", handler_name)
33+
panic!("Unknown handler name {handler_name}")
3434
}
3535
});
3636

examples/gtk_test/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ fn build_ui(application: &gtk::Application) {
3434
let scale: Scale = builder.object("scale").expect("Couldn't get scale");
3535
scale.connect_format_value(|scale, value| {
3636
let digits = scale.digits() as usize;
37-
format!("<{:.*}>", digits, value)
37+
format!("<{value:.digits$}>")
3838
});
3939

4040
let spin_button: SpinButton = builder
4141
.object("spin_button")
4242
.expect("Couldn't get spin_button");
4343
spin_button.connect_input(|spin_button| {
4444
let text = spin_button.text();
45-
println!("spin_button_input: \"{}\"", text);
45+
println!("spin_button_input: \"{text}\"");
4646
match text.parse::<f64>() {
4747
Ok(value) if value >= 90. => {
4848
println!("circular right");
@@ -72,7 +72,7 @@ fn build_ui(application: &gtk::Application) {
7272
("Custom", ResponseType::Other(0))]);
7373

7474
dialog.connect_response(glib::clone!(@weak entry => move |dialog, response| {
75-
entry.set_text(&format!("Clicked {}", response));
75+
entry.set_text(&format!("Clicked {response}"));
7676
dialog.close();
7777
}));
7878
dialog.show_all();
@@ -119,7 +119,7 @@ fn build_ui(application: &gtk::Application) {
119119
dialog.connect_response(|dialog, response| {
120120
if response == ResponseType::Ok {
121121
let files = dialog.filenames();
122-
println!("Files: {:?}", files);
122+
println!("Files: {files:?}");
123123
}
124124
dialog.close();
125125
});
@@ -159,7 +159,7 @@ fn build_ui(application: &gtk::Application) {
159159
let keyval = key.keyval();
160160
let keystate = key.state();
161161

162-
println!("key pressed: {} / {:?}", keyval, keystate);
162+
println!("key pressed: {keyval} / {keystate:?}");
163163
println!("text: {}", entry.text());
164164

165165
if keystate.intersects(gdk::ModifierType::CONTROL_MASK) {

examples/icon_view/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn create_list_store_model() -> gtk::ListStore {
8484
);
8585
}
8686
Err(err) => {
87-
println!("Error: {}", err);
87+
println!("Error: {err}");
8888
process::exit(1);
8989
}
9090
}

examples/list_box_model/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn build_ui(application: &gtk::Application) {
178178
window.add(&vbox);
179179

180180
for i in 0..10 {
181-
model.append(&RowData::new(&format!("Name {}", i), i * 10));
181+
model.append(&RowData::new(&format!("Name {i}"), i * 10));
182182
}
183183

184184
window.show_all();

examples/multi_threading_context/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn build_ui(application: &gtk::Application) {
3535
// do long work
3636
thread::sleep(Duration::from_millis(50));
3737
// send result to channel
38-
tx.send(format!("#{} Text from another thread.", i))
38+
tx.send(format!("#{i} Text from another thread."))
3939
.expect("Couldn't send data to channel");
4040
// receiver will be run on the main thread
4141
}

examples/multi_window/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ fn create_sub_window(
104104
}),
105105
);
106106

107-
let button = gtk::Button::with_label(&format!("Notify main window with id {}!", id));
107+
let button = gtk::Button::with_label(&format!("Notify main window with id {id}!"));
108108
button.connect_clicked(glib::clone!(@weak main_window_entry => move |_| {
109109
// When the button is clicked, let's write it on the main window's entry!
110-
main_window_entry.buffer().set_text(&format!("sub window {} clicked", id));
110+
main_window_entry.buffer().set_text(&format!("sub window {id} clicked"));
111111
}));
112112
window.add(&button);
113113

examples/notebook/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn build_ui(application: &gtk::Application) {
2525
let mut notebook = Notebook::new();
2626

2727
for i in 1..4 {
28-
let title = format!("sheet {}", i);
28+
let title = format!("sheet {i}");
2929
let label = gtk::Label::new(Some(&*title));
3030
notebook.create_tab(&title, label.upcast());
3131
}

0 commit comments

Comments
 (0)