From 276749c2e45a5385d7177f60ff22f7db23c73322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cclaudio-code=E2=80=9D?= Date: Thu, 25 Jan 2024 18:05:27 -0300 Subject: [PATCH] examples: formatted the example code --- examples/tokio_async_request/main.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/tokio_async_request/main.rs b/examples/tokio_async_request/main.rs index a9d8aebdf36d..47d28a6bf7de 100644 --- a/examples/tokio_async_request/main.rs +++ b/examples/tokio_async_request/main.rs @@ -1,9 +1,9 @@ use glib::clone; use gtk::glib::once_cell::sync::Lazy; -use gtk::{glib, Application, ApplicationWindow}; use gtk::prelude::*; -use tokio::runtime::Runtime; +use gtk::{glib, Application, ApplicationWindow}; use serde::Deserialize; +use tokio::runtime::Runtime; #[derive(Deserialize, Debug)] pub struct Pokemon { @@ -35,10 +35,7 @@ impl PokemonClient { ("offset", current_offset.as_str()), ]; let url = reqwest::Url::parse_with_params(Self::URI, params).unwrap(); - let body = reqwest::get(url) - .await? - .json::() - .await?; + let body = reqwest::get(url).await?.json::().await?; self.page += 10; Ok(body.results) @@ -49,7 +46,9 @@ static RUNTIME: Lazy = Lazy::new(|| Runtime::new().expect("Setting up tokio runtime needs to succeed.")); fn main() -> glib::ExitCode { - let app = Application::builder().application_id("org.gtk_rs.pokemon.list").build(); + let app = Application::builder() + .application_id("org.gtk_rs.pokemon.list") + .build(); app.connect_activate(build_ui); app.run() } @@ -63,8 +62,7 @@ fn build_ui(app: &Application) { sender.send(pokemon_vec).await.expect("The channel needs to be open."); })); - let list_box = gtk::ListBox::builder() - .build(); + let list_box = gtk::ListBox::builder().build(); let scrolled_window = gtk::ScrolledWindow::builder() .hscrollbar_policy(gtk::PolicyType::Never) .min_content_width(360)