Skip to content

Commit

Permalink
update modules exercise to still use the GUI library
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jan 10, 2024
1 parent b8ccf36 commit 3374416
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"src/std-types",
"src/std-traits",
"src/iterators",
"src/modules",
"src/testing",
"src/memory-management",
"src/smart-pointers",
Expand Down
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
- [Filesystem Hierarchy](modules/filesystem.md)
- [Visibility](modules/visibility.md)
- [`use`, `super`, `self`](modules/paths.md)
- [Exercise: Modules for the GUI Library](modules/exercise.md)
- [Exercise: Modules for a GUI Library](modules/exercise.md)
- [Solution](modules/solution.md)
- [Testing](testing.md)
- [Test Modules](testing/unit-tests.md)
Expand Down
27 changes: 17 additions & 10 deletions src/modules/exercise.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
---
minutes: 20
minutes: 15
---

# Exercise: Modules for the GUI Library
# Exercise: Modules for a GUI Library

In this exercise, you will reorganize the GUI Library exercise from the "Methods
and Traits" segment of the course into a collection of modules. It is typical to
put each type or set of closely-related types into its own module, so each
widget type should get its own module.
In this exercise, you will reorganize a small GUI Library implementation. This
library defines a `Widget` trait and a few implementations of that trait, as
well as a `main` function.

If you no longer have your version, that's fine - refer back to the
[provided solution](../methods-and-traits/solution.html).
It is typical to put each type or set of closely-related types into its own
module, so each widget type should get its own module.

## Cargo Setup

Expand All @@ -23,8 +22,16 @@ cd gui-modules
cargo run
```

Edit `src/main.rs` to add `mod` statements, and add additional files in the
`src` directory.
Edit the resulting `src/main.rs` to add `mod` statements, and add additional
files in the `src` directory.

## Source

Here's the single-module implementation of the GUI library:

```rust
{{#include exercise.rs:single-module}}
```

<details>

Expand Down

0 comments on commit 3374416

Please sign in to comment.