From 69a62ba227687d83f1fb7a6b1a22b0b6395c505c Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Mon, 24 Apr 2023 14:51:23 -0400 Subject: [PATCH] Add a bit about 'use' (#580) * Add a bit about 'use' * fix paths --- src/modules/filesystem.md | 12 ++++++++---- src/modules/paths.md | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/modules/filesystem.md b/src/modules/filesystem.md index 17057ffa..1afad010 100644 --- a/src/modules/filesystem.md +++ b/src/modules/filesystem.md @@ -28,11 +28,15 @@ These document the item that contains them -- in this case, a module. //! This module implements the garden, including a highly performant germination //! implementation. -/// Sow the given seed packets. -fn sow(seeds: Vec) { todo!() } +// Re-export types from this module. +pub use seeds::SeedPacket; +pub use garden::Garden; -// Harvest the produce in the garden that is ready. -fn harvest(garden: &mut Garden) { todo!() } +/// Sow the given seed packets. +pub fn sow(seeds: Vec) { todo!() } + +/// Harvest the produce in the garden that is ready. +pub fn harvest(garden: &mut Garden) { todo!() } ```
diff --git a/src/modules/paths.md b/src/modules/paths.md index 2a6f3d0f..bf4b9546 100644 --- a/src/modules/paths.md +++ b/src/modules/paths.md @@ -9,3 +9,11 @@ Paths are resolved as follows: 2. As an absolute path: * `crate::foo` refers to `foo` in the root of the current crate, * `bar::foo` refers to `foo` in the `bar` crate. + +A module can bring symbols from another module into scope with `use`. +You will typically see something like this at the top of each module: + +```rust,editable +use std::collections::HashSet; +use std::mem::transmute; +```