[gtk-web: 1/2] Update the rust example to add comments



commit 08d34736a164dff875751bf6d890e2bd6410e17a
Author: Jordan Petridis <jpetridis gnome org>
Date:   Wed Feb 19 18:30:50 2020 +0000

    Update the rust example to add comments

 _data/sample_codes.yml    | 22 +++++++++++-----------
 collections/_docs/rust.md | 22 +++++++++++-----------
 2 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/_data/sample_codes.yml b/_data/sample_codes.yml
index 8e57258..eb6239e 100644
--- a/_data/sample_codes.yml
+++ b/_data/sample_codes.yml
@@ -52,28 +52,28 @@ codes:
     snippet: |
       ```rust
       use gio::prelude::*;
-      use gtk::prelude::*;
       use glib::clone;
+      use gtk::prelude::*;
 
-      use std::env::args;
-
+      // When the application is launched…
       fn on_activate(application: &gtk::Application) {
+          // … create a new window …
           let window = gtk::ApplicationWindow::new(application);
+          // … with a button in it …
           let button = gtk::Button::new_with_label("Hello World!");
-
+          // … which closes the window when clicked
           button.connect_clicked(clone!(@weak window => move |_| window.destroy()));
-
           window.add(&button);
           window.show_all();
       }
 
       fn main() {
-          let application =
-              gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
-                  .expect("Initialization failed...");
-
-          application.connect_activate(|app| on_activate(app));
-          application.run(&args().collect::<Vec<_>>());
+          // Create a new application
+          let app = gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
+              .expect("Initialization failed...");
+          app.connect_activate(|app| on_activate(app));
+          // Run the application
+          app.run(&std::env::args().collect::<Vec<_>>());
       }
       ```
   - name: C
diff --git a/collections/_docs/rust.md b/collections/_docs/rust.md
index cb6bf51..c173ffe 100644
--- a/collections/_docs/rust.md
+++ b/collections/_docs/rust.md
@@ -17,28 +17,28 @@ There are also a growing number of examples and thorough tests of language featu
 
 ```rust
 use gio::prelude::*;
-use gtk::prelude::*;
 use glib::clone;
+use gtk::prelude::*;
 
-use std::env::args;
-
+// When the application is launched…
 fn on_activate(application: &gtk::Application) {
+    // … create a new window …
     let window = gtk::ApplicationWindow::new(application);
+    // … with a button in it …
     let button = gtk::Button::new_with_label("Hello World!");
-
+    // … which closes the window when clicked
     button.connect_clicked(clone!(@weak window => move |_| window.destroy()));
-
     window.add(&button);
     window.show_all();
 }
 
 fn main() {
-    let application =
-        gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
-            .expect("Initialization failed...");
-
-    application.connect_activate(|app| on_activate(app));
-    application.run(&args().collect::<Vec<_>>());
+    // Create a new application
+    let app = gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
+        .expect("Initialization failed...");
+    app.connect_activate(|app| on_activate(app));
+    // Run the application
+    app.run(&std::env::args().collect::<Vec<_>>());
 }
 ```
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]