11# Implementations
22
3- An _ implementation_ is an item that associates items with an * implementing type* .
3+ An _ implementation_ is an item that associates items with an _ implementing type_ .
4+ Implementations are defined with the keyword ` impl ` and contain functions
5+ that belong to an instance of the type that is being implemented or to the
6+ type statically.
47
5- There are two types of implementations: inherent implementations and [ trait]
6- implementations.
8+ There are two types of implementations:
79
8- Implementations are defined with the keyword ` impl ` .
10+ - inherent implementations
11+ - [ trait] implementations
912
1013## Inherent Implementations
1114
1215An inherent implementation is defined as the sequence of the ` impl ` keyword,
1316generic type declarations, a path to a nominal type, a where clause, and a
1417bracketed set of associable items.
1518
16- The nominal type is called the * implementing type* and the associable items are
17- the * associated items* to the implementing type.
18-
19- Inherent implementations associate the associated items to the implementing
20- type.
19+ The nominal type is called the _ implementing type_ and the associable items are
20+ the _ associated items_ to the implementing type.
2121
22+ Inherent implementations associate the contained items to the implementing type.
2223The associated item has a path of a path to the implementing type followed by
23- the associate item's path component.
24-
25- Inherent implementations cannot contain associated type aliases.
26-
27- A type can have multiple inherent implementations.
24+ the associate item's path component. Inherent implementations cannot contain
25+ associated type aliases.
2826
29- The implementing type must be defined within the same crate.
27+ A type can also have multiple inherent implementations. An implementing type
28+ must be defined within the same crate as the original type definition.
3029
3130``` rust
3231struct Point {x : i32 , y : i32 }
@@ -43,14 +42,14 @@ my_point.log();
4342
4443## Trait Implementations
4544
46- A * trait implementation * is defined like an inherent implementation except that
45+ A _ trait implementation _ is defined like an inherent implementation except that
4746the optional generic type declarations is followed by a [ trait] followed
48- by the keyword ` for ` . <!-- To understand this, you have to back-reference to
49- the previous section. :( -->
47+ by the keyword ` for ` . Followed by a path to a nominal type.
5048
51- The trait is known as the * implemented trait * .
49+ <!-- To understand this, you have to back-reference to the previous section. :( -->
5250
53- The implementing type implements the implemented trait.
51+ The trait is known as the _ implemented trait_ . The implementing type
52+ implements the implemented trait.
5453
5554A trait implementation must define all non-default associated items declared
5655by the implemented trait, may redefine default associated items defined by the
@@ -105,18 +104,18 @@ be instantiable with the same set of types for the input type parameters. -->
105104The ` Orphan Check ` states that every trait implementation must meet either of
106105the following conditions:
107106
108- 1 . The trait being implemented is defined in the same crate.
107+ 1 . The trait being implemented is defined in the same crate.
109108
110- 2 . At least one of either ` Self ` or a generic type parameter of the trait must
111- meet the following grammar, where ` C ` is a nominal type defined
112- within the containing crate:
109+ 2 . At least one of either ` Self ` or a generic type parameter of the trait must
110+ meet the following grammar, where ` C ` is a nominal type defined
111+ within the containing crate:
113112
114- ``` ignore
115- T = C
116- | &C
117- | &mut C
118- | Box<C>
119- ```
113+ ``` ignore
114+ T = C
115+ | &C
116+ | &mut C
117+ | Box<C>
118+ ```
120119
121120## Generic Implementations
122121
0 commit comments