From c33a9b2ca4578247a3a61fdfc8873e448a6d0349 Mon Sep 17 00:00:00 2001 From: Nicole L Date: Mon, 16 Dec 2024 08:42:22 -0800 Subject: [PATCH] Better demonstrate imports in modules exercise (#2514) The solution to the modules exercise changes how `Button`, `Window`, and `Label` are referenced, adding a `widgets::` prefix to them. This seems weird to me because the more idiomatic thing to do would be to import those types at the top of the file. Unless I'm missing a reason why the solutions is written the way it is, I think this is a good simplification. --- src/modules/solution.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/solution.md b/src/modules/solution.md index 12ed1c69..f835f709 100644 --- a/src/modules/solution.md +++ b/src/modules/solution.md @@ -177,13 +177,12 @@ impl Widget for Window { // ---- src/main.rs ---- mod widgets; -use widgets::Widget; +use widgets::{Button, Label, Widget, Window}; fn main() { - let mut window = widgets::Window::new("Rust GUI Demo 1.23"); - window - .add_widget(Box::new(widgets::Label::new("This is a small text GUI demo."))); - window.add_widget(Box::new(widgets::Button::new("Click me!"))); + let mut window = Window::new("Rust GUI Demo 1.23"); + window.add_widget(Box::new(Label::new("This is a small text GUI demo."))); + window.add_widget(Box::new(Button::new("Click me!"))); window.draw(); } ```