@@ -574,7 +574,7 @@ of [attributes](#attributes) attached to it.
574
574
575
575
~~~~~~~~ {.ebnf .gram}
576
576
item : mod_item | fn_item | type_item | enum_item
577
- | res_item | iface_item | impl_item | foreign_mod_item ;
577
+ | res_item | trait_item | impl_item | foreign_mod_item ;
578
578
~~~~~~~~
579
579
580
580
An _ item_ is a component of a crate; some module items can be defined in crate
@@ -1259,7 +1259,7 @@ those methods for a specific type.
1259
1259
# type surface = int;
1260
1260
# type bounding_box = int;
1261
1261
1262
- iface shape {
1262
+ trait shape {
1263
1263
fn draw(surface);
1264
1264
fn bounding_box() -> bounding_box;
1265
1265
}
@@ -1275,7 +1275,7 @@ These appear after the name, using the same syntax used in [generic
1275
1275
functions] ( #generic-functions ) .
1276
1276
1277
1277
~~~~
1278
- iface seq<T> {
1278
+ trait seq<T> {
1279
1279
fn len() -> uint;
1280
1280
fn elt_at(n: uint) -> T;
1281
1281
fn iter(fn(T));
@@ -1290,7 +1290,7 @@ that have the parameter's type. For example:
1290
1290
1291
1291
~~~~
1292
1292
# type surface = int;
1293
- # iface shape { fn draw(surface); }
1293
+ # trait shape { fn draw(surface); }
1294
1294
1295
1295
fn draw_twice<T: shape>(surface: surface, sh: T) {
1296
1296
sh.draw(surface);
@@ -1301,33 +1301,33 @@ fn draw_twice<T: shape>(surface: surface, sh: T) {
1301
1301
Trait items also define a type with the same name as the
1302
1302
trait. Values of this type are created by
1303
1303
[ casting] ( #type-cast-expressions ) values (of a type for which an
1304
- implementation of the given interface is in scope) to the interface
1304
+ implementation of the given trait is in scope) to the trait
1305
1305
type.
1306
1306
1307
1307
~~~~
1308
- # iface shape { }
1308
+ # trait shape { }
1309
1309
# impl of shape for int { }
1310
1310
# let mycircle = 0;
1311
1311
1312
1312
let myshape: shape = mycircle as shape;
1313
1313
~~~~
1314
1314
1315
- The resulting value is a reference counted box containing the value
1315
+ The resulting value is a reference- counted box containing the value
1316
1316
that was cast along with information that identify the methods of the
1317
- implementation that was used. Values with an interface type can always
1318
- have methods of their interface called on them, and can be used to
1319
- instantiate type parameters that are bounded on their interface .
1317
+ implementation that was used. Values with a trait type can always
1318
+ have methods from their trait called on them, and can be used to
1319
+ instantiate type parameters that are bounded by their trait .
1320
1320
1321
1321
### Implementations
1322
1322
1323
- An _ implementation item_ provides an implementation of an
1324
- [ interface ] ( #traits ) for a type.
1323
+ An _ implementation item_ provides an implementation of a
1324
+ [ trait ] ( #traits ) for a type.
1325
1325
1326
1326
~~~~
1327
1327
# type point = {x: float, y: float};
1328
1328
# type surface = int;
1329
1329
# type bounding_box = {x: float, y: float, width: float, height: float};
1330
- # iface shape { fn draw(surface); fn bounding_box() -> bounding_box; }
1330
+ # trait shape { fn draw(surface); fn bounding_box() -> bounding_box; }
1331
1331
# fn do_draw_circle(s: surface, c: circle) { }
1332
1332
1333
1333
type circle = {radius: float, center: point};
@@ -1342,16 +1342,16 @@ impl circle_shape of shape for circle {
1342
1342
}
1343
1343
~~~~
1344
1344
1345
- This defines an implementation named ` circle_shape ` of interface
1345
+ This defines an implementation named ` circle_shape ` of trait
1346
1346
` shape ` for type ` circle ` . The name of the implementation is the name
1347
1347
by which it is imported and exported, but has no further significance.
1348
- It may be omitted to default to the name of the interface that was
1348
+ It may be omitted to default to the name of the trait that was
1349
1349
implemented. Implementation names do not conflict the way other names
1350
1350
do: multiple implementations with the same name may exist in a scope at
1351
1351
the same time.
1352
1352
1353
- It is possible to define an implementation without referencing an
1354
- interface. The methods in such an implementation can only be used
1353
+ It is possible to define an implementation without referring to a trait.
1354
+ The methods in such an implementation can only be used
1355
1355
statically (as direct calls on the values of the type that the
1356
1356
implementation targets). In such an implementation, the ` of ` clause is
1357
1357
not given, and the name is mandatory.
@@ -1365,17 +1365,17 @@ impl uint_loops for uint {
1365
1365
}
1366
1366
~~~~
1367
1367
1368
- _ When_ an interface is specified, all methods declared as part of the
1369
- interface must be present, with matching types and type parameter
1368
+ _ When_ a trait is specified, all methods declared as part of the
1369
+ trait must be present, with matching types and type parameter
1370
1370
counts, in the implementation.
1371
1371
1372
1372
An implementation can take type parameters, which can be different
1373
- from the type parameters taken by the interface it implements. They
1373
+ from the type parameters taken by the trait it implements. They
1374
1374
are written after the name of the implementation, or if that is not
1375
1375
specified, after the ` impl ` keyword.
1376
1376
1377
1377
~~~~
1378
- # iface seq<T> { }
1378
+ # trait seq<T> { }
1379
1379
1380
1380
impl <T> of seq<T> for ~[T] {
1381
1381
/* ... */
@@ -1540,7 +1540,7 @@ statement block. The declared name may denote a new slot or a new item.
1540
1540
1541
1541
An _ item declaration statement_ has a syntactic form identical to an
1542
1542
[ item] ( #items ) declaration within a module. Declaring an item -- a function,
1543
- enumeration, type, resource, interface , implementation or module -- locally
1543
+ enumeration, type, resource, trait , implementation or module -- locally
1544
1544
within a statement block is simply a way of restricting its scope to a narrow
1545
1545
region containing all of its uses; it is otherwise identical in meaning to
1546
1546
declaring the item outside the statement block.
@@ -2763,8 +2763,7 @@ Every trait item (see [traits](#traits)) defines a type with the same name
2763
2763
as the trait. For a trait ` T ` , cast expressions introduce values of type ` T ` :
2764
2764
2765
2765
~~~~~~~~
2766
- // doc extractor doesn't recognize trait -- fix it
2767
- iface printable {
2766
+ trait printable {
2768
2767
fn to_str() -> ~str;
2769
2768
}
2770
2769
@@ -2811,7 +2810,7 @@ impl item. It refers to the type of the implicit `self` argument. For
2811
2810
example, in:
2812
2811
2813
2812
~~~~~~
2814
- iface printable {
2813
+ trait printable {
2815
2814
fn to_str() -> ~str;
2816
2815
}
2817
2816
@@ -2848,7 +2847,7 @@ Sendable
2848
2847
Copyable
2849
2848
: This kind includes all types that can be copied. All types with
2850
2849
sendable kind are copyable, as are shared boxes, shared closures,
2851
- interface types, and structural types built out of these.
2850
+ trait types, and structural types built out of these.
2852
2851
Noncopyable
2853
2852
: [ Resource] ( #resources ) types, and every type that includes a
2854
2853
resource without storing it in a shared box, may not be copied.
@@ -2933,10 +2932,10 @@ shared or unique boxes, and/or references. Sharing memory between tasks can
2933
2932
only be accomplished using * unsafe* constructs, such as raw pointer
2934
2933
operations or calling C code.
2935
2934
2936
- When a task sends a value satisfying the ` send ` interface over a channel, it
2935
+ When a task sends a value that has the ` send ` trait over a channel, it
2937
2936
loses ownership of the value sent and can no longer refer to it. This is
2938
2937
statically guaranteed by the combined use of "move semantics" and the
2939
- compiler-checked _ meaning_ of the ` send ` interface : it is only instantiated
2938
+ compiler-checked _ meaning_ of the ` send ` trait : it is only instantiated
2940
2939
for (transitively) unique kinds of data constructor and pointers, never shared
2941
2940
pointers.
2942
2941
@@ -3117,7 +3116,7 @@ channels -- may lead to the same port.]
3117
3116
Each port and channel can carry only one type of message. The message type is
3118
3117
encoded as a parameter of the channel or port type. The message type of a
3119
3118
channel is equal to the message type of the port it is bound to. The types of
3120
- messages must satisfy the ` send ` built-in interface .
3119
+ messages must satisfy the ` send ` built-in trait .
3121
3120
3122
3121
Messages are generally sent asynchronously, with optional
3123
3122
rate-limiting on the transmit side. Each port contains a message
0 commit comments