From 01ca752265ef2a1cf4af8174788e8bcefb64e235 Mon Sep 17 00:00:00 2001 From: GeeF Date: Wed, 11 Mar 2020 16:20:02 +0100 Subject: [PATCH 1/2] Fix and clarify section on re-export Section on use-visibility fixed to compile under Rust 2018, since they are not absolute paths by default anymore. --- src/items/use-declarations.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/items/use-declarations.md b/src/items/use-declarations.md index 6de253a19..6db98ab2e 100644 --- a/src/items/use-declarations.md +++ b/src/items/use-declarations.md @@ -60,21 +60,26 @@ default. Also like items, a `use` declaration can be public, if qualified by the `pub` keyword. Such a `use` declaration serves to _re-export_ a name. A public `use` declaration can therefore _redirect_ some public name to a different target definition: even a definition with a private canonical path, -inside a different module. If a sequence of such redirections form a cycle or -cannot be resolved unambiguously, they represent a compile-time error. +inside a different module. This allows to present an external interface to a +user of the crate that is different from the internal organization of the code. +If a sequence of such redirections form a cycle or cannot be resolved unambiguously, +they represent a compile-time error. An example of re-exporting: ```rust -# fn main() { } mod quux { - pub use quux::foo::{bar, baz}; - + pub use self::foo::{bar, baz}; pub mod foo { - pub fn bar() { } - pub fn baz() { } + pub fn bar() {} + pub fn baz() {} } } + +fn main() { + quux::bar(); + quux::baz(); +} ``` In this example, the module `quux` re-exports two public names defined in From 702bc78049313d8186ccc8753aad993dd2ae6485 Mon Sep 17 00:00:00 2001 From: GeeF Date: Fri, 13 Mar 2020 10:25:37 +0100 Subject: [PATCH 2/2] remove sentence --- src/items/use-declarations.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/items/use-declarations.md b/src/items/use-declarations.md index 6db98ab2e..89542ce6a 100644 --- a/src/items/use-declarations.md +++ b/src/items/use-declarations.md @@ -60,10 +60,8 @@ default. Also like items, a `use` declaration can be public, if qualified by the `pub` keyword. Such a `use` declaration serves to _re-export_ a name. A public `use` declaration can therefore _redirect_ some public name to a different target definition: even a definition with a private canonical path, -inside a different module. This allows to present an external interface to a -user of the crate that is different from the internal organization of the code. -If a sequence of such redirections form a cycle or cannot be resolved unambiguously, -they represent a compile-time error. +inside a different module. If a sequence of such redirections form a cycle or +cannot be resolved unambiguously, they represent a compile-time error. An example of re-exporting: