@@ -1308,7 +1308,7 @@ type of the value is not required to ascribe to `Sync`.
1308
1308
### Traits
1309
1309
1310
1310
Traits are Rust's take on interfaces. A _ trait_ describes a collection of
1311
- methods and associated items (like associated types or associated constants).
1311
+ methods and associated items (like associated functions, types, or constants).
1312
1312
1313
1313
An example is the following trait ` Shape ` :
1314
1314
@@ -1323,14 +1323,15 @@ trait Shape {
1323
1323
1324
1324
This defines a trait with two methods, ` draw ` and ` bounding_box ` . These
1325
1325
methods can be invoked on any value whose type has an
1326
- [ implementation] ( #implementations ) of this trait. The [ method call
1326
+ [ implementation] ( #implementations ) of this trait, provided that the trait is in
1327
+ scope (via a ` use ` declaration if necessary). The [ method call
1327
1328
syntax] ( #method-call-expressions ) looks like this: ` value.bounding_box() ` .
1328
1329
1329
- Trait methods can be defined to take a [ ` self ` type] ( #self-types ) as a
1330
- parameter. In the example above, each method takes ` &self ` as its first
1331
- parameter. This is sometimes called the _ receiver_ of the method, and indicates
1332
- that for any type ` T ` implementing ` Shape ` , invoking one of the ` Shape ` methods
1333
- will immutably borrow the ` T ` value for the duration of the method call.
1330
+ Trait methods take a [ ` self ` type] ( #self-types ) as a parameter. In the example
1331
+ above, each method takes ` &self ` as its first parameter. This is sometimes
1332
+ called the _ receiver_ of the method, and indicates that for any type ` T `
1333
+ that implements ` Shape ` , invoking one of the ` Shape ` methods will immutably
1334
+ borrow the ` T ` value for the duration of the method call.
1334
1335
1335
1336
Traits can include default implementations of methods, as in:
1336
1337
@@ -1346,9 +1347,9 @@ Here the `baz` method has a default implementation, so types that implement
1346
1347
` Foo ` need only implement ` bar ` . It is also possible for implementing types
1347
1348
to override a method that has a default implementation.
1348
1349
1349
- It is not required that trait methods use a ` self ` type as a parameter. Methods
1350
- that lack ` self ` types are called _ static methods _ . A common use for static
1351
- methods is defining constructors, as the following example illustrates:
1350
+ Functions in a trait that do not take a ` self ` type as a parameter are called
1351
+ _ associated functions _ . A common use for associated functions is defining
1352
+ constructors, as the following example illustrates:
1352
1353
1353
1354
```
1354
1355
trait Num {
0 commit comments