Skip to content

Commit 27e10fa

Browse files
committed
Incorporate PR feedback
1 parent 6f2924e commit 27e10fa

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/items/implementations.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,25 @@ the _associated items_ to the implementing type.
5252

5353
Inherent implementations associate the contained items to the
5454
implementing type. Inherent implementations can contain [associated
55-
functions] (including methods), [associated types], and [associated
56-
constants]. They cannot contain associated type aliases.
55+
functions] (including methods) and [associated constants]. They cannot
56+
contain associated type aliases.
5757

58-
[associated functions]: associated-items.html#associated-functions-and-methods
59-
[associated types]: associated-items.html#associated-types
60-
[associated constants]: associated-items.html#associated-constants
61-
62-
The path to an associated item is: any path to the implementing type,
58+
The [path] to an associated item is: any path to the implementing type,
6359
followed by the path to the associate item within the inherent
6460
implementation.
6561

66-
Note that the path to the module containing the inherent
67-
implementation does not allow access to the associate item, unless the
68-
implementing type is re-exported from the same location.
69-
7062
``` rust
7163
pub mod color {
7264
pub struct Color(pub u8, pub u8, pub u8);
65+
impl Color {
66+
pub const WHITE: Color = Color(255, 255, 255);
67+
}
7368
}
7469

7570
mod values {
7671
use super::color::Color;
7772
impl Color {
73+
7874
pub fn red() -> Color {
7975
Color(255, 0, 0)
8076
}
@@ -83,9 +79,10 @@ mod values {
8379

8480
pub use self::color::Color;
8581
fn main() {
86-
color::Color::red(); // actual path to the implementing type
82+
color::Color::WHITE; // actual path to the implementing type and impl in the same module
83+
color::Color::red(); // impl blocks in different modules are still accessed through a path to the type
8784
Color::red(); // rexported paths to the implementing type also work
88-
// bright_theme::Color::red(); // Does not work, because use in `theme` is not pub
85+
// values::Color::red(); // Does not work, because use in `values` is not pub
8986
}
9087
```
9188

@@ -225,9 +222,12 @@ attributes].
225222
[_Visibility_]: visibility-and-privacy.html
226223
[_WhereClause_]: items/generics.html#where-clauses
227224
[trait]: items/traits.html
225+
[associated functions]: associated-items.html#associated-functions-and-methods
226+
[associated constants]: associated-items.html#associated-constants
228227
[attributes]: attributes.html
229228
[`cfg`]: conditional-compilation.html
230229
[`deprecated`]: attributes.html#deprecation
231230
[`doc`]: attributes.html#documentation
231+
[path]: paths.html
232232
[the lint check attributes]: attributes.html#lint-check-attributes
233233
[Unsafe traits]: items/traits.html#unsafe-traits

0 commit comments

Comments
 (0)