Skip to content

Commit 2b2454e

Browse files
committed
---
yaml --- r: 32406 b: refs/heads/dist-snap c: 10c5338 h: refs/heads/master v: v3
1 parent 3c833c5 commit 2b2454e

File tree

4 files changed

+69
-68
lines changed

4 files changed

+69
-68
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: f686896f60d901fd7f97add72fbc047691027baa
10+
refs/heads/dist-snap: 10c533861b38cf7c0533d3e28529bb49c917d2eb
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/doc/rust.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ grammar as double-quoted strings. Other tokens have exact rules given.
203203
The keywords in [crate files](#crate-files) are the following strings:
204204

205205
~~~~~~~~ {.keyword}
206-
import export use mod
206+
export use mod
207207
~~~~~~~~
208208

209209
The keywords in [source files](#source-files) are the following strings:
@@ -215,7 +215,7 @@ check const copy
215215
drop
216216
else enum export extern
217217
fail false fn for
218-
if impl import
218+
if impl
219219
let log loop
220220
match mod mut
221221
pure
@@ -447,7 +447,7 @@ expression context, the final namespace qualifier is omitted.
447447
Two examples of paths with type arguments:
448448

449449
~~~~
450-
# import std::map;
450+
# use std::map;
451451
# fn f() {
452452
# fn id<T:copy>(t: T) -> T { t }
453453
type t = map::hashmap<int,~str>; // Type arguments used in a type expression
@@ -619,8 +619,8 @@ or a *configuration* in Mesa.] A crate file describes:
619619
and copyright. These are used for linking, versioning and distributing
620620
crates.
621621
* The source-file and directory modules that make up the crate.
622-
* Any `use`, `import` or `export` [view items](#view-items) that apply to the
623-
anonymous module at the top-level of the crate's module tree.
622+
* Any `use`, `extern mod` or `export` [view items](#view-items) that apply to
623+
the anonymous module at the top-level of the crate's module tree.
624624

625625
An example of a crate file:
626626

@@ -636,7 +636,7 @@ An example of a crate file:
636636
author = "Jane Doe" ];
637637
638638
// Import a module.
639-
use std (ver = "1.0");
639+
extern mod std (ver = "1.0");
640640
641641
// Define some modules.
642642
#[path = "foo.rs"]
@@ -767,28 +767,28 @@ mod math {
767767
#### View items
768768

769769
~~~~~~~~ {.ebnf .gram}
770-
view_item : use_decl | import_decl | export_decl ;
770+
view_item : extern_mod_decl | use_decl | export_decl ;
771771
~~~~~~~~
772772

773773
A view item manages the namespace of a module; it does not define new items
774774
but simply changes the visibility of other items. There are several kinds of
775775
view item:
776776

777+
* [extern mod declarations](#extern-mod-declarations)
777778
* [use declarations](#use-declarations)
778-
* [import declarations](#import-declarations)
779779
* [export declarations](#export-declarations)
780780

781-
##### Use declarations
781+
##### Extern mod declarations
782782

783783
~~~~~~~~ {.ebnf .gram}
784-
use_decl : "use" ident [ '(' link_attrs ')' ] ? ;
784+
extern_mod_decl : "extern" "mod" ident [ '(' link_attrs ')' ] ? ;
785785
link_attrs : link_attr [ ',' link_attrs ] + ;
786786
link_attr : ident '=' literal ;
787787
~~~~~~~~
788788

789-
A _use declaration_ specifies a dependency on an external crate. The external
790-
crate is then imported into the declaring scope as the `ident` provided in the
791-
`use_decl`.
789+
An _extern mod declaration_ specifies a dependency on an external crate. The
790+
external crate is then imported into the declaring scope as the `ident`
791+
provided in the `extern_mod_decl`.
792792

793793
The external crate is resolved to a specific `soname` at compile time, and a
794794
runtime linkage requirement to that `soname` is passed to the linker for
@@ -798,51 +798,52 @@ compiler's library path and matching the `link_attrs` provided in the
798798
crate when it was compiled. If no `link_attrs` are provided, a default `name`
799799
attribute is assumed, equal to the `ident` given in the `use_decl`.
800800

801-
Two examples of `use` declarations:
801+
Two examples of `extern mod` declarations:
802802

803803
~~~~~~~~{.xfail-test}
804-
use pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841");
804+
extern mod pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841");
805805
806-
use std; // equivalent to: use std ( name = "std" );
806+
extern mod std; // equivalent to: extern mod std ( name = "std" );
807807
808-
use ruststd (name = "std"); // linking to 'std' under another name
808+
extern mod ruststd (name = "std"); // linking to 'std' under another name
809809
~~~~~~~~
810810

811-
##### Import declarations
811+
##### Use declarations
812812

813813
~~~~~~~~ {.ebnf .gram}
814-
import_decl : "import" ident [ '=' path
815-
| "::" path_glob ] ;
814+
use_decl : "use" ident [ '=' path
815+
| "::" path_glob ] ;
816816
817817
path_glob : ident [ "::" path_glob ] ?
818818
| '*'
819819
| '{' ident [ ',' ident ] * '}'
820820
~~~~~~~~
821821

822-
An _import declaration_ creates one or more local name bindings synonymous
823-
with some other [path](#paths). Usually an import declaration is used to
822+
A _use declaration_ creates one or more local name bindings synonymous
823+
with some other [path](#paths). Usually an use declaration is used to
824824
shorten the path required to refer to a module item.
825825

826-
*Note*: unlike many languages, Rust's `import` declarations do *not* declare
826+
*Note*: unlike many languages, Rust's `use` declarations do *not* declare
827827
linkage-dependency with external crates. Linkage dependencies are
828-
independently declared with [`use` declarations](#use-declarations).
828+
independently declared with
829+
[`extern mod` declarations](#extern-mod-declarations).
829830

830831
Imports support a number of "convenience" notations:
831832

832833
* Importing as a different name than the imported name, using the
833-
syntax `import x = p::q::r;`.
834+
syntax `use x = p::q::r;`.
834835
* Importing a list of paths differing only in final element, using
835-
the glob-like brace syntax `import a::b::{c,d,e,f};`
836+
the glob-like brace syntax `use a::b::{c,d,e,f};`
836837
* Importing all paths matching a given prefix, using the glob-like
837-
asterisk syntax `import a::b::*;`
838+
asterisk syntax `use a::b::*;`
838839

839840
An example of imports:
840841

841842
~~~~
842-
import foo = core::info;
843-
import core::float::sin;
844-
import core::str::{slice, to_upper};
845-
import core::option::Some;
843+
use foo = core::info;
844+
use core::float::sin;
845+
use core::str::{slice, to_upper};
846+
use core::option::Some;
846847
847848
fn main() {
848849
// Equivalent to 'log(core::info, core::float::sin(1.0));'
@@ -1053,7 +1054,7 @@ verify the semantics of the pure functions they write.
10531054
An example of a pure function that uses an unchecked block:
10541055

10551056
~~~~
1056-
# import std::list::*;
1057+
# use std::list::*;
10571058
10581059
fn pure_foldl<T, U: copy>(ls: List<T>, u: U, f: fn(&&T, &&U) -> U) -> U {
10591060
match ls {
@@ -1347,7 +1348,7 @@ Rust functions, with the exception that they may not have a body and are
13471348
instead terminated by a semi-colon.
13481349

13491350
~~~
1350-
# import libc::{c_char, FILE};
1351+
# use libc::{c_char, FILE};
13511352
# #[nolink]
13521353
13531354
extern mod c {

branches/dist-snap/doc/tutorial-ffi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ hexadecimal string and prints to standard output. If you have the
1313
OpenSSL libraries installed, it should 'just work'.
1414

1515
~~~~ {.xfail-test}
16-
use std;
17-
import libc::c_uint;
16+
extern mod std;
17+
use libc::c_uint;
1818
1919
extern mod crypto {
2020
fn SHA1(src: *u8, sz: c_uint, out: *u8) -> *u8;
@@ -208,8 +208,8 @@ This program uses the POSIX function `gettimeofday` to get a
208208
microsecond-resolution timer.
209209

210210
~~~~
211-
use std;
212-
import libc::c_ulonglong;
211+
extern mod std;
212+
use libc::c_ulonglong;
213213
214214
type timeval = {mut tv_sec: c_ulonglong,
215215
mut tv_usec: c_ulonglong};

branches/dist-snap/doc/tutorial.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ most vector functionality is provided by methods, so let's have a
12221222
brief look at a few common ones.
12231223

12241224
~~~
1225-
# import io::println;
1225+
# use io::println;
12261226
# enum crayon {
12271227
# almond, antique_brass, apricot,
12281228
# aquamarine, asparagus, atomic_tangerine,
@@ -1276,7 +1276,7 @@ Rust also supports _closures_, functions that can access variables in
12761276
the enclosing scope.
12771277

12781278
~~~~
1279-
# import println = io::println;
1279+
# use println = io::println;
12801280
fn call_closure_with_ten(b: fn(int)) { b(10); }
12811281
12821282
let captured_var = 20;
@@ -1434,7 +1434,7 @@ takes a final closure argument.
14341434
`do` is often used for task spawning.
14351435

14361436
~~~~
1437-
import task::spawn;
1437+
use task::spawn;
14381438
14391439
do spawn() || {
14401440
debug!("I'm a task, whatever");
@@ -1446,7 +1446,7 @@ argument lists back to back. Wouldn't it be great if they weren't
14461446
there?
14471447

14481448
~~~~
1449-
# import task::spawn;
1449+
# use task::spawn;
14501450
do spawn {
14511451
debug!("Kablam!");
14521452
}
@@ -1479,8 +1479,8 @@ fn each(v: ~[int], op: fn(int) -> bool) {
14791479
And using this function to iterate over a vector:
14801480

14811481
~~~~
1482-
# import each = vec::each;
1483-
# import println = io::println;
1482+
# use each = vec::each;
1483+
# use println = io::println;
14841484
each(~[2, 4, 8, 5, 16], |n| {
14851485
if n % 2 != 0 {
14861486
println(~"found odd number!");
@@ -1496,8 +1496,8 @@ out of the loop, you just write `break`. To skip ahead
14961496
to the next iteration, write `again`.
14971497

14981498
~~~~
1499-
# import each = vec::each;
1500-
# import println = io::println;
1499+
# use each = vec::each;
1500+
# use println = io::println;
15011501
for each(~[2, 4, 8, 5, 16]) |n| {
15021502
if n % 2 != 0 {
15031503
println(~"found odd number!");
@@ -1512,7 +1512,7 @@ normally allowed in closures, in a block that appears as the body of a
15121512
function, not just the loop body.
15131513

15141514
~~~~
1515-
# import each = vec::each;
1515+
# use each = vec::each;
15161516
fn contains(v: ~[int], elt: int) -> bool {
15171517
for each(v) |x| {
15181518
if (x == elt) { return true; }
@@ -1760,22 +1760,22 @@ that path is several modules deep). Rust allows you to import
17601760
identifiers at the top of a file, module, or block.
17611761

17621762
~~~~
1763-
use std;
1764-
import io::println;
1763+
extern mod std;
1764+
use io::println;
17651765
fn main() {
17661766
println(~"that was easy");
17671767
}
17681768
~~~~
17691769

1770-
It is also possible to import just the name of a module (`import
1770+
It is also possible to import just the name of a module (`use
17711771
std::list;`, then use `list::find`), to import all identifiers exported
1772-
by a given module (`import io::*`), or to import a specific set
1773-
of identifiers (`import math::{min, max, pi}`).
1772+
by a given module (`use io::*`), or to import a specific set
1773+
of identifiers (`use math::{min, max, pi}`).
17741774

17751775
You can rename an identifier when importing using the `=` operator:
17761776

17771777
~~~~
1778-
import prnt = io::println;
1778+
use prnt = io::println;
17791779
~~~~
17801780

17811781
## Exporting
@@ -1836,14 +1836,14 @@ fn main() {
18361836
}
18371837
~~~~
18381838

1839-
An `import` directive will only import into the namespaces for which
1839+
An `use` directive will only import into the namespaces for which
18401840
identifiers are actually found. Consider this example:
18411841

18421842
~~~~
18431843
type bar = uint;
18441844
mod foo { fn bar() {} }
18451845
mod baz {
1846-
import foo::bar;
1846+
use foo::bar;
18471847
const x: bar = 20u;
18481848
}
18491849
~~~~
@@ -2089,8 +2089,8 @@ Spawning a task is done using the various spawn functions in the
20892089
module `task`. Let's begin with the simplest one, `task::spawn()`:
20902090

20912091
~~~~
2092-
import task::spawn;
2093-
import io::println;
2092+
use task::spawn;
2093+
use io::println;
20942094
20952095
let some_value = 22;
20962096
@@ -2116,8 +2116,8 @@ receiving messages. The easiest way to create a pipe is to use
21162116
computations in parallel. We might write something like:
21172117

21182118
~~~~
2119-
import task::spawn;
2120-
import pipes::{stream, Port, Chan};
2119+
use task::spawn;
2120+
use pipes::{stream, Port, Chan};
21212121
21222122
let (chan, port) = stream();
21232123
@@ -2137,7 +2137,7 @@ Let's walk through this code line-by-line. The first line creates a
21372137
stream for sending and receiving integers:
21382138

21392139
~~~~ {.ignore}
2140-
# import pipes::stream;
2140+
# use pipes::stream;
21412141
let (chan, port) = stream();
21422142
~~~~
21432143

@@ -2146,8 +2146,8 @@ once it is complete. The channel will be used by the child to send a
21462146
message to the port. The next statement actually spawns the child:
21472147

21482148
~~~~
2149-
# import task::{spawn};
2150-
# import comm::{Port, Chan};
2149+
# use task::{spawn};
2150+
# use comm::{Port, Chan};
21512151
# fn some_expensive_computation() -> int { 42 }
21522152
# let port = Port();
21532153
# let chan = port.chan();
@@ -2167,7 +2167,7 @@ some other expensive computation and then waiting for the child's result
21672167
to arrive on the port:
21682168

21692169
~~~~
2170-
# import pipes::{stream, Port, Chan};
2170+
# use pipes::{stream, Port, Chan};
21712171
# fn some_other_expensive_computation() {}
21722172
# let (chan, port) = stream::<int>();
21732173
# chan.send(0);
@@ -2188,8 +2188,8 @@ the string in response. The child terminates when `0` is received.
21882188
Here is the function that implements the child task:
21892189

21902190
~~~~
2191-
# import std::comm::DuplexStream;
2192-
# import pipes::{Port, Chan};
2191+
# use std::comm::DuplexStream;
2192+
# use pipes::{Port, Chan};
21932193
fn stringifier(channel: DuplexStream<~str, uint>) {
21942194
let mut value: uint;
21952195
loop {
@@ -2211,9 +2211,9 @@ response itself is simply the strified version of the received value,
22112211
Here is the code for the parent task:
22122212

22132213
~~~~
2214-
# import std::comm::DuplexStream;
2215-
# import pipes::{Port, Chan};
2216-
# import task::spawn;
2214+
# use std::comm::DuplexStream;
2215+
# use pipes::{Port, Chan};
2216+
# use task::spawn;
22172217
# fn stringifier(channel: DuplexStream<~str, uint>) {
22182218
# let mut value: uint;
22192219
# loop {

0 commit comments

Comments
 (0)