From 2bc8a9be77f230d7691468f80599ae97f2495e0a Mon Sep 17 00:00:00 2001 From: gifnksm Date: Tue, 30 Jul 2013 07:08:54 +0900 Subject: [PATCH] doc: Update .pot files --- doc/po/rust.md.pot | 1884 +++++++++++++-------------- doc/po/rustpkg.md.pot | 60 +- doc/po/tutorial-borrowed-ptr.md.pot | 24 +- doc/po/tutorial-container.md.pot | 150 ++- doc/po/tutorial-ffi.md.pot | 98 +- doc/po/tutorial-macros.md.pot | 6 +- doc/po/tutorial-tasks.md.pot | 248 ++-- doc/po/tutorial.md.pot | 1153 ++++++++-------- 8 files changed, 1844 insertions(+), 1779 deletions(-) diff --git a/doc/po/rust.md.pot b/doc/po/rust.md.pot index 20ebb88c724..9bc3fb1d16e 100644 --- a/doc/po/rust.md.pot +++ b/doc/po/rust.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:47+0900\n" +"POT-Creation-Date: 2013-08-12 02:06+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -160,7 +160,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:74 doc/rust.md:417 doc/rust.md:487 +#: doc/rust.md:74 doc/rust.md:416 doc/rust.md:486 msgid "~~~~~~~~" msgstr "" @@ -454,27 +454,27 @@ msgid "The keywords are the following strings:" msgstr "" #. type: Plain text -#: doc/rust.md:223 +#: doc/rust.md:222 msgid "" -"~~~~~~~~ {.keyword} as break copy do else enum extern false fn for if impl " -"let loop match mod mut priv pub ref return self static struct super true " -"trait type unsafe use while ~~~~~~~~" +"~~~~~~~~ {.keyword} as break do else enum extern false fn for if impl let " +"loop match mod mut priv pub ref return self static struct super true trait " +"type unsafe use while ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:226 +#: doc/rust.md:225 msgid "" "Each of these keywords has special meaning in its grammar, and all of them " "are excluded from the `ident` rule." msgstr "" #. type: Plain text -#: doc/rust.md:228 +#: doc/rust.md:227 msgid "### Literals" msgstr "" #. type: Plain text -#: doc/rust.md:234 +#: doc/rust.md:233 msgid "" "A literal is an expression consisting of a single token, rather than a " "sequence of tokens, that immediately and directly denotes the value it " @@ -484,25 +484,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:238 +#: doc/rust.md:237 msgid "" "~~~~~~~~ {.ebnf .gram} literal : string_lit | char_lit | num_lit ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:240 +#: doc/rust.md:239 msgid "#### Character and string literals" msgstr "" #. type: Plain text -#: doc/rust.md:244 +#: doc/rust.md:243 msgid "" "~~~~~~~~ {.ebnf .gram} char_lit : '\\x27' char_body '\\x27' ; string_lit : " "'\"' string_body * '\"' ;" msgstr "" #. type: Plain text -#: doc/rust.md:247 +#: doc/rust.md:246 #, no-wrap msgid "" "char_body : non_single_quote\n" @@ -510,7 +510,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:250 +#: doc/rust.md:249 #, no-wrap msgid "" "string_body : non_double_quote\n" @@ -518,7 +518,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:256 +#: doc/rust.md:255 #, no-wrap msgid "" "common_escape : '\\x5c'\n" @@ -529,7 +529,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:264 +#: doc/rust.md:263 #, no-wrap msgid "" "hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'\n" @@ -542,7 +542,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:268 +#: doc/rust.md:267 msgid "" "A _character literal_ is a single Unicode character enclosed within two `U" "+0027` (single-quote) characters, with the exception of `U+0027` itself, " @@ -550,7 +550,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:272 +#: doc/rust.md:271 msgid "" "A _string literal_ is a sequence of any Unicode characters enclosed within " "two `U+0022` (double-quote) characters, with the exception of `U+0022` " @@ -558,7 +558,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:276 +#: doc/rust.md:275 msgid "" "Some additional _escapes_ are available in either character or string " "literals. An escape starts with a `U+005C` (`\\`) and continues with one of " @@ -566,7 +566,7 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:291 +#: doc/rust.md:290 msgid "" "An _8-bit codepoint escape_ escape starts with `U+0078` (`x`) and is " "followed by exactly two _hex digits_. It denotes the Unicode codepoint equal " @@ -574,7 +574,7 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:291 +#: doc/rust.md:290 msgid "" "A _16-bit codepoint escape_ starts with `U+0075` (`u`) and is followed by " "exactly four _hex digits_. It denotes the Unicode codepoint equal to the " @@ -582,7 +582,7 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:291 +#: doc/rust.md:290 msgid "" "A _32-bit codepoint escape_ starts with `U+0055` (`U`) and is followed by " "exactly eight _hex digits_. It denotes the Unicode codepoint equal to the " @@ -590,7 +590,7 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:291 +#: doc/rust.md:290 msgid "" "A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072` " "(`r`), or `U+0074` (`t`), denoting the unicode values `U+000A` (LF), `U" @@ -598,24 +598,24 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:291 +#: doc/rust.md:290 msgid "" "The _backslash escape_ is the character U+005C (`\\`) which must be escaped " "in order to denote *itself*." msgstr "" #. type: Plain text -#: doc/rust.md:293 +#: doc/rust.md:292 msgid "#### Number literals" msgstr "" #. type: Plain text -#: doc/rust.md:295 doc/rust.md:407 doc/rust.md:474 +#: doc/rust.md:294 doc/rust.md:406 doc/rust.md:473 msgid "~~~~~~~~ {.ebnf .gram}" msgstr "" #. type: Plain text -#: doc/rust.md:300 +#: doc/rust.md:299 #, no-wrap msgid "" "num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?\n" @@ -625,12 +625,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:302 +#: doc/rust.md:301 msgid "num_suffix : int_suffix | float_suffix ;" msgstr "" #. type: Plain text -#: doc/rust.md:306 +#: doc/rust.md:305 #, no-wrap msgid "" "int_suffix : 'u' int_suffix_size ?\n" @@ -639,7 +639,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:312 +#: doc/rust.md:311 msgid "" "float_suffix : [ exponent | '.' dec_lit exponent ? ] ? float_suffix_ty ? ; " "float_suffix_ty : 'f' [ '3' '2' | '6' '4' ] ; exponent : ['E' | 'e'] ['-' | " @@ -647,7 +647,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:316 +#: doc/rust.md:315 msgid "" "A _number literal_ is either an _integer literal_ or a _floating-point " "literal_. The grammar for recognizing the two kinds of literals is mixed, as " @@ -655,38 +655,38 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:318 +#: doc/rust.md:317 msgid "##### Integer literals" msgstr "" #. type: Plain text -#: doc/rust.md:320 +#: doc/rust.md:319 msgid "An _integer literal_ has one of three forms:" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:327 +#: doc/rust.md:326 msgid "" "A _decimal literal_ starts with a *decimal digit* and continues with any " "mixture of *decimal digits* and _underscores_." msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:327 +#: doc/rust.md:326 msgid "" "A _hex literal_ starts with the character sequence `U+0030` `U+0078` (`0x`) " "and continues as any mixture hex digits and underscores." msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:327 +#: doc/rust.md:326 msgid "" "A _binary literal_ starts with the character sequence `U+0030` `U+0062` " "(`0b`) and continues as any mixture binary digits and underscores." msgstr "" #. type: Plain text -#: doc/rust.md:331 +#: doc/rust.md:330 msgid "" "An integer literal may be followed (immediately, without any spaces) by an " "_integer suffix_, which changes the type of the literal. There are two kinds " @@ -694,13 +694,13 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:337 +#: doc/rust.md:336 msgid "" "The `i` and `u` suffixes give the literal type `int` or `uint`, respectively." msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:337 +#: doc/rust.md:336 msgid "" "Each of the signed and unsigned machine types `u8`, `i8`, `u16`, `i16`, " "`u32`, `i32`, `u64` and `i64` give the literal the corresponding machine " @@ -708,7 +708,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:344 +#: doc/rust.md:343 msgid "" "The type of an _unsuffixed_ integer literal is determined by type " "inference. If a integer type can be _uniquely_ determined from the " @@ -719,12 +719,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:346 +#: doc/rust.md:345 msgid "Examples of integer literals of various forms:" msgstr "" #. type: Plain text -#: doc/rust.md:351 +#: doc/rust.md:350 #, no-wrap msgid "" "~~~~\n" @@ -734,7 +734,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:357 +#: doc/rust.md:356 #, no-wrap msgid "" "123u; // type uint\n" @@ -745,29 +745,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:359 +#: doc/rust.md:358 msgid "##### Floating-point literals" msgstr "" #. type: Plain text -#: doc/rust.md:361 +#: doc/rust.md:360 msgid "A _floating-point literal_ has one of two forms:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:366 +#: doc/rust.md:365 msgid "" "Two _decimal literals_ separated by a period character `U+002E` (`.`), with " "an optional _exponent_ trailing after the second decimal literal." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:366 +#: doc/rust.md:365 msgid "A single _decimal literal_ followed by an _exponent_." msgstr "" #. type: Plain text -#: doc/rust.md:373 +#: doc/rust.md:372 msgid "" "By default, a floating-point literal is of type `float`. A floating-point " "literal may be followed (immediately, without any spaces) by a _floating-" @@ -777,12 +777,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:375 +#: doc/rust.md:374 msgid "Examples of floating-point literals of various forms:" msgstr "" #. type: Plain text -#: doc/rust.md:383 +#: doc/rust.md:382 #, no-wrap msgid "" "~~~~\n" @@ -795,12 +795,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:385 +#: doc/rust.md:384 msgid "##### Unit and boolean literals" msgstr "" #. type: Plain text -#: doc/rust.md:388 +#: doc/rust.md:387 msgid "" "The _unit value_, the only value of the type that has the same name, is " "written as `()`. The two values of the boolean type are written `true` and " @@ -808,12 +808,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:390 +#: doc/rust.md:389 msgid "### Symbols" msgstr "" #. type: Plain text -#: doc/rust.md:396 +#: doc/rust.md:395 #, no-wrap msgid "" "~~~~~~~~ {.ebnf .gram}\n" @@ -824,7 +824,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:402 +#: doc/rust.md:401 msgid "" "Symbols are a general class of printable [token](#tokens) that play " "structural roles in a variety of grammar productions. They are catalogued " @@ -835,12 +835,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:405 +#: doc/rust.md:404 msgid "## Paths" msgstr "" #. type: Plain text -#: doc/rust.md:411 +#: doc/rust.md:410 #, no-wrap msgid "" "expr_path : ident [ \"::\" expr_path_tail ] + ;\n" @@ -849,7 +849,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:415 +#: doc/rust.md:414 #, no-wrap msgid "" "type_path : ident [ type_path_tail ] + ;\n" @@ -858,7 +858,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:422 +#: doc/rust.md:421 msgid "" "A _path_ is a sequence of one or more path components _logically_ separated " "by a namespace qualifier (`::`). If a path consists of only one component, " @@ -867,7 +867,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:426 +#: doc/rust.md:425 msgid "" "Every item has a _canonical path_ within its crate, but the path naming an " "item is only meaningful within a given crate. There is no global namespace " @@ -876,17 +876,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:428 +#: doc/rust.md:427 msgid "Two examples of simple paths consisting of only identifier components:" msgstr "" #. type: Plain text -#: doc/rust.md:433 +#: doc/rust.md:432 msgid "~~~~{.ignore} x; x::y::z; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:440 +#: doc/rust.md:439 msgid "" "Path components are usually [identifiers](#identifiers), but the trailing " "component of a path may be an angle-bracket-enclosed list of type arguments. " @@ -897,18 +897,18 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:442 +#: doc/rust.md:441 msgid "Two examples of paths with type arguments:" msgstr "" #. type: Plain text -#: doc/rust.md:451 +#: doc/rust.md:450 #, no-wrap msgid "" "~~~~\n" "# use std::hashmap::HashMap;\n" "# fn f() {\n" -"# fn id(t: T) -> T { t }\n" +"# fn id(t: T) -> T { t }\n" "type t = HashMap; // Type arguments used in a type expression\n" "let x = id::(10); // Type arguments used in a call expression\n" "# }\n" @@ -916,12 +916,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:453 +#: doc/rust.md:452 msgid "# Syntax extensions" msgstr "" #. type: Plain text -#: doc/rust.md:458 +#: doc/rust.md:457 msgid "" "A number of minor features of Rust are not central enough to have their own " "syntax, and yet are not implementable as functions. Instead, they are given " @@ -930,60 +930,60 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`fmt!` : format data into a string" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`env!` : look up an environment variable's value at compile time" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`stringify!` : pretty-print the Rust expression given as an argument" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`proto!` : define a protocol for inter-task communication" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`include!` : include the Rust expression in the given file" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`include_str!` : include the contents of the given file as a string" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "" "`include_bin!` : include the contents of the given file as a binary blob" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:467 +#: doc/rust.md:466 msgid "`error!`, `warn!`, `info!`, `debug!` : provide diagnostic information." msgstr "" #. type: Plain text -#: doc/rust.md:470 +#: doc/rust.md:469 msgid "" "All of the above extensions, with the exception of `proto!`, are expressions " "with values. `proto!` is an item, defining a new name." msgstr "" #. type: Plain text -#: doc/rust.md:472 +#: doc/rust.md:471 msgid "## Macros" msgstr "" #. type: Plain text -#: doc/rust.md:485 +#: doc/rust.md:484 #, no-wrap msgid "" "expr_macro_rules : \"macro_rules\" '!' ident '(' macro_rule * ')'\n" @@ -999,7 +999,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:491 +#: doc/rust.md:490 msgid "" "User-defined syntax extensions are called \"macros\", and the `macro_rules` " "syntax extension defines them. Currently, user-defined macros can expand to " @@ -1007,14 +1007,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:494 +#: doc/rust.md:493 msgid "" "(A `sep_token` is any token other than `*` and `+`. A `non_special_token` " "is any token other than a delimiter or `$`.)" msgstr "" #. type: Plain text -#: doc/rust.md:500 +#: doc/rust.md:499 msgid "" "The macro expander looks up macro invocations by name, and tries each macro " "rule in turn. It transcribes the first successful match. Matching and " @@ -1023,12 +1023,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:502 +#: doc/rust.md:501 msgid "### Macro By Example" msgstr "" #. type: Plain text -#: doc/rust.md:505 +#: doc/rust.md:504 msgid "" "The macro expander matches and transcribes every token that does not begin " "with a `$` literally, including delimiters. For parsing reasons, delimiters " @@ -1036,7 +1036,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:511 +#: doc/rust.md:510 msgid "" "In the matcher, `$` _name_ `:` _designator_ matches the nonterminal in the " "Rust syntax named by _designator_. Valid designators are `item`, `block`, " @@ -1047,7 +1047,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:520 +#: doc/rust.md:519 msgid "" "In both the matcher and transcriber, the Kleene star-like operator indicates " "repetition. The Kleene star operator consists of `$` and parens, optionally " @@ -1060,7 +1060,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:526 +#: doc/rust.md:525 msgid "" "The rules for transcription of these repetitions are called \"Macro By " "Example\". Essentially, one \"layer\" of repetition is discharged at a " @@ -1070,7 +1070,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:534 +#: doc/rust.md:533 msgid "" "When Macro By Example encounters a repetition, it examines all of the `$` " "_name_ s that occur in its body. At the \"current layer\", they all must " @@ -1081,24 +1081,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:536 +#: doc/rust.md:535 msgid "Nested repetitions are allowed." msgstr "" #. type: Plain text -#: doc/rust.md:538 +#: doc/rust.md:537 msgid "### Parsing limitations" msgstr "" #. type: Plain text -#: doc/rust.md:541 +#: doc/rust.md:540 msgid "" "The parser used by the macro system is reasonably powerful, but the parsing " "of Rust syntax is restricted in two ways:" msgstr "" #. type: Plain text -#: doc/rust.md:547 +#: doc/rust.md:546 #, no-wrap msgid "" "1. The parser will always parse as much as possible. If it attempts to match\n" @@ -1109,40 +1109,40 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:550 +#: doc/rust.md:549 msgid "## Syntax extensions useful for the macro author" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:555 +#: doc/rust.md:554 msgid "`log_syntax!` : print out the arguments at compile time" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:555 +#: doc/rust.md:554 msgid "" "`trace_macros!` : supply `true` or `false` to enable or disable macro " "expansion logging" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:555 +#: doc/rust.md:554 msgid "`stringify!` : turn the identifier argument into a string literal" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:555 +#: doc/rust.md:554 msgid "" "`concat_idents!` : create a new identifier by concatenating the arguments" msgstr "" #. type: Plain text -#: doc/rust.md:557 +#: doc/rust.md:556 msgid "# Crates and source files" msgstr "" #. type: Plain text -#: doc/rust.md:564 +#: doc/rust.md:563 msgid "" "Rust is a *compiled* language. Its semantics obey a *phase distinction* " "between compile-time and run-time. Those semantic rules that have a *static " @@ -1155,7 +1155,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:570 +#: doc/rust.md:569 msgid "" "The compilation model centres on artifacts called _crates_. Each " "compilation processes a single crate in source form, and if successful, " @@ -1166,7 +1166,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:574 +#: doc/rust.md:573 msgid "" "A _crate_ is a unit of compilation and linking, as well as versioning, " "distribution and runtime loading. A crate contains a _tree_ of nested " @@ -1177,17 +1177,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:579 +#: doc/rust.md:577 msgid "" "The Rust compiler is always invoked with a single source file as input, and " "always produces a single output crate. The processing of that source file " -"may result in other source files being loaded as modules. Source files " -"typically have the extension `.rs` but, by convention, source files that " -"represent crates have the extension `.rc`, called *crate files*." +"may result in other source files being loaded as modules. Source files have " +"the extension `.rs`." msgstr "" #. type: Plain text -#: doc/rust.md:584 +#: doc/rust.md:582 msgid "" "A Rust source file describes a module, the name and location of which -- in " "the module tree of the current crate -- are defined from outside the source " @@ -1196,7 +1195,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:589 +#: doc/rust.md:587 msgid "" "Each source file contains a sequence of zero or more `item` definitions, and " "may optionally begin with any number of `attributes` that apply to the " @@ -1205,7 +1204,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:595 +#: doc/rust.md:593 #, no-wrap msgid "" "~~~~~~~~\n" @@ -1216,24 +1215,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:600 +#: doc/rust.md:598 msgid "" "// Additional metadata attributes #[ desc = \"Project X\" ]; #[ license = " "\"BSD\" ]; #[ author = \"Jane Doe\" ];" msgstr "" #. type: Plain text -#: doc/rust.md:603 +#: doc/rust.md:601 msgid "// Specify the output type #[ crate_type = \"lib\" ];" msgstr "" #. type: Plain text -#: doc/rust.md:607 +#: doc/rust.md:605 msgid "// Turn on a warning #[ warn(non_camel_case_types) ]; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:610 +#: doc/rust.md:608 msgid "" "A crate that contains a `main` function can be compiled to an executable. " "If a `main` function is present, its return type must be [`unit`](#primitive-" @@ -1241,24 +1240,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:613 +#: doc/rust.md:611 msgid "# Items and attributes" msgstr "" #. type: Plain text -#: doc/rust.md:616 +#: doc/rust.md:614 msgid "" "Crates contain [items](#items), each of which may have some number of " "[attributes](#attributes) attached to it." msgstr "" #. type: Plain text -#: doc/rust.md:618 +#: doc/rust.md:616 msgid "## Items" msgstr "" #. type: Plain text -#: doc/rust.md:623 +#: doc/rust.md:621 #, no-wrap msgid "" "~~~~~~~~ {.ebnf .gram}\n" @@ -1268,7 +1267,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:629 +#: doc/rust.md:627 msgid "" "An _item_ is a component of a crate; some module items can be defined in " "crate files, but most are defined in source files. Items are organized " @@ -1278,59 +1277,59 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:632 +#: doc/rust.md:630 msgid "" "Items are entirely determined at compile-time, generally remain fixed during " "execution, and may reside in read-only memory." msgstr "" #. type: Plain text -#: doc/rust.md:634 +#: doc/rust.md:632 msgid "There are several kinds of item:" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[modules](#modules)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[functions](#functions)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[type definitions](#type-definitions)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[structures](#structures)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[enumerations](#enumerations)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[static items](#static-items)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[traits](#traits)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:643 +#: doc/rust.md:641 msgid "[implementations](#implementations)" msgstr "" #. type: Plain text -#: doc/rust.md:653 +#: doc/rust.md:651 msgid "" "Some items form an implicit scope for the declaration of sub-items. In other " "words, within a function or module, declarations of items can (in many " @@ -1344,12 +1343,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:655 +#: doc/rust.md:653 msgid "### Type Parameters" msgstr "" #. type: Plain text -#: doc/rust.md:664 +#: doc/rust.md:662 msgid "" "All items except modules may be *parameterized* by type. Type parameters are " "given as a comma-separated list of identifiers enclosed in angle brackets " @@ -1365,19 +1364,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:666 +#: doc/rust.md:664 msgid "### Modules" msgstr "" #. type: Plain text -#: doc/rust.md:671 +#: doc/rust.md:669 msgid "" "~~~~~~~~ {.ebnf .gram} mod_item : \"mod\" ident ( ';' | '{' mod '}' ); mod : " "[ view_item | item ] * ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:676 +#: doc/rust.md:674 msgid "" "A module is a container for zero or more [view items](#view-items) and zero " "or more [items](#items). The view items manage the visibility of the items " @@ -1386,7 +1385,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:680 +#: doc/rust.md:678 msgid "" "A _module item_ is a module, surrounded in braces, named, and prefixed with " "the keyword `mod`. A module item introduces a new, named module into the " @@ -1394,12 +1393,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:682 +#: doc/rust.md:680 msgid "An example of a module:" msgstr "" #. type: Plain text -#: doc/rust.md:700 +#: doc/rust.md:698 #, no-wrap msgid "" "~~~~~~~~\n" @@ -1422,7 +1421,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:705 +#: doc/rust.md:703 msgid "" "Modules and types share the same namespace. Declaring a named type that has " "the same name as a module in scope is forbidden: that is, a type definition, " @@ -1431,7 +1430,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:710 +#: doc/rust.md:708 msgid "" "A module without a body is loaded from an external file, by default with the " "same name as the module, plus the `.rs` extension. When a nested submodule " @@ -1440,12 +1439,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:714 +#: doc/rust.md:712 msgid "~~~ {.xfail-test} // Load the `vec` module from `vec.rs` mod vec;" msgstr "" #. type: Plain text -#: doc/rust.md:720 +#: doc/rust.md:718 #, no-wrap msgid "" "mod task {\n" @@ -1456,14 +1455,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:723 +#: doc/rust.md:721 msgid "" "The directories and files used for loading external file modules can be " "influenced with the `path` attribute." msgstr "" #. type: Plain text -#: doc/rust.md:732 +#: doc/rust.md:730 #, no-wrap msgid "" "~~~ {.xfail-test}\n" @@ -1477,18 +1476,18 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:734 +#: doc/rust.md:732 msgid "#### View items" msgstr "" #. type: Plain text -#: doc/rust.md:738 +#: doc/rust.md:736 msgid "" "~~~~~~~~ {.ebnf .gram} view_item : extern_mod_decl | use_decl ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:742 +#: doc/rust.md:740 msgid "" "A view item manages the namespace of a module. View items do not define new " "items, but rather, simply change other items' visibility. There are several " @@ -1496,30 +1495,30 @@ msgid "" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:745 +#: doc/rust.md:743 msgid "[`extern mod` declarations](#extern-mod-declarations)" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:745 +#: doc/rust.md:743 msgid "[`use` declarations](#use-declarations)" msgstr "" #. type: Plain text -#: doc/rust.md:747 +#: doc/rust.md:745 msgid "##### Extern mod declarations" msgstr "" #. type: Plain text -#: doc/rust.md:753 +#: doc/rust.md:751 msgid "" "~~~~~~~~ {.ebnf .gram} extern_mod_decl : \"extern\" \"mod\" ident [ '(' " -"link_attrs ')' ] ? ; link_attrs : link_attr [ ',' link_attrs ] + ; " -"link_attr : ident '=' literal ; ~~~~~~~~" +"link_attrs ')' ] ? [ '=' string_lit ] ? ; link_attrs : link_attr [ ',' " +"link_attrs ] + ; link_attr : ident '=' literal ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:757 +#: doc/rust.md:755 msgid "" "An _`extern mod` declaration_ specifies a dependency on an external crate. " "The external crate is then bound into the declaring scope as the `ident` " @@ -1531,45 +1530,64 @@ msgstr "" msgid "" "The external crate is resolved to a specific `soname` at compile time, and a " "runtime linkage requirement to that `soname` is passed to the linker for " -"loading at runtime. The `soname` is resolved at compile time by scanning the " -"compiler's library path and matching the `link_attrs` provided in the " +"loading at runtime. The `soname` is resolved at compile time by scanning " +"the compiler's library path and matching the `link_attrs` provided in the " "`use_decl` against any `#link` attributes that were declared on the external " -"crate when it was compiled. If no `link_attrs` are provided, a default " +"crate when it was compiled. If no `link_attrs` are provided, a default " "`name` attribute is assumed, equal to the `ident` given in the `use_decl`." msgstr "" #. type: Plain text -#: doc/rust.md:767 -msgid "Three examples of `extern mod` declarations:" +#: doc/rust.md:775 +msgid "" +"Optionally, an identifier in an `extern mod` declaration may be followed by " +"an equals sign, then a string literal denoting a relative path on the " +"filesystem. This path should exist in one of the directories in the Rust " +"path, which by default contains the `.rust` subdirectory of the current " +"directory and each of its parents, as well as any directories in the colon-" +"separated (or semicolon-separated on Windows) list of paths that is the " +"`RUST_PATH` environment variable. The meaning of `extern mod a = \"b/c/d\";" +"`, supposing that `/a` is in the RUST_PATH, is that the name `a` should be " +"taken as a reference to the crate whose absolute location is `/a/b/c/d`." msgstr "" #. type: Plain text -#: doc/rust.md:770 +#: doc/rust.md:777 +msgid "Four examples of `extern mod` declarations:" +msgstr "" + +#. type: Plain text +#: doc/rust.md:780 msgid "" "~~~~~~~~{.xfail-test} extern mod pcre (uuid = \"54aba0f8-" "a7b1-4beb-92f1-4cf625264841\");" msgstr "" #. type: Plain text -#: doc/rust.md:772 +#: doc/rust.md:782 msgid "" "extern mod extra; // equivalent to: extern mod extra ( name = \"extra\" );" msgstr "" #. type: Plain text -#: doc/rust.md:775 +#: doc/rust.md:784 msgid "" "extern mod rustextra (name = \"extra\"); // linking to 'extra' under another " -"name ~~~~~~~~" +"name" msgstr "" #. type: Plain text -#: doc/rust.md:777 +#: doc/rust.md:787 +msgid "extern mod complicated_mod = \"some-file/in/the-rust/path\"; ~~~~~~~~" +msgstr "" + +#. type: Plain text +#: doc/rust.md:789 msgid "##### Use declarations" msgstr "" #. type: Plain text -#: doc/rust.md:781 +#: doc/rust.md:793 #, no-wrap msgid "" "~~~~~~~~ {.ebnf .gram}\n" @@ -1578,7 +1596,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:786 +#: doc/rust.md:798 #, no-wrap msgid "" "path_glob : ident [ \"::\" path_glob ] ?\n" @@ -1588,7 +1606,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:790 +#: doc/rust.md:802 msgid "" "A _use declaration_ creates one or more local name bindings synonymous with " "some other [path](#paths). Usually a `use` declaration is used to shorten " @@ -1596,7 +1614,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:794 +#: doc/rust.md:806 #, no-wrap msgid "" "*Note*: Unlike in many languages,\n" @@ -1605,43 +1623,43 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:796 +#: doc/rust.md:808 msgid "Use declarations support a number of convenient shortcuts:" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:801 +#: doc/rust.md:813 msgid "" "Rebinding the target name as a new local name, using the syntax `use x = p::" "q::r;`." msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:801 +#: doc/rust.md:813 msgid "" "Simultaneously binding a list of paths differing only in their final " "element, using the glob-like brace syntax `use a::b::{c,d,e,f};`" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:801 +#: doc/rust.md:813 msgid "" "Binding all paths matching a given prefix, using the asterisk wildcard " "syntax `use a::b::*;`" msgstr "" #. type: Plain text -#: doc/rust.md:803 +#: doc/rust.md:815 msgid "An example of `use` declarations:" msgstr "" #. type: Plain text -#: doc/rust.md:807 +#: doc/rust.md:819 msgid "~~~~ use std::num::sin; use std::option::{Some, None};" msgstr "" #. type: Plain text -#: doc/rust.md:811 +#: doc/rust.md:823 #, no-wrap msgid "" "fn main() {\n" @@ -1650,7 +1668,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:816 +#: doc/rust.md:828 #, no-wrap msgid "" " // Equivalent to 'info!(~[std::option::Some(1.0), std::option::None]);'\n" @@ -1660,7 +1678,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:824 +#: doc/rust.md:836 msgid "" "Like items, `use` declarations are private to the containing module, by " "default. Also like items, a `use` declaration can be public, if qualified " @@ -1673,7 +1691,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:830 +#: doc/rust.md:842 #, no-wrap msgid "" "An example of re-exporting:\n" @@ -1684,7 +1702,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:837 +#: doc/rust.md:849 #, no-wrap msgid "" " pub mod foo {\n" @@ -1696,14 +1714,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:839 +#: doc/rust.md:851 msgid "" "In this example, the module `quux` re-exports all of the public names " "defined in `foo`." msgstr "" #. type: Plain text -#: doc/rust.md:842 +#: doc/rust.md:854 msgid "" "Also note that the paths contained in `use` items are relative to the crate " "root. So, in the previous example, the `use` refers to `quux::foo::*`, and " @@ -1711,12 +1729,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:844 +#: doc/rust.md:856 msgid "### Functions" msgstr "" #. type: Plain text -#: doc/rust.md:848 +#: doc/rust.md:860 msgid "" "A _function item_ defines a sequence of [statements](#statements) and an " "optional final [expression](#expressions), along with a name and a set of " @@ -1727,7 +1745,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:853 +#: doc/rust.md:865 msgid "" "A function may also be copied into a first class *value*, in which case the " "value has the corresponding [*function type*](#function-types), and can be " @@ -1736,7 +1754,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:859 +#: doc/rust.md:871 msgid "" "Every control path in a function logically ends with a `return` expression " "or a diverging expression. If the outermost block of a function has a value-" @@ -1746,12 +1764,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:861 +#: doc/rust.md:873 msgid "An example of a function:" msgstr "" #. type: Plain text -#: doc/rust.md:867 +#: doc/rust.md:879 #, no-wrap msgid "" "~~~~\n" @@ -1762,24 +1780,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:870 +#: doc/rust.md:882 msgid "" "As with `let` bindings, function arguments are irrefutable patterns, so any " "pattern that is valid in a let binding is also valid as an argument." msgstr "" #. type: Plain text -#: doc/rust.md:874 +#: doc/rust.md:886 msgid "~~~ fn first((value, _): (int, int)) -> int { value } ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:877 +#: doc/rust.md:889 msgid "#### Generic functions" msgstr "" #. type: Plain text -#: doc/rust.md:882 +#: doc/rust.md:894 msgid "" "A _generic function_ allows one or more _parameterized types_ to appear in " "its signature. Each type parameter must be explicitly declared, in an angle-" @@ -1787,7 +1805,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:893 +#: doc/rust.md:905 #, no-wrap msgid "" "~~~~ {.xfail-test}\n" @@ -1803,14 +1821,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:896 +#: doc/rust.md:908 msgid "" "Inside the function signature and body, the name of the type parameter can " "be used as a type name." msgstr "" #. type: Plain text -#: doc/rust.md:902 +#: doc/rust.md:914 msgid "" "When a generic function is referenced, its type is instantiated based on the " "context of the reference. For example, calling the `iter` function defined " @@ -1819,7 +1837,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:907 +#: doc/rust.md:919 msgid "" "The type parameters can also be explicitly supplied in a trailing [path]" "(#paths) component after the function name. This might be necessary if there " @@ -1828,33 +1846,32 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:912 +#: doc/rust.md:923 msgid "" "Since a parameter type is opaque to the generic function, the set of " "operations that can be performed on it is limited. Values of parameter type " -"can always be moved, but they can only be copied when the parameter is given " -"a [`Copy` bound](#type-kinds)." +"can only be moved, not copied." msgstr "" #. type: Plain text -#: doc/rust.md:916 -msgid "~~~~ fn id(x: T) -> T { x } ~~~~" +#: doc/rust.md:927 +msgid "~~~~ fn id(x: T) -> T { x } ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:920 +#: doc/rust.md:931 msgid "" "Similarly, [trait](#traits) bounds can be specified for type parameters to " "allow methods with that trait to be called on values of that type." msgstr "" #. type: Plain text -#: doc/rust.md:923 +#: doc/rust.md:934 msgid "#### Unsafe functions" msgstr "" #. type: Plain text -#: doc/rust.md:926 +#: doc/rust.md:937 msgid "" "Unsafe functions are those containing unsafe operations that are not " "contained in an [`unsafe` block](#unsafe-blocks). Such a function must be " @@ -1862,7 +1879,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:929 +#: doc/rust.md:940 msgid "" "Unsafe operations are those that potentially violate the memory-safety " "guarantees of Rust's static semantics. Specifically, the following " @@ -1870,27 +1887,27 @@ msgid "" msgstr "" #. type: Bullet: ' - ' -#: doc/rust.md:933 +#: doc/rust.md:944 msgid "Dereferencing a [raw pointer](#pointer-types)." msgstr "" #. type: Bullet: ' - ' -#: doc/rust.md:933 +#: doc/rust.md:944 msgid "Casting a [raw pointer](#pointer-types) to a safe pointer type." msgstr "" #. type: Bullet: ' - ' -#: doc/rust.md:933 +#: doc/rust.md:944 msgid "Calling an unsafe function." msgstr "" #. type: Plain text -#: doc/rust.md:935 +#: doc/rust.md:946 msgid "##### Unsafe blocks" msgstr "" #. type: Plain text -#: doc/rust.md:939 +#: doc/rust.md:950 msgid "" "A block of code can also be prefixed with the `unsafe` keyword, to permit a " "sequence of unsafe operations in an otherwise-safe function. This facility " @@ -1902,19 +1919,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:942 +#: doc/rust.md:953 msgid "#### Diverging functions" msgstr "" #. type: Plain text -#: doc/rust.md:945 +#: doc/rust.md:956 msgid "" "A special kind of function can be declared with a `!` character where the " "output slot type would normally be. For example:" msgstr "" #. type: Plain text -#: doc/rust.md:952 +#: doc/rust.md:963 #, no-wrap msgid "" "~~~~\n" @@ -1926,7 +1943,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:959 +#: doc/rust.md:970 msgid "" "We call such functions \"diverging\" because they never return a value to " "the caller. Every control path in a diverging function must end with a `fail!" @@ -1937,7 +1954,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:965 +#: doc/rust.md:976 msgid "" "It might be necessary to declare a diverging function because as mentioned " "previously, the typechecker checks that every control path in a function " @@ -1947,12 +1964,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:968 +#: doc/rust.md:979 msgid "~~~~ # fn my_err(s: &str) -> ! { fail!() }" msgstr "" #. type: Plain text -#: doc/rust.md:978 +#: doc/rust.md:989 #, no-wrap msgid "" "fn f(i: int) -> int {\n" @@ -1967,7 +1984,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:986 +#: doc/rust.md:997 msgid "" "This will not compile without the `!` annotation on `my_err`, since the " "`else` branch of the conditional in `f` does not return an `int`, as " @@ -1979,12 +1996,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:989 +#: doc/rust.md:1000 msgid "#### Extern functions" msgstr "" #. type: Plain text -#: doc/rust.md:996 +#: doc/rust.md:1007 msgid "" "Extern functions are part of Rust's foreign function interface, providing " "the opposite functionality to [external blocks](#external-blocks). Whereas " @@ -1995,37 +2012,37 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1000 +#: doc/rust.md:1011 msgid "~~~ extern fn new_vec() -> ~[int] { ~[] } ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1003 +#: doc/rust.md:1014 msgid "" "Extern functions may not be called from Rust code, but Rust code may take " "their value as a raw `u8` pointer." msgstr "" #. type: Plain text -#: doc/rust.md:1008 +#: doc/rust.md:1019 msgid "" "~~~ # extern fn new_vec() -> ~[int] { ~[] } let fptr: *u8 = new_vec; ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1012 +#: doc/rust.md:1023 msgid "" "The primary motivation for extern functions is to create callbacks for " "foreign functions that expect to receive function pointers." msgstr "" #. type: Plain text -#: doc/rust.md:1014 +#: doc/rust.md:1025 msgid "### Type definitions" msgstr "" #. type: Plain text -#: doc/rust.md:1018 +#: doc/rust.md:1029 msgid "" "A _type definition_ defines a new name for an existing [type](#types). Type " "definitions are declared with the keyword `type`. Every value has a single, " @@ -2033,32 +2050,32 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1024 +#: doc/rust.md:1035 msgid "Whether the value is composed of sub-values or is indivisible." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1024 +#: doc/rust.md:1035 msgid "Whether the value represents textual or numerical information." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1024 +#: doc/rust.md:1035 msgid "Whether the value represents integral or floating-point information." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1024 +#: doc/rust.md:1035 msgid "The sequence of memory operations required to access the value." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1024 +#: doc/rust.md:1035 msgid "The [kind](#type-kinds) of the type." msgstr "" #. type: Plain text -#: doc/rust.md:1027 +#: doc/rust.md:1038 msgid "" "For example, the type `(u8, u8)` defines the set of immutable values that " "are composite pairs, each containing two unsigned 8-bit integers accessed by " @@ -2067,45 +2084,45 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1029 +#: doc/rust.md:1040 msgid "### Structures" msgstr "" #. type: Plain text -#: doc/rust.md:1031 +#: doc/rust.md:1042 msgid "" "A _structure_ is a nominal [structure type](#structure-types) defined with " "the keyword `struct`." msgstr "" #. type: Plain text -#: doc/rust.md:1033 +#: doc/rust.md:1044 msgid "An example of a `struct` item and its use:" msgstr "" #. type: Plain text -#: doc/rust.md:1039 +#: doc/rust.md:1050 msgid "" "~~~~ struct Point {x: int, y: int} let p = Point {x: 10, y: 11}; let px: int " "= p.x; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1042 +#: doc/rust.md:1053 msgid "" "A _tuple structure_ is a nominal [tuple type](#tuple-types), also defined " "with the keyword `struct`. For example:" msgstr "" #. type: Plain text -#: doc/rust.md:1048 +#: doc/rust.md:1059 msgid "" "~~~~ struct Point(int, int); let p = Point(10, 11); let px: int = match p " "{ Point(x, _) => x }; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1052 +#: doc/rust.md:1063 msgid "" "A _unit-like struct_ is a structure without any fields, defined by leaving " "off the list of fields entirely. Such types will have a single value, just " @@ -2114,17 +2131,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1057 +#: doc/rust.md:1068 msgid "~~~~ struct Cookie; let c = [Cookie, Cookie, Cookie, Cookie]; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1059 +#: doc/rust.md:1070 msgid "### Enumerations" msgstr "" #. type: Plain text -#: doc/rust.md:1062 +#: doc/rust.md:1073 msgid "" "An _enumeration_ is a simultaneous definition of a nominal [enumerated type]" "(#enumerated-types) as well as a set of *constructors*, that can be used to " @@ -2132,17 +2149,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1064 +#: doc/rust.md:1075 msgid "Enumerations are declared with the keyword `enum`." msgstr "" #. type: Plain text -#: doc/rust.md:1066 +#: doc/rust.md:1077 msgid "An example of an `enum` item and its use:" msgstr "" #. type: Plain text -#: doc/rust.md:1072 +#: doc/rust.md:1083 #, no-wrap msgid "" "~~~~\n" @@ -2153,12 +2170,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1076 +#: doc/rust.md:1087 msgid "let mut a: Animal = Dog; a = Cat; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1083 +#: doc/rust.md:1094 #, no-wrap msgid "" "Enumeration constructors can have either named or unnamed fields:\n" @@ -2170,33 +2187,33 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1087 +#: doc/rust.md:1098 msgid "" "let mut a: Animal = Dog(~\"Cocoa\", 37.2); a = Cat{ name: ~\"Spotty\", " "weight: 2.7 }; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1090 +#: doc/rust.md:1101 msgid "" "In this example, `Cat` is a _struct-like enum variant_, whereas `Dog` is " "simply called an enum variant." msgstr "" #. type: Plain text -#: doc/rust.md:1092 +#: doc/rust.md:1103 msgid "### Static items" msgstr "" #. type: Plain text -#: doc/rust.md:1096 +#: doc/rust.md:1107 msgid "" "~~~~~~~~ {.ebnf .gram} static_item : \"static\" ident ':' type '=' expr " "';' ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1103 +#: doc/rust.md:1114 msgid "" "A *static item* is a named _constant value_ stored in the global data " "section of a crate. Immutable static items are stored in the read-only data " @@ -2208,7 +2225,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1108 +#: doc/rust.md:1119 msgid "" "Static items must be explicitly typed. The type may be ```bool```, " "```char```, a number, or a type derived from those primitive types. The " @@ -2217,19 +2234,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1112 +#: doc/rust.md:1123 msgid "~~~~ static BIT1: uint = 1 << 0; static BIT2: uint = 1 << 1;" msgstr "" #. type: Plain text -#: doc/rust.md:1115 +#: doc/rust.md:1126 msgid "" "static BITS: [uint, ..2] = [BIT1, BIT2]; static STRING: &'static str = " "\"bitstring\";" msgstr "" #. type: Plain text -#: doc/rust.md:1120 +#: doc/rust.md:1131 #, no-wrap msgid "" "struct BitsNStrings<'self> {\n" @@ -2239,7 +2256,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1126 +#: doc/rust.md:1137 #, no-wrap msgid "" "static bits_n_strings: BitsNStrings<'static> = BitsNStrings {\n" @@ -2250,17 +2267,81 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1128 +#: doc/rust.md:1139 +msgid "#### Mutable statics" +msgstr "" + +#. type: Plain text +#: doc/rust.md:1147 +msgid "" +"If a static item is declared with the ```mut``` keyword, then it is allowed " +"to be modified by the program. One of Rust's goals is to make concurrency " +"bugs hard to run into, and this is obviously a very large source of race " +"conditions or other bugs. For this reason, an ```unsafe``` block is required " +"when either reading or writing a mutable static variable. Care should be " +"taken to ensure that modifications to a mutable static are safe with respect " +"to other tasks running in the same process." +msgstr "" + +#. type: Plain text +#: doc/rust.md:1150 +msgid "" +"Mutable statics are still very useful, however. They can be used with C " +"libraries and can also be bound from C libraries (in an ```extern``` block)." +msgstr "" + +#. type: Plain text +#: doc/rust.md:1153 +msgid "~~~ # fn atomic_add(_: &mut uint, _: uint) -> uint { 2 }" +msgstr "" + +#. type: Plain text +#: doc/rust.md:1155 +msgid "static mut LEVELS: uint = 0;" +msgstr "" + +#. type: Plain text +#: doc/rust.md:1163 +#, no-wrap +msgid "" +"// This violates the idea of no shared state, and this doesn't internally\n" +"// protect against races, so this function is `unsafe`\n" +"unsafe fn bump_levels_unsafe1() -> uint {\n" +" let ret = LEVELS;\n" +" LEVELS += 1;\n" +" return ret;\n" +"}\n" +msgstr "" + +#. type: Plain text +#: doc/rust.md:1170 +#, no-wrap +msgid "" +"// Assuming that we have an atomic_add function which returns the old value,\n" +"// this function is \"safe\" but the meaning of the return value may not be what\n" +"// callers expect, so it's still marked as `unsafe`\n" +"unsafe fn bump_levels_unsafe2() -> uint {\n" +" return atomic_add(&mut LEVELS, 1);\n" +"}\n" +msgstr "" + +#. type: Plain text +#: doc/rust.md:1172 +msgid "~~~" +msgstr "" + +#. type: Plain text +#: doc/rust.md:1174 msgid "### Traits" msgstr "" #. type: Plain text -#: doc/rust.md:1130 +#: doc/rust.md:1176 msgid "A _trait_ describes a set of method types." msgstr "" #. type: Plain text -#: doc/rust.md:1135 +#: doc/rust.md:1181 msgid "" "Traits can include default implementations of methods, written in terms of " "some unknown [`self` type](#self-types); the `self` type may either be " @@ -2268,19 +2349,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1137 +#: doc/rust.md:1183 msgid "" "Traits are implemented for specific types through separate [implementations]" "(#implementations)." msgstr "" #. type: Plain text -#: doc/rust.md:1141 +#: doc/rust.md:1187 msgid "~~~~ # type Surface = int; # type BoundingBox = int;" msgstr "" #. type: Plain text -#: doc/rust.md:1147 +#: doc/rust.md:1193 #, no-wrap msgid "" "trait Shape {\n" @@ -2291,7 +2372,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1151 +#: doc/rust.md:1197 msgid "" "This defines a trait with two methods. All values that have " "[implementations](#implementations) of this trait in scope can have their " @@ -2300,7 +2381,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1154 +#: doc/rust.md:1200 msgid "" "Type parameters can be specified for a trait to make it generic. These " "appear after the trait name, using the same syntax used in [generic " @@ -2308,7 +2389,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1162 +#: doc/rust.md:1208 #, no-wrap msgid "" "~~~~\n" @@ -2321,7 +2402,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1168 +#: doc/rust.md:1214 msgid "" "Generic functions may use traits as _bounds_ on their type parameters. This " "will have two effects: only types that have the trait may instantiate the " @@ -2330,12 +2411,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1172 +#: doc/rust.md:1218 msgid "~~~~ # type Surface = int; # trait Shape { fn draw(&self, Surface); }" msgstr "" #. type: Plain text -#: doc/rust.md:1178 +#: doc/rust.md:1224 #, no-wrap msgid "" "fn draw_twice(surface: Surface, sh: T) {\n" @@ -2346,7 +2427,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1183 +#: doc/rust.md:1229 msgid "" "Traits also define an [object type](#object-types) with the same name as the " "trait. Values of this type are created by [casting](#type-cast-expressions) " @@ -2355,17 +2436,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1188 +#: doc/rust.md:1234 msgid "~~~~ # trait Shape { } # impl Shape for int { } # let mycircle = 0;" msgstr "" #. type: Plain text -#: doc/rust.md:1191 +#: doc/rust.md:1237 msgid "let myshape: @Shape = @mycircle as @Shape; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1197 +#: doc/rust.md:1243 msgid "" "The resulting value is a managed box containing the value that was cast, " "along with information that identifies the methods of the implementation " @@ -2375,7 +2456,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1205 +#: doc/rust.md:1251 msgid "" "Trait methods may be static, which means that they lack a `self` argument. " "This means that they can only be called with function call syntax (`f(x)`) " @@ -2385,7 +2466,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1215 +#: doc/rust.md:1261 #, no-wrap msgid "" "~~~~\n" @@ -2400,19 +2481,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1217 +#: doc/rust.md:1263 msgid "Traits may inherit from other traits. For example, in" msgstr "" #. type: Plain text -#: doc/rust.md:1222 +#: doc/rust.md:1268 msgid "" "~~~~ trait Shape { fn area() -> float; } trait Circle : Shape { fn radius() -" "> float; } ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1227 +#: doc/rust.md:1273 msgid "" "the syntax `Circle : Shape` means that types that implement `Circle` must " "also have an implementation for `Shape`. Multiple supertraits are separated " @@ -2423,7 +2504,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1231 doc/tutorial.md:2177 +#: doc/rust.md:1277 doc/tutorial.md:2176 msgid "" "In type-parameterized functions, methods of the supertrait may be called on " "values of subtrait-bound type parameters. Refering to the previous example " @@ -2431,7 +2512,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1240 doc/tutorial.md:2186 +#: doc/rust.md:1286 doc/tutorial.md:2185 #, no-wrap msgid "" "~~~\n" @@ -2445,12 +2526,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1242 doc/tutorial.md:2188 +#: doc/rust.md:1288 doc/tutorial.md:2187 msgid "Likewise, supertrait methods may also be called on trait objects." msgstr "" #. type: Plain text -#: doc/rust.md:1249 +#: doc/rust.md:1295 msgid "" "~~~ {.xfail-test} # trait Shape { fn area(&self) -> float; } # trait " "Circle : Shape { fn radius(&self) -> float; } # impl Shape for int { fn " @@ -2459,31 +2540,31 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1253 +#: doc/rust.md:1299 msgid "" "let mycircle: Circle = @mycircle as @Circle; let nonsense = mycircle." "radius() * mycircle.area(); ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1255 +#: doc/rust.md:1301 msgid "### Implementations" msgstr "" #. type: Plain text -#: doc/rust.md:1257 +#: doc/rust.md:1303 msgid "" "An _implementation_ is an item that implements a [trait](#traits) for a " "specific type." msgstr "" #. type: Plain text -#: doc/rust.md:1259 +#: doc/rust.md:1305 msgid "Implementations are defined with the keyword `impl`." msgstr "" #. type: Plain text -#: doc/rust.md:1266 +#: doc/rust.md:1312 msgid "" "~~~~ # struct Point {x: float, y: float}; # type Surface = int; # struct " "BoundingBox {x: float, y: float, width: float, height: float}; # trait Shape " @@ -2492,7 +2573,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1271 +#: doc/rust.md:1317 #, no-wrap msgid "" "struct Circle {\n" @@ -2502,7 +2583,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1281 +#: doc/rust.md:1327 #, no-wrap msgid "" "impl Shape for Circle {\n" @@ -2517,7 +2598,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1288 +#: doc/rust.md:1334 msgid "" "It is possible to define an implementation without referring to a trait. " "The methods in such an implementation can only be used as direct calls on " @@ -2529,14 +2610,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1292 +#: doc/rust.md:1338 msgid "" "When a trait _is_ specified in an `impl`, all methods declared as part of " "the trait must be implemented, with matching types and type parameter counts." msgstr "" #. type: Plain text -#: doc/rust.md:1296 +#: doc/rust.md:1342 msgid "" "An implementation can take type parameters, which can be different from the " "type parameters taken by the trait it implements. Implementation parameters " @@ -2544,12 +2625,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1299 +#: doc/rust.md:1345 msgid "~~~~ # trait Seq { }" msgstr "" #. type: Plain text -#: doc/rust.md:1307 +#: doc/rust.md:1353 #, no-wrap msgid "" "impl Seq for ~[T] {\n" @@ -2562,19 +2643,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1309 +#: doc/rust.md:1355 msgid "### External blocks" msgstr "" #. type: Plain text -#: doc/rust.md:1314 +#: doc/rust.md:1360 msgid "" "~~~ {.ebnf .gram} extern_block_item : \"extern\" '{' extern_block '} ; " "extern_block : [ foreign_fn ] * ; ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1318 +#: doc/rust.md:1364 msgid "" "External blocks form the basis for Rust's foreign function interface. " "Declarations in an external block describe symbols in external, non-Rust " @@ -2582,7 +2663,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1323 +#: doc/rust.md:1369 msgid "" "Functions within external blocks are declared in the same way as other Rust " "functions, with the exception that they may not have a body and are instead " @@ -2590,12 +2671,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1327 +#: doc/rust.md:1373 msgid "~~~ # use std::libc::{c_char, FILE}; # #[nolink]" msgstr "" #. type: Plain text -#: doc/rust.md:1332 +#: doc/rust.md:1378 #, no-wrap msgid "" "extern {\n" @@ -2605,7 +2686,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1337 +#: doc/rust.md:1383 msgid "" "Functions within external blocks may be called by Rust code, just like " "functions defined in Rust. The Rust compiler automatically translates " @@ -2613,14 +2694,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1340 +#: doc/rust.md:1386 msgid "" "A number of [attributes](#attributes) control the behavior of external " "blocks." msgstr "" #. type: Plain text -#: doc/rust.md:1344 +#: doc/rust.md:1390 msgid "" "By default external blocks assume that the library they are calling uses the " "standard C \"cdecl\" ABI. Other ABIs may be specified using the `abi` " @@ -2628,25 +2709,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1350 +#: doc/rust.md:1396 msgid "" "~~~{.xfail-test} // Interface to the Windows API #[abi = \"stdcall\"] extern " "{ } ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1352 +#: doc/rust.md:1398 msgid "" "The `link_name` attribute allows the name of the library to be specified." msgstr "" #. type: Plain text -#: doc/rust.md:1357 +#: doc/rust.md:1403 msgid "~~~{.xfail-test} #[link_name = \"crypto\"] extern { } ~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1363 +#: doc/rust.md:1409 msgid "" "The `nolink` attribute tells the Rust compiler not to do any linking for the " "external block. This is particularly useful for creating external blocks " @@ -2655,12 +2736,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1365 +#: doc/rust.md:1411 msgid "## Attributes" msgstr "" #. type: Plain text -#: doc/rust.md:1372 +#: doc/rust.md:1418 #, no-wrap msgid "" "~~~~~~~~{.ebnf .gram}\n" @@ -2672,7 +2753,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1378 +#: doc/rust.md:1424 msgid "" "Static entities in Rust -- crates, modules and items -- may have " "_attributes_ applied to them. ^[Attributes in Rust are modeled on Attributes " @@ -2682,25 +2763,25 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1382 +#: doc/rust.md:1428 msgid "A single identifier, the attribute name" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1382 +#: doc/rust.md:1428 msgid "" "An identifier followed by the equals sign '=' and a literal, providing a key/" "value pair" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1382 +#: doc/rust.md:1428 msgid "" "An identifier followed by a parenthesized list of sub-attribute arguments" msgstr "" #. type: Plain text -#: doc/rust.md:1385 +#: doc/rust.md:1431 msgid "" "Attributes terminated by a semi-colon apply to the entity that the attribute " "is declared within. Attributes that are not terminated by a semi-colon apply " @@ -2708,19 +2789,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1387 +#: doc/rust.md:1433 msgid "An example of attributes:" msgstr "" #. type: Plain text -#: doc/rust.md:1391 +#: doc/rust.md:1437 msgid "" "~~~~~~~~{.xfail-test} // General metadata applied to the enclosing module or " "crate. #[license = \"BSD\"];" msgstr "" #. type: Plain text -#: doc/rust.md:1397 +#: doc/rust.md:1443 #, no-wrap msgid "" "// A function marked as a unit test\n" @@ -2731,7 +2812,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1403 +#: doc/rust.md:1449 #, no-wrap msgid "" "// A conditionally-compiled module\n" @@ -2742,14 +2823,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1408 +#: doc/rust.md:1454 msgid "" "// A lint attribute used to suppress a warning/error " "#[allow(non_camel_case_types)] pub type int8_t = i8; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1411 +#: doc/rust.md:1457 msgid "" "> **Note:** In future versions of Rust, user-provided extensions to the " "compiler will be able to interpret attributes. > When this facility is " @@ -2758,74 +2839,74 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1414 +#: doc/rust.md:1460 msgid "" "At present, only the Rust compiler interprets attributes, so all attribute " "names are effectively reserved. Some significant attributes include:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "The `doc` attribute, for documenting code in-place." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "" "The `cfg` attribute, for conditional-compilation by build-configuration." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "" "The `lang` attribute, for custom definitions of traits and functions that " "are known to the Rust compiler (see [Language items](#language-items))." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "The `link` attribute, for describing linkage metadata for a crate." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "The `test` attribute, for marking functions as unit tests." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "" "The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint " "checks (see [Lint check attributes](#lint-check-attributes))." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "" "The `deriving` attribute, for automatically generating implementations of " "certain traits." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1425 +#: doc/rust.md:1471 msgid "" "The `static_assert` attribute, for asserting that a static bool is true at " "compiletime" msgstr "" #. type: Plain text -#: doc/rust.md:1427 +#: doc/rust.md:1473 msgid "" "Other attributes may be added or removed during development of the language." msgstr "" #. type: Plain text -#: doc/rust.md:1429 +#: doc/rust.md:1475 msgid "### Lint check attributes" msgstr "" #. type: Plain text -#: doc/rust.md:1433 +#: doc/rust.md:1479 msgid "" "A lint check names a potentially undesirable coding pattern, such as " "unreachable code or omitted documentation, for the static entity to which " @@ -2833,22 +2914,22 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1435 +#: doc/rust.md:1481 msgid "For any lint check `C`:" msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:1442 +#: doc/rust.md:1488 msgid "`warn(C)` warns about violations of `C` but continues compilation," msgstr "" #. type: Bullet: ' * ' -#: doc/rust.md:1442 +#: doc/rust.md:1488 msgid "`deny(C)` signals an error after encountering a violation of `C`," msgstr "" #. type: Plain text -#: doc/rust.md:1442 +#: doc/rust.md:1488 #, no-wrap msgid "" " * `allow(C)` overrides the check for `C` so that violations will go\n" @@ -2858,14 +2939,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1445 +#: doc/rust.md:1491 msgid "" "The lint checks supported by the compiler can be found via `rustc -W help`, " "along with their default settings." msgstr "" #. type: Plain text -#: doc/rust.md:1451 +#: doc/rust.md:1497 #, no-wrap msgid "" "~~~{.xfail-test}\n" @@ -2876,7 +2957,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1455 +#: doc/rust.md:1501 #, no-wrap msgid "" " // Missing documentation signals a warning here\n" @@ -2885,7 +2966,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1461 +#: doc/rust.md:1507 #, no-wrap msgid "" " // Missing documentation signals an error here\n" @@ -2896,17 +2977,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1464 +#: doc/rust.md:1510 msgid "" "This example shows how one can use `allow` and `warn` to toggle a particular " "check on and off." msgstr "" #. type: Plain text -#: doc/rust.md:1472 +#: doc/rust.md:1518 #, no-wrap msgid "" -"~~~\n" +"~~~{.xfail-test}\n" "#[warn(missing_doc)]\n" "mod m2{\n" " #[allow(missing_doc)]\n" @@ -2916,7 +2997,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1478 +#: doc/rust.md:1524 #, no-wrap msgid "" " // Missing documentation signals a warning here,\n" @@ -2927,7 +3008,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1483 +#: doc/rust.md:1529 #, no-wrap msgid "" " // Missing documentation signals a warning here\n" @@ -2937,14 +3018,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1486 +#: doc/rust.md:1532 msgid "" "This example shows how one can use `forbid` to disallow uses of `allow` for " "that lint check." msgstr "" #. type: Plain text -#: doc/rust.md:1496 +#: doc/rust.md:1542 #, no-wrap msgid "" "~~~{.xfail-test}\n" @@ -2959,12 +3040,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1498 +#: doc/rust.md:1544 msgid "### Language items" msgstr "" #. type: Plain text -#: doc/rust.md:1504 +#: doc/rust.md:1550 msgid "" "Some primitive Rust operations are defined in Rust code, rather than being " "implemented directly in C or assembly language. The definitions of these " @@ -2974,7 +3055,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1511 +#: doc/rust.md:1557 #, no-wrap msgid "" "~~~ {.xfail-test}\n" @@ -2986,7 +3067,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1515 +#: doc/rust.md:1561 msgid "" "The name `str_eq` has a special meaning to the Rust compiler, and the " "presence of this definition means that it will use this definition when " @@ -2994,23 +3075,21 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1517 +#: doc/rust.md:1563 msgid "A complete list of the built-in language items follows:" msgstr "" #. type: Plain text -#: doc/rust.md:1519 +#: doc/rust.md:1565 msgid "#### Traits" msgstr "" #. type: Plain text -#: doc/rust.md:1560 +#: doc/rust.md:1604 #, no-wrap msgid "" "`const`\n" " : Cannot be mutated.\n" -"`copy`\n" -" : Can be implicitly copied.\n" "`owned`\n" " : Are uniquely owned.\n" "`durable`\n" @@ -3050,12 +3129,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1562 +#: doc/rust.md:1606 msgid "#### Operations" msgstr "" #. type: Plain text -#: doc/rust.md:1591 +#: doc/rust.md:1636 #, no-wrap msgid "" "`str_eq`\n" @@ -3085,23 +3164,24 @@ msgid "" "`check_not_borrowed`\n" " : Fail if a value has existing borrowed pointers to it.\n" "`strdup_uniq`\n" -" : Return a new unique string containing a copy of the contents of a unique string.\n" +" : Return a new unique string\n" +" containing a copy of the contents of a unique string.\n" msgstr "" #. type: Plain text -#: doc/rust.md:1594 +#: doc/rust.md:1639 msgid "" "> **Note:** This list is likely to become out of date. We should auto-" "generate it > from `librustc/middle/lang_items.rs`." msgstr "" #. type: Plain text -#: doc/rust.md:1596 +#: doc/rust.md:1641 msgid "### Deriving" msgstr "" #. type: Plain text -#: doc/rust.md:1602 +#: doc/rust.md:1647 msgid "" "The `deriving` attribute allows certain traits to be automatically " "implemented for data structures. For example, the following will create an " @@ -3110,7 +3190,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1610 +#: doc/rust.md:1655 #, no-wrap msgid "" "~~~\n" @@ -3123,12 +3203,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1612 +#: doc/rust.md:1657 msgid "The generated `impl` for `Eq` is equivalent to" msgstr "" #. type: Plain text -#: doc/rust.md:1619 +#: doc/rust.md:1664 #, no-wrap msgid "" "~~~\n" @@ -3140,7 +3220,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1625 +#: doc/rust.md:1670 #, no-wrap msgid "" " fn ne(&self, other: &Foo) -> bool {\n" @@ -3151,42 +3231,42 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1627 +#: doc/rust.md:1672 msgid "Supported traits for `deriving` are:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "Serialization: `Encodable`, `Decodable`. These require `extra`." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "`Clone` and `DeepClone`, to perform (deep) copies." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "`IterBytes`, to iterate over the bytes in a data type." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "`Rand`, to create a random instance of a data type." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "`Zero`, to create an zero (or empty) instance of a data type." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:1638 +#: doc/rust.md:1683 msgid "" "`ToStr`, to convert to a string. For a type with this instance, `obj." "to_str()` has similar output as `fmt!(\"%?\", obj)`, but it differs in that " @@ -3195,12 +3275,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1640 +#: doc/rust.md:1685 msgid "# Statements and expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1647 +#: doc/rust.md:1692 msgid "" "Rust is _primarily_ an expression language. This means that most forms of " "value-producing or effect-causing evaluation are directed by the uniform " @@ -3211,38 +3291,38 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1650 +#: doc/rust.md:1695 msgid "" "In contrast, statements in Rust serve _mostly_ to contain and explicitly " "sequence expression evaluation." msgstr "" #. type: Plain text -#: doc/rust.md:1652 +#: doc/rust.md:1697 msgid "## Statements" msgstr "" #. type: Plain text -#: doc/rust.md:1655 +#: doc/rust.md:1700 msgid "" "A _statement_ is a component of a block, which is in turn a component of an " "outer [expression](#expressions) or [function](#functions)." msgstr "" #. type: Plain text -#: doc/rust.md:1659 +#: doc/rust.md:1704 msgid "" "Rust has two kinds of statement: [declaration statements](#declaration-" "statements) and [expression statements](#expression-statements)." msgstr "" #. type: Plain text -#: doc/rust.md:1661 +#: doc/rust.md:1706 msgid "### Declaration statements" msgstr "" #. type: Plain text -#: doc/rust.md:1664 +#: doc/rust.md:1709 msgid "" "A _declaration statement_ is one that introduces one or more *names* into " "the enclosing statement block. The declared names may denote new slots or " @@ -3250,12 +3330,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1666 +#: doc/rust.md:1711 msgid "#### Item declarations" msgstr "" #. type: Plain text -#: doc/rust.md:1673 +#: doc/rust.md:1718 msgid "" "An _item declaration statement_ has a syntactic form identical to an [item]" "(#items) declaration within a module. Declaring an item -- a function, " @@ -3266,26 +3346,26 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1676 +#: doc/rust.md:1721 msgid "" "Note: there is no implicit capture of the function's dynamic environment " "when declaring a function-local item." msgstr "" #. type: Plain text -#: doc/rust.md:1679 +#: doc/rust.md:1724 msgid "#### Slot declarations" msgstr "" #. type: Plain text -#: doc/rust.md:1684 +#: doc/rust.md:1729 msgid "" "~~~~~~~~{.ebnf .gram} let_decl : \"let\" pat [':' type ] ? [ init ] ? ';' ; " "init : [ '=' ] expr ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1690 +#: doc/rust.md:1735 msgid "" "A _slot declaration_ introduces a new set of slots, given by a pattern. The " "pattern may be followed by a type annotation, and/or an initializer " @@ -3296,12 +3376,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1692 +#: doc/rust.md:1737 msgid "### Expression statements" msgstr "" #. type: Plain text -#: doc/rust.md:1697 +#: doc/rust.md:1742 msgid "" "An _expression statement_ is one that evaluates an [expression]" "(#expressions) and ignores its result. The type of an expression statement " @@ -3311,12 +3391,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1699 +#: doc/rust.md:1744 msgid "## Expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1708 +#: doc/rust.md:1753 #, no-wrap msgid "" "An expression may have two roles: it always produces a *value*, and it may have *effects*\n" @@ -3330,7 +3410,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1713 +#: doc/rust.md:1758 msgid "" "In this way, the structure of expressions dictates the structure of " "execution. Blocks are just another kind of expression, so blocks, " @@ -3339,12 +3419,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1715 +#: doc/rust.md:1760 msgid "#### Lvalues, rvalues and temporaries" msgstr "" #. type: Plain text -#: doc/rust.md:1719 +#: doc/rust.md:1764 msgid "" "Expressions are divided into two main categories: _lvalues_ and _rvalues_. " "Likewise within each expression, sub-expressions may occur in _lvalue " @@ -3353,14 +3433,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1722 +#: doc/rust.md:1767 msgid "" "[Path](#path-expressions), [field](#field-expressions) and [index](#index-" "expressions) expressions are lvalues. All other expressions are rvalues." msgstr "" #. type: Plain text -#: doc/rust.md:1730 +#: doc/rust.md:1775 msgid "" "The left operand of an [assignment](#assignment-expressions), [binary move]" "(#binary-move-expressions) or [compound-assignment](#compound-assignment-" @@ -3371,7 +3451,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1733 +#: doc/rust.md:1778 msgid "" "When an lvalue is evaluated in an _lvalue context_, it denotes a memory " "location; when evaluated in an _rvalue context_, it denotes the value held " @@ -3379,7 +3459,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1736 +#: doc/rust.md:1781 msgid "" "When an rvalue is used in lvalue context, a temporary un-named lvalue is " "created and used instead. A temporary's lifetime equals the largest " @@ -3387,27 +3467,27 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1738 +#: doc/rust.md:1783 msgid "#### Moved and copied types" msgstr "" #. type: Plain text -#: doc/rust.md:1744 +#: doc/rust.md:1792 msgid "" "When a [local variable](#memory-slots) is used as an [rvalue](#lvalues-" "rvalues-and-temporaries) the variable will either be [moved](#move-" -"expressions) or [copied](#copy-expressions), depending on its type. For " -"types that contain mutable fields or [owning pointers](#owning-pointers), " -"the variable is moved. All other types are copied." +"expressions) or copied, depending on its type. For types that contain " +"[owning pointers](#owning-pointers) or values that implement the special " +"trait `Drop`, the variable is moved. All other types are copied." msgstr "" #. type: Plain text -#: doc/rust.md:1747 +#: doc/rust.md:1795 msgid "### Literal expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1751 +#: doc/rust.md:1799 msgid "" "A _literal expression_ consists of one of the [literal](#literals) forms " "described earlier. It directly describes a number, character, string, " @@ -3415,7 +3495,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1758 +#: doc/rust.md:1806 #, no-wrap msgid "" "~~~~~~~~ {.literals}\n" @@ -3427,12 +3507,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1760 +#: doc/rust.md:1808 msgid "### Path expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1763 +#: doc/rust.md:1811 msgid "" "A [path](#paths) used as an expression context denotes either a local " "variable or an item. Path expressions are [lvalues](#lvalues-rvalues-and-" @@ -3440,29 +3520,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1765 +#: doc/rust.md:1813 msgid "### Tuple expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1769 +#: doc/rust.md:1817 msgid "" "Tuples are written by enclosing one or more comma-separated expressions in " "parentheses. They are used to create [tuple-typed](#tuple-types) values." msgstr "" #. type: Plain text -#: doc/rust.md:1775 +#: doc/rust.md:1823 msgid "~~~~~~~~ {.tuple} (0,); (0f, 4.5f); (\"a\", 4u, true); ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1777 +#: doc/rust.md:1825 msgid "### Structure expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1786 +#: doc/rust.md:1834 #, no-wrap msgid "" "~~~~~~~~{.ebnf .gram}\n" @@ -3476,7 +3556,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1793 +#: doc/rust.md:1841 msgid "" "There are several forms of structure expressions. A _structure expression_ " "consists of the [path](#paths) of a [structure item](#structures), followed " @@ -3488,7 +3568,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1798 +#: doc/rust.md:1846 msgid "" "A _tuple structure expression_ consists of the [path](#paths) of a " "[structure item](#structures), followed by a parenthesized list of one or " @@ -3498,19 +3578,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1800 +#: doc/rust.md:1848 msgid "" "A _unit-like structure expression_ consists only of the [path](#paths) of a " "[structure item](#structures)." msgstr "" #. type: Plain text -#: doc/rust.md:1802 +#: doc/rust.md:1850 msgid "The following are examples of structure expressions:" msgstr "" #. type: Plain text -#: doc/rust.md:1813 +#: doc/rust.md:1861 msgid "" "~~~~ # struct Point { x: float, y: float } # struct TuplePoint(float, " "float); # mod game { pub struct User<'self> { name: &'self str, age: uint, " @@ -3520,7 +3600,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1816 +#: doc/rust.md:1864 msgid "" "A structure expression forms a new value of the named structure type. Note " "that for a given *unit-like* structure type, this will always be the same " @@ -3528,7 +3608,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1823 +#: doc/rust.md:1871 msgid "" "A structure expression can terminate with the syntax `..` followed by an " "expression to denote a functional update. The expression following `..` " @@ -3540,19 +3620,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1829 +#: doc/rust.md:1877 msgid "" "~~~~ # struct Point3d { x: int, y: int, z: int } let base = Point3d {x: 1, " "y: 2, z: 3}; Point3d {y: 0, z: 10, .. base}; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1831 +#: doc/rust.md:1879 msgid "### Record expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1837 +#: doc/rust.md:1885 #, no-wrap msgid "" "~~~~~~~~{.ebnf .gram}\n" @@ -3563,19 +3643,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1839 +#: doc/rust.md:1887 msgid "### Method-call expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1843 +#: doc/rust.md:1891 msgid "" "~~~~~~~~{.ebnf .gram} method_call_expr : expr '.' ident paren_expr_list ; " "~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1848 +#: doc/rust.md:1896 msgid "" "A _method call_ consists of an expression followed by a single dot, an " "identifier, and a parenthesized expression-list. Method calls are resolved " @@ -3586,17 +3666,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1851 +#: doc/rust.md:1899 msgid "### Field expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1855 +#: doc/rust.md:1903 msgid "~~~~~~~~{.ebnf .gram} field_expr : expr '.' ident ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1859 +#: doc/rust.md:1907 msgid "" "A _field expression_ consists of an expression followed by a single dot and " "an identifier, when not immediately followed by a parenthesized expression-" @@ -3605,12 +3685,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1864 +#: doc/rust.md:1912 msgid "~~~~~~~~ {.field} myrecord.myfield; {a: 10, b: 20}.a; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1867 +#: doc/rust.md:1915 msgid "" "A field access on a record is an [lvalue](#lvalues-rvalues-and-temporaries) " "referring to the value of that field. When the field is mutable, it can be " @@ -3618,7 +3698,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1870 +#: doc/rust.md:1918 msgid "" "When the type of the expression to the left of the dot is a pointer to a " "record or structure, it is automatically derferenced to make the field " @@ -3626,29 +3706,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1873 +#: doc/rust.md:1921 msgid "### Vector expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1876 +#: doc/rust.md:1924 msgid "~~~~~~~~{.ebnf .gram} vec_expr : '[' \"mut\"? vec_elems? ']'" msgstr "" #. type: Plain text -#: doc/rust.md:1879 +#: doc/rust.md:1927 msgid "vec_elems : [expr [',' expr]*] | [expr ',' \"..\" expr] ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1882 +#: doc/rust.md:1930 msgid "" "A [_vector_](#vector-types) _expression_ is written by enclosing zero or " "more comma-separated expressions of uniform type in square brackets." msgstr "" #. type: Plain text -#: doc/rust.md:1886 +#: doc/rust.md:1934 msgid "" "In the `[expr ',' \"..\" expr]` form, the expression after the `\"..\"` must " "be a constant expression that can be evaluated at compile time, such as a " @@ -3656,7 +3736,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1893 +#: doc/rust.md:1941 #, no-wrap msgid "" "~~~~\n" @@ -3668,17 +3748,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1895 +#: doc/rust.md:1943 msgid "### Index expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1899 +#: doc/rust.md:1947 msgid "~~~~~~~~{.ebnf .gram} idx_expr : expr '[' expr ']' ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1904 +#: doc/rust.md:1952 msgid "" "[Vector](#vector-types)-typed expressions can be indexed by writing a square-" "bracket-enclosed expression (the index) after them. When the vector is " @@ -3687,7 +3767,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1908 +#: doc/rust.md:1956 msgid "" "Indices are zero-based, and may be of any integral type. Vector access is " "bounds-checked at run-time. When the check fails, it will put the task in a " @@ -3695,36 +3775,34 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1912 +#: doc/rust.md:1960 msgid "~~~~ # use std::task; # do task::spawn_unlinked {" msgstr "" #. type: Plain text -#: doc/rust.md:1915 +#: doc/rust.md:1963 msgid "([1, 2, 3, 4])[0]; ([\"a\", \"b\"])[10]; // fails" msgstr "" #. type: Plain text -#: doc/rust.md:1918 doc/tutorial-tasks.md:649 +#: doc/rust.md:1966 doc/tutorial-tasks.md:648 msgid "# } ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1920 +#: doc/rust.md:1968 msgid "### Unary operator expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1924 +#: doc/rust.md:1972 msgid "" -"Rust defines six symbolic unary operators, in addition to the unary [copy]" -"(#unary-copy-expressions) and [move](#unary-move-expressions) operators. " -"They are all written as prefix operators, before the expression they apply " -"to." +"Rust defines six symbolic unary operators. They are all written as prefix " +"operators, before the expression they apply to." msgstr "" #. type: Plain text -#: doc/rust.md:1943 +#: doc/rust.md:1991 #, no-wrap msgid "" "`-`\n" @@ -3748,29 +3826,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1945 +#: doc/rust.md:1993 msgid "### Binary operator expressions" msgstr "" #. type: Plain text -#: doc/rust.md:1949 +#: doc/rust.md:1997 msgid "~~~~~~~~{.ebnf .gram} binop_expr : expr binop expr ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:1952 +#: doc/rust.md:2000 msgid "" "Binary operators expressions are given in terms of [operator precedence]" "(#operator-precedence)." msgstr "" #. type: Plain text -#: doc/rust.md:1954 +#: doc/rust.md:2002 msgid "#### Arithmetic operators" msgstr "" #. type: Plain text -#: doc/rust.md:1959 +#: doc/rust.md:2007 msgid "" "Binary arithmetic expressions are syntactic sugar for calls to built-in " "traits, defined in the `std::ops` module of the `std` library. This means " @@ -3779,7 +3857,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1975 +#: doc/rust.md:2023 #, no-wrap msgid "" "`+`\n" @@ -3800,12 +3878,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1977 +#: doc/rust.md:2025 msgid "#### Bitwise operators" msgstr "" #. type: Plain text -#: doc/rust.md:1982 +#: doc/rust.md:2030 msgid "" "Like the [arithmetic operators](#arithmetic-operators), bitwise operators " "are syntactic sugar for calls to methods of built-in traits. This means " @@ -3814,7 +3892,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1998 +#: doc/rust.md:2046 #, no-wrap msgid "" "`&`\n" @@ -3835,12 +3913,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2000 +#: doc/rust.md:2048 msgid "#### Lazy boolean operators" msgstr "" #. type: Plain text -#: doc/rust.md:2007 +#: doc/rust.md:2055 msgid "" "The operators `||` and `&&` may be applied to operands of boolean type. The " "`||` operator denotes logical 'or', and the `&&` operator denotes logical " @@ -3852,12 +3930,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2009 +#: doc/rust.md:2057 msgid "#### Comparison operators" msgstr "" #. type: Plain text -#: doc/rust.md:2015 +#: doc/rust.md:2063 msgid "" "Comparison operators are, like the [arithmetic operators](#arithmetic-" "operators), and [bitwise operators](#bitwise-operators), syntactic sugar for " @@ -3867,7 +3945,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2034 +#: doc/rust.md:2082 #, no-wrap msgid "" "`==`\n" @@ -3891,24 +3969,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2037 +#: doc/rust.md:2085 msgid "#### Type cast expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2039 +#: doc/rust.md:2087 msgid "A type cast expression is denoted with the binary operator `as`." msgstr "" #. type: Plain text -#: doc/rust.md:2042 +#: doc/rust.md:2090 msgid "" "Executing an `as` expression casts the value on the left-hand side to the " "type on the right-hand side." msgstr "" #. type: Plain text -#: doc/rust.md:2046 +#: doc/rust.md:2094 msgid "" "A numeric value can be cast to any numeric type. A raw pointer value can be " "cast to or from any integral type or raw pointer type. Any other cast is " @@ -3916,19 +3994,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2048 +#: doc/rust.md:2096 msgid "An example of an `as` expression:" msgstr "" #. type: Plain text -#: doc/rust.md:2052 +#: doc/rust.md:2100 msgid "" "~~~~ # fn sum(v: &[float]) -> float { 0.0 } # fn len(v: &[float]) -> int " "{ 0 }" msgstr "" #. type: Plain text -#: doc/rust.md:2059 +#: doc/rust.md:2107 #, no-wrap msgid "" "fn avg(v: &[float]) -> float {\n" @@ -3940,12 +4018,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2061 +#: doc/rust.md:2109 msgid "#### Assignment expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2064 +#: doc/rust.md:2112 msgid "" "An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-" "temporaries) expression followed by an equals sign (`=`) and an [rvalue]" @@ -3953,29 +4031,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2066 +#: doc/rust.md:2114 msgid "" "Evaluating an assignment expression [either copies or moves](#moved-and-" "copied-types) its right-hand operand to its left-hand operand." msgstr "" #. type: Plain text -#: doc/rust.md:2070 +#: doc/rust.md:2118 msgid "~~~~ # let mut x = 0; # let y = 0;" msgstr "" #. type: Plain text -#: doc/rust.md:2073 +#: doc/rust.md:2121 msgid "x = y; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2075 +#: doc/rust.md:2123 msgid "#### Compound assignment expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2080 +#: doc/rust.md:2128 msgid "" "The `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, and `>>` operators may be " "composed with the `=` operator. The expression `lval OP= val` is equivalent " @@ -3983,24 +4061,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2082 +#: doc/rust.md:2130 msgid "Any such expression always has the [`unit`](#primitive-types) type." msgstr "" #. type: Plain text -#: doc/rust.md:2084 +#: doc/rust.md:2132 msgid "#### Operator precedence" msgstr "" #. type: Plain text -#: doc/rust.md:2087 +#: doc/rust.md:2135 msgid "" "The precedence of Rust binary operators is ordered as follows, going from " "strong to weak:" msgstr "" #. type: Plain text -#: doc/rust.md:2100 +#: doc/rust.md:2148 #, no-wrap msgid "" "~~~~ {.precedence}\n" @@ -4019,12 +4097,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2102 doc/rust.md:2243 doc/tutorial-macros.md:323 +#: doc/rust.md:2150 doc/rust.md:2237 doc/tutorial-macros.md:323 msgid "~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2105 +#: doc/rust.md:2153 msgid "" "Operators at the same precedence level are evaluated left-to-right. [Unary " "operators](#unary-operator-expressions) have the same precedence level and " @@ -4032,12 +4110,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2107 +#: doc/rust.md:2155 msgid "### Grouped expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2111 +#: doc/rust.md:2159 msgid "" "An expression enclosed in parentheses evaluates to the result of the " "enclosed expression. Parentheses can be used to explicitly specify " @@ -4045,135 +4123,27 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2115 +#: doc/rust.md:2163 msgid "~~~~~~~~{.ebnf .gram} paren_expr : '(' expr ')' ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2117 +#: doc/rust.md:2165 msgid "An example of a parenthesized expression:" msgstr "" #. type: Plain text -#: doc/rust.md:2121 +#: doc/rust.md:2169 msgid "~~~~ let x = (2 + 3) * 4; ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2123 -msgid "### Unary copy expressions" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2127 -msgid "~~~~~~~~{.ebnf .gram} copy_expr : \"copy\" expr ; ~~~~~~~~" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2130 -msgid "" -"> **Note:** `copy` expressions are deprecated. It's preferable to use > the " -"`Clone` trait and `clone()` method." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2133 -msgid "" -"A _unary copy expression_ consists of the unary `copy` operator applied to " -"some argument expression." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2137 -msgid "" -"Evaluating a copy expression first evaluates the argument expression, then " -"copies the resulting value, allocating any memory necessary to hold the new " -"copy." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2141 -msgid "" -"[Managed boxes](#pointer-types) (type `@`) are, as usual, shallow-copied, as " -"are raw and borrowed pointers. [Owned boxes](#pointer-types), [owned " -"vectors](#vector-types) and similar owned types are deep-copied." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2144 -msgid "" -"Since the binary [assignment operator](#assignment-expressions) `=` performs " -"a copy or move implicitly, the unary copy operator is typically only used to " -"cause an argument to a function to be copied and passed by value." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2146 -msgid "An example of a copy expression:" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2151 -#, no-wrap -msgid "" -"~~~~\n" -"fn mutate(mut vec: ~[int]) {\n" -" vec[0] = 10;\n" -"}\n" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2153 -msgid "let v = ~[1,2,3];" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2155 -#, no-wrap -msgid "mutate(copy v); // Pass a copy\n" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2158 -msgid "assert!(v[0] == 1); // Original was not modified ~~~~" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2160 -msgid "### Unary move expressions" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2164 -msgid "~~~~~~~~{.ebnf .gram} move_expr : \"move\" expr ; ~~~~~~~~" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2171 -msgid "" -"A _unary move expression_ is similar to a [unary copy](#unary-copy-" -"expressions) expression, except that it can only be applied to a [local " -"variable](#memory-slots), and it performs a _move_ on its operand, rather " -"than a copy. That is, the memory location denoted by its operand is de-" -"initialized after evaluation, and the resulting value is a shallow copy of " -"the operand, even if the operand is an [owning type](#type-kinds)." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2175 -msgid "" -"> **Note:** In future versions of Rust, `move` may be removed as a separate " -"operator; > moves are now [automatically performed](#moved-and-copied-types) " -"for most cases `move` would be appropriate." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2178 +#: doc/rust.md:2172 msgid "### Call expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2184 +#: doc/rust.md:2178 msgid "" "~~~~~~~~ {.abnf .gram} expr_list : [ expr [ ',' expr ]* ] ? ; " "paren_expr_list : '(' expr_list ')' ; call_expr : expr paren_expr_list ; " @@ -4181,7 +4151,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2189 +#: doc/rust.md:2183 msgid "" "A _call expression_ invokes a function, providing zero or more input slots " "and an optional reference slot to serve as the function's output, bound to " @@ -4190,36 +4160,36 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2191 +#: doc/rust.md:2185 msgid "Some examples of call expressions:" msgstr "" #. type: Plain text -#: doc/rust.md:2195 +#: doc/rust.md:2189 msgid "" "~~~~ # use std::from_str::FromStr; # fn add(x: int, y: int) -> int { 0 }" msgstr "" #. type: Plain text -#: doc/rust.md:2199 +#: doc/rust.md:2193 msgid "" "let x: int = add(1, 2); let pi = FromStr::from_str::(\"3.14\"); ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2201 +#: doc/rust.md:2195 msgid "### Lambda expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2206 +#: doc/rust.md:2200 msgid "" "~~~~~~~~ {.abnf .gram} ident_list : [ ident [ ',' ident ]* ] ? ; " "lambda_expr : '|' ident_list '|' expr ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2210 +#: doc/rust.md:2204 msgid "" "A _lambda expression_ (sometimes called an \"anonymous function expression" "\") defines a function and denotes it as a value, in a single expression. A " @@ -4228,7 +4198,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2215 +#: doc/rust.md:2209 msgid "" "A lambda expression denotes a function that maps a list of parameters " "(`ident_list`) onto the expression that follows the `ident_list`. The " @@ -4238,7 +4208,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2218 +#: doc/rust.md:2212 msgid "" "Lambda expressions are most useful when passing functions as arguments to " "other functions, as an abbreviation for defining and capturing a separate " @@ -4246,7 +4216,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2227 +#: doc/rust.md:2221 msgid "" "Significantly, lambda expressions _capture their environment_, which regular " "[function definitions](#functions) do not. The exact type of capture " @@ -4260,14 +4230,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2230 +#: doc/rust.md:2224 msgid "" "In this example, we define a function `ten_times` that takes a higher-order " "function argument, and call it with a lambda expression as an argument." msgstr "" #. type: Plain text -#: doc/rust.md:2239 +#: doc/rust.md:2233 #, no-wrap msgid "" "~~~~\n" @@ -4281,23 +4251,23 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2241 +#: doc/rust.md:2235 msgid "ten_times(|j| println(fmt!(\"hello, %d\", j)));" msgstr "" #. type: Plain text -#: doc/rust.md:2245 +#: doc/rust.md:2239 msgid "### While loops" msgstr "" #. type: Plain text -#: doc/rust.md:2249 +#: doc/rust.md:2243 msgid "" "~~~~~~~~{.ebnf .gram} while_expr : \"while\" expr '{' block '}' ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2254 +#: doc/rust.md:2248 msgid "" "A `while` loop begins by evaluating the boolean loop conditional " "expression. If the loop conditional expression evaluates to `true`, the " @@ -4307,17 +4277,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2256 +#: doc/rust.md:2250 msgid "An example:" msgstr "" #. type: Plain text -#: doc/rust.md:2259 +#: doc/rust.md:2253 msgid "~~~~ let mut i = 0;" msgstr "" #. type: Plain text -#: doc/rust.md:2265 +#: doc/rust.md:2259 #, no-wrap msgid "" "while i < 10 {\n" @@ -4328,12 +4298,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2267 +#: doc/rust.md:2261 msgid "### Infinite loops" msgstr "" #. type: Plain text -#: doc/rust.md:2271 +#: doc/rust.md:2265 msgid "" "The keyword `loop` in Rust appears both in _loop expressions_ and in " "_continue expressions_. A loop expression denotes an infinite loop; see " @@ -4341,14 +4311,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2275 +#: doc/rust.md:2269 msgid "" "~~~~~~~~{.ebnf .gram} loop_expr : [ lifetime ':' ] \"loop\" '{' block '}'; " "~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2280 +#: doc/rust.md:2274 msgid "" "A `loop` expression may optionally have a _label_. If a label is present, " "then labeled `break` and `loop` expressions nested within this loop may exit " @@ -4357,17 +4327,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2282 +#: doc/rust.md:2276 msgid "### Break expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2286 +#: doc/rust.md:2280 msgid "~~~~~~~~{.ebnf .gram} break_expr : \"break\" [ lifetime ]; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2293 +#: doc/rust.md:2287 msgid "" "A `break` expression has an optional `label`. If the label is absent, then " "executing a `break` expression immediately terminates the innermost loop " @@ -4378,17 +4348,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2295 +#: doc/rust.md:2289 msgid "### Continue expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2299 +#: doc/rust.md:2293 msgid "~~~~~~~~{.ebnf .gram} continue_expr : \"loop\" [ lifetime ]; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2310 +#: doc/rust.md:2304 msgid "" "A continue expression, written `loop`, also has an optional `label`. If the " "label is absent, then executing a `loop` expression immediately terminates " @@ -4402,24 +4372,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2312 +#: doc/rust.md:2306 msgid "A `loop` expression is only permitted in the body of a loop." msgstr "" #. type: Plain text -#: doc/rust.md:2315 +#: doc/rust.md:2309 msgid "### Do expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2319 +#: doc/rust.md:2313 msgid "" "~~~~~~~~{.ebnf .gram} do_expr : \"do\" expr [ '|' ident_list '|' ] ? '{' " "block '}' ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2322 +#: doc/rust.md:2316 msgid "" "A _do expression_ provides a more-familiar block-syntax for a [lambda " "expression](#lambda-expressions), including a special translation of [return " @@ -4427,7 +4397,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2330 +#: doc/rust.md:2324 msgid "" "Any occurrence of a [return expression](#return-expressions) inside this " "`block` expression is rewritten as a reference to an (anonymous) flag set in " @@ -4439,7 +4409,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2333 +#: doc/rust.md:2327 msgid "" "The optional `ident_list` and `block` provided in a `do` expression are " "parsed as though they constitute a lambda expression; if the `ident_list` is " @@ -4447,7 +4417,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2339 +#: doc/rust.md:2333 msgid "" "The lambda expression is then provided as a _trailing argument_ to the " "outermost [call](#call-expressions) or [method call](#method-call-" @@ -4458,22 +4428,22 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2341 +#: doc/rust.md:2335 msgid "In this example, both calls to `f` are equivalent:" msgstr "" #. type: Plain text -#: doc/rust.md:2345 +#: doc/rust.md:2339 msgid "~~~~ # fn f(f: &fn(int)) { } # fn g(i: int) { }" msgstr "" #. type: Plain text -#: doc/rust.md:2347 +#: doc/rust.md:2341 msgid "f(|j| g(j));" msgstr "" #. type: Plain text -#: doc/rust.md:2352 +#: doc/rust.md:2346 #, no-wrap msgid "" "do f |j| {\n" @@ -4483,23 +4453,23 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2354 +#: doc/rust.md:2348 msgid "" "In this example, both calls to the (binary) function `k` are equivalent:" msgstr "" #. type: Plain text -#: doc/rust.md:2358 +#: doc/rust.md:2352 msgid "~~~~ # fn k(x:int, f: &fn(int)) { } # fn l(i: int) { }" msgstr "" #. type: Plain text -#: doc/rust.md:2360 +#: doc/rust.md:2354 msgid "k(3, |j| l(j));" msgstr "" #. type: Plain text -#: doc/rust.md:2365 +#: doc/rust.md:2359 #, no-wrap msgid "" "do k(3) |j| {\n" @@ -4509,19 +4479,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2368 +#: doc/rust.md:2362 msgid "### For expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2372 +#: doc/rust.md:2366 msgid "" "~~~~~~~~{.ebnf .gram} for_expr : \"for\" expr [ '|' ident_list '|' ] ? '{' " "block '}' ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2376 +#: doc/rust.md:2370 msgid "" "A _for expression_ is similar to a [`do` expression](#do-expressions), in " "that it provides a special block-form of lambda expression, suited to " @@ -4529,7 +4499,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2382 +#: doc/rust.md:2376 msgid "" "In contrast to a `do` expression, a `for` expression is designed to work " "with methods such as `each` and `times`, that require the body block to " @@ -4539,7 +4509,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2389 +#: doc/rust.md:2383 msgid "" "In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) " "expressions are rewritten inside `for` expressions in the same way that " @@ -4550,24 +4520,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2391 +#: doc/rust.md:2385 msgid "An example of a for loop over the contents of a vector:" msgstr "" #. type: Plain text -#: doc/rust.md:2398 +#: doc/rust.md:2392 msgid "" "~~~~ # type foo = int; # fn bar(f: foo) { } # let a = 0; # let b = 0; # let " "c = 0;" msgstr "" #. type: Plain text -#: doc/rust.md:2400 +#: doc/rust.md:2394 msgid "let v: &[foo] = &[a, b, c];" msgstr "" #. type: Plain text -#: doc/rust.md:2405 +#: doc/rust.md:2399 #, no-wrap msgid "" "for e in v.iter() {\n" @@ -4577,30 +4547,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2407 +#: doc/rust.md:2401 msgid "An example of a for loop over a series of integers:" msgstr "" #. type: Plain text -#: doc/rust.md:2415 +#: doc/rust.md:2408 #, no-wrap msgid "" "~~~~\n" -"# use std::uint;\n" "# fn bar(b:uint) { }\n" -"for uint::range(0, 256) |i| {\n" +"for i in range(0u, 256) {\n" " bar(i);\n" "}\n" "~~~~\n" msgstr "" #. type: Plain text -#: doc/rust.md:2417 +#: doc/rust.md:2410 msgid "### If expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2421 +#: doc/rust.md:2414 #, no-wrap msgid "" "~~~~~~~~{.ebnf .gram}\n" @@ -4609,7 +4578,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2425 +#: doc/rust.md:2418 #, no-wrap msgid "" "else_tail : \"else\" [ if_expr\n" @@ -4618,7 +4587,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2436 +#: doc/rust.md:2429 msgid "" "An `if` expression is a conditional branch in program control. The form of " "an `if` expression is a condition expression, followed by a consequent " @@ -4632,29 +4601,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2439 +#: doc/rust.md:2432 msgid "### Match expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2442 +#: doc/rust.md:2435 msgid "" "~~~~~~~~{.ebnf .gram} match_expr : \"match\" expr '{' match_arm [ '|' " "match_arm ] * '}' ;" msgstr "" #. type: Plain text -#: doc/rust.md:2444 +#: doc/rust.md:2437 msgid "match_arm : match_pat '=>' [ expr \",\" | '{' block '}' ] ;" msgstr "" #. type: Plain text -#: doc/rust.md:2447 +#: doc/rust.md:2440 msgid "match_pat : pat [ \"..\" pat ] ? [ \"if\" expr ] ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2455 +#: doc/rust.md:2448 msgid "" "A `match` expression branches on a *pattern*. The exact form of matching " "that occurs depends on the pattern. Patterns consist of some combination of " @@ -4666,7 +4635,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2459 +#: doc/rust.md:2452 msgid "" "In a pattern whose head expression has an `enum` type, a placeholder (`_`) " "stands for a *single* data field, whereas a wildcard `*` stands for *all* " @@ -4674,17 +4643,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2462 +#: doc/rust.md:2455 msgid "~~~~ enum List { Nil, Cons(X, @List) }" msgstr "" #. type: Plain text -#: doc/rust.md:2464 doc/rust.md:2493 +#: doc/rust.md:2457 doc/rust.md:2486 msgid "let x: List = Cons(10, @Cons(11, @Nil));" msgstr "" #. type: Plain text -#: doc/rust.md:2471 +#: doc/rust.md:2464 #, no-wrap msgid "" "match x {\n" @@ -4696,7 +4665,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2476 +#: doc/rust.md:2469 msgid "" "The first pattern matches lists constructed by applying `Cons` to any head " "value, and a tail value of `@Nil`. The second pattern matches _any_ list " @@ -4707,7 +4676,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2482 +#: doc/rust.md:2475 msgid "" "To execute an `match` expression, first the head expression is evaluated, " "then its value is sequentially compared to the patterns in the arms until a " @@ -4717,22 +4686,22 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2484 +#: doc/rust.md:2477 msgid "An example of an `match` expression:" msgstr "" #. type: Plain text -#: doc/rust.md:2489 +#: doc/rust.md:2482 msgid "~~~~ # fn process_pair(a: int, b: int) { } # fn process_ten() { }" msgstr "" #. type: Plain text -#: doc/rust.md:2491 +#: doc/rust.md:2484 msgid "enum List { Nil, Cons(X, @List) }" msgstr "" #. type: Plain text -#: doc/rust.md:2509 +#: doc/rust.md:2502 #, no-wrap msgid "" "match x {\n" @@ -4753,17 +4722,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2515 +#: doc/rust.md:2509 msgid "" "Patterns that bind variables default to binding to a copy or move of the " -"matched value (depending on the matched value's type). This can be made " -"explicit using the ```copy``` keyword, changed to bind to a borrowed pointer " -"by using the ```ref``` keyword, or to a mutable borrowed pointer using " -"```ref mut```." +"matched value (depending on the matched value's type). This can be changed " +"to bind to a borrowed pointer by using the ```ref``` keyword, or to a " +"mutable borrowed pointer using ```ref mut```." msgstr "" #. type: Plain text -#: doc/rust.md:2526 +#: doc/rust.md:2520 msgid "" "A pattern that's just an identifier, like `Nil` in the previous answer, " "could either refer to an enum variant that's in scope, or bind a new " @@ -4778,19 +4746,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2530 +#: doc/rust.md:2524 msgid "" "Multiple match patterns may be joined with the `|` operator. A range of " "values may be specified with `..`. For example:" msgstr "" #. type: Plain text -#: doc/rust.md:2533 +#: doc/rust.md:2527 msgid "~~~~ # let x = 2;" msgstr "" #. type: Plain text -#: doc/rust.md:2540 +#: doc/rust.md:2534 #, no-wrap msgid "" "let message = match x {\n" @@ -4802,7 +4770,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2544 +#: doc/rust.md:2538 msgid "" "Range patterns only work on scalar types (like integers and characters; not " "like vectors and structs, which have sub-components). A range pattern may " @@ -4810,7 +4778,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2549 +#: doc/rust.md:2543 msgid "" "Finally, match patterns can accept *pattern guards* to further refine the " "criteria for matching a case. Pattern guards appear after the pattern and " @@ -4819,14 +4787,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2554 +#: doc/rust.md:2548 msgid "" "~~~~ # let maybe_digit = Some(0); # fn process_digit(i: int) { } # fn " "process_other(i: int) { }" msgstr "" #. type: Plain text -#: doc/rust.md:2561 +#: doc/rust.md:2555 #, no-wrap msgid "" "let message = match maybe_digit {\n" @@ -4838,17 +4806,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2563 +#: doc/rust.md:2557 msgid "### Return expressions" msgstr "" #. type: Plain text -#: doc/rust.md:2567 +#: doc/rust.md:2561 msgid "~~~~~~~~{.ebnf .gram} return_expr : \"return\" expr ? ; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2572 +#: doc/rust.md:2566 msgid "" "Return expressions are denoted with the keyword `return`. Evaluating a " "`return` expression moves its argument into the output slot of the current " @@ -4857,12 +4825,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2574 +#: doc/rust.md:2568 msgid "An example of a `return` expression:" msgstr "" #. type: Plain text -#: doc/rust.md:2583 +#: doc/rust.md:2577 #, no-wrap msgid "" "~~~~\n" @@ -4876,24 +4844,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2586 +#: doc/rust.md:2580 msgid "# Type system" msgstr "" #. type: Plain text -#: doc/rust.md:2588 +#: doc/rust.md:2582 msgid "## Types" msgstr "" #. type: Plain text -#: doc/rust.md:2591 +#: doc/rust.md:2585 msgid "" "Every slot, item and value in a Rust program has a type. The _type_ of a " "*value* defines the interpretation of the memory holding it." msgstr "" #. type: Plain text -#: doc/rust.md:2595 +#: doc/rust.md:2589 msgid "" "Built-in types and type-constructors are tightly integrated into the " "language, in nontrivial ways that are not possible to emulate in user-" @@ -4901,17 +4869,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2597 +#: doc/rust.md:2591 msgid "### Primitive types" msgstr "" #. type: Plain text -#: doc/rust.md:2599 +#: doc/rust.md:2593 msgid "The primitive types are the following:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2605 +#: doc/rust.md:2599 msgid "" "The \"unit\" type `()`, having the single \"unit\" value `()` (occasionally " "called \"nil\"). ^[The \"unit\" value `()` is *not* a sentinel \"null " @@ -4922,32 +4890,32 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2605 +#: doc/rust.md:2599 msgid "The boolean type `bool` with values `true` and `false`." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2605 +#: doc/rust.md:2599 msgid "The machine types." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2605 +#: doc/rust.md:2599 msgid "The machine-dependent integer and floating-point types." msgstr "" #. type: Plain text -#: doc/rust.md:2607 +#: doc/rust.md:2601 msgid "#### Machine types" msgstr "" #. type: Plain text -#: doc/rust.md:2609 +#: doc/rust.md:2603 msgid "The machine types are the following:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2614 +#: doc/rust.md:2608 msgid "" "The unsigned word types `u8`, `u16`, `u32` and `u64`, with values drawn from " "the integer intervals $[0, 2^8 - 1]$, $[0, 2^{16} - 1]$, $[0, 2^{32} - 1]$ " @@ -4955,7 +4923,7 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2619 +#: doc/rust.md:2613 msgid "" "The signed two's complement word types `i8`, `i16`, `i32` and `i64`, with " "values drawn from the integer intervals $[-(2^7), 2^7 - 1]$, $[-(2^{15}), " @@ -4964,19 +4932,19 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2622 +#: doc/rust.md:2616 msgid "" "The IEEE 754-2008 `binary32` and `binary64` floating-point types: `f32` and " "`f64`, respectively." msgstr "" #. type: Plain text -#: doc/rust.md:2624 +#: doc/rust.md:2618 msgid "#### Machine-dependent integer types" msgstr "" #. type: Plain text -#: doc/rust.md:2629 +#: doc/rust.md:2623 msgid "" "The Rust type `uint`^[A Rust `uint` is analogous to a C99 `uintptr_t`.] is " "an unsigned integer type with target-machine-dependent size. Its size, in " @@ -4985,7 +4953,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2634 +#: doc/rust.md:2628 msgid "" "The Rust type `int`^[A Rust `int` is analogous to a C99 `intptr_t`.] is a " "two's complement signed integer type with target-machine-dependent size. Its " @@ -4994,12 +4962,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2637 +#: doc/rust.md:2631 msgid "#### Machine-dependent floating point type" msgstr "" #. type: Plain text -#: doc/rust.md:2644 +#: doc/rust.md:2638 msgid "" "The Rust type `float` is a machine-specific type equal to one of the " "supported Rust floating-point machine types (`f32` or `f64`). It is the " @@ -5010,31 +4978,31 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2647 +#: doc/rust.md:2641 msgid "" "Note that due to the preference for hardware-supported floating-point, the " "type `float` may not be equal to the largest *supported* floating-point type." msgstr "" #. type: Plain text -#: doc/rust.md:2650 +#: doc/rust.md:2644 msgid "### Textual types" msgstr "" #. type: Plain text -#: doc/rust.md:2652 +#: doc/rust.md:2646 msgid "The types `char` and `str` hold textual data." msgstr "" #. type: Plain text -#: doc/rust.md:2655 +#: doc/rust.md:2649 msgid "" "A value of type `char` is a Unicode character, represented as a 32-bit " "unsigned word holding a UCS-4 codepoint." msgstr "" #. type: Plain text -#: doc/rust.md:2661 +#: doc/rust.md:2655 msgid "" "A value of type `str` is a Unicode string, represented as a vector of 8-bit " "unsigned bytes holding a sequence of UTF-8 codepoints. Since `str` is of " @@ -5043,61 +5011,61 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2664 +#: doc/rust.md:2658 msgid "### Tuple types" msgstr "" #. type: Plain text -#: doc/rust.md:2667 +#: doc/rust.md:2661 msgid "" "The tuple type-constructor forms a new heterogeneous product of values " "similar to the record type-constructor. The differences are as follows:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2670 +#: doc/rust.md:2664 msgid "tuple elements cannot be mutable, unlike record fields" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:2670 +#: doc/rust.md:2664 msgid "" "tuple elements are not named and can be accessed only by pattern-matching" msgstr "" #. type: Plain text -#: doc/rust.md:2674 +#: doc/rust.md:2668 msgid "" "Tuple types and values are denoted by listing the types or values of their " "elements, respectively, in a parenthesized, comma-separated list." msgstr "" #. type: Plain text -#: doc/rust.md:2677 +#: doc/rust.md:2671 msgid "" "The members of a tuple are laid out in memory contiguously, like a record, " "in order specified by the tuple type." msgstr "" #. type: Plain text -#: doc/rust.md:2679 +#: doc/rust.md:2673 msgid "An example of a tuple type and its use:" msgstr "" #. type: Plain text -#: doc/rust.md:2686 +#: doc/rust.md:2680 msgid "" "~~~~ type Pair<'self> = (int,&'self str); let p: Pair<'static> = (10,\"hello" "\"); let (a, b) = p; assert!(b != \"world\"); ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2689 +#: doc/rust.md:2683 msgid "### Vector types" msgstr "" #. type: Plain text -#: doc/rust.md:2702 +#: doc/rust.md:2696 msgid "" "The vector type constructor represents a homogeneous array of values of a " "given type. A vector has a fixed size. (Operations like `vec.push` operate " @@ -5112,7 +5080,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2706 +#: doc/rust.md:2700 msgid "" "Expressions producing vectors of definite size cannot be evaluated in a " "context expecting a vector of indefinite size; one must copy the definite-" @@ -5120,30 +5088,30 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2708 +#: doc/rust.md:2702 msgid "An example of a vector type and its use:" msgstr "" #. type: Plain text -#: doc/rust.md:2714 +#: doc/rust.md:2708 msgid "" "~~~~ let v: &[int] = &[7, 5, 3]; let i: int = v[2]; assert!(i == 3); ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2717 +#: doc/rust.md:2711 msgid "" "All in-bounds elements of a vector are always initialized, and access to a " "vector is always bounds-checked." msgstr "" #. type: Plain text -#: doc/rust.md:2720 +#: doc/rust.md:2714 msgid "### Structure types" msgstr "" #. type: Plain text -#: doc/rust.md:2725 +#: doc/rust.md:2719 msgid "" "A `struct` *type* is a heterogeneous product of other types, called the " "*fields* of the type. ^[`struct` types are analogous `struct` types in C, " @@ -5152,14 +5120,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2727 +#: doc/rust.md:2721 msgid "" "New instances of a `struct` can be constructed with a [struct expression]" "(#struct-expressions)." msgstr "" #. type: Plain text -#: doc/rust.md:2731 +#: doc/rust.md:2725 msgid "" "The memory order of fields in a `struct` is given by the item defining it. " "Fields may be given in any order in a corresponding struct *expression*; the " @@ -5168,7 +5136,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2734 +#: doc/rust.md:2728 msgid "" "The fields of a `struct` may be qualified by [visibility modifiers]" "(#visibility-modifiers), to restrict access to implementation-private data " @@ -5176,14 +5144,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2736 +#: doc/rust.md:2730 msgid "" "A _tuple struct_ type is just like a structure type, except that the fields " "are anonymous." msgstr "" #. type: Plain text -#: doc/rust.md:2739 +#: doc/rust.md:2733 msgid "" "A _unit-like struct_ type is like a structure type, except that it has no " "fields. The one value constructed by the associated [structure expression]" @@ -5191,12 +5159,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2741 +#: doc/rust.md:2735 msgid "### Enumerated types" msgstr "" #. type: Plain text -#: doc/rust.md:2746 +#: doc/rust.md:2740 msgid "" "An *enumerated type* is a nominal, heterogeneous disjoint union type, " "denoted by the name of an [`enum` item](#enumerations). ^[The `enum` type " @@ -5205,7 +5173,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2749 +#: doc/rust.md:2743 msgid "" "An [`enum` item](#enumerations) declares both the type and a number of " "*variant constructors*, each of which is independently named and takes an " @@ -5213,33 +5181,33 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2752 +#: doc/rust.md:2746 msgid "" "New instances of an `enum` can be constructed by calling one of the variant " "constructors, in a [call expression](#call-expressions)." msgstr "" #. type: Plain text -#: doc/rust.md:2754 +#: doc/rust.md:2748 msgid "" "Any `enum` value consumes as much memory as the largest variant constructor " "for its corresponding `enum` type." msgstr "" #. type: Plain text -#: doc/rust.md:2757 +#: doc/rust.md:2751 msgid "" "Enum types cannot be denoted *structurally* as types, but must be denoted by " "named reference to an [`enum` item](#enumerations)." msgstr "" #. type: Plain text -#: doc/rust.md:2760 +#: doc/rust.md:2754 msgid "### Recursive types" msgstr "" #. type: Plain text -#: doc/rust.md:2764 +#: doc/rust.md:2758 msgid "" "Nominal types -- [enumerations](#enumerated-types) and [structures]" "(#structure-types) -- may be recursive. That is, each `enum` constructor or " @@ -5248,7 +5216,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2774 +#: doc/rust.md:2768 #, no-wrap msgid "" "* Recursive types must include a nominal type in the recursion\n" @@ -5263,12 +5231,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2776 +#: doc/rust.md:2770 msgid "An example of a *recursive* type and its use:" msgstr "" #. type: Plain text -#: doc/rust.md:2782 +#: doc/rust.md:2776 #, no-wrap msgid "" "~~~~\n" @@ -5279,17 +5247,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2785 +#: doc/rust.md:2779 msgid "let a: List = Cons(7, @Cons(13, @Nil)); ~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2788 +#: doc/rust.md:2782 msgid "### Pointer types" msgstr "" #. type: Plain text -#: doc/rust.md:2792 +#: doc/rust.md:2786 msgid "" "All pointers in Rust are explicit first-class values. They can be copied, " "stored into data structures, and returned from functions. There are four " @@ -5297,7 +5265,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2802 +#: doc/rust.md:2796 #, no-wrap msgid "" "Managed pointers (`@`)\n" @@ -5312,7 +5280,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2811 +#: doc/rust.md:2805 #, no-wrap msgid "" "Owning pointers (`~`)\n" @@ -5326,7 +5294,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2824 +#: doc/rust.md:2818 #, no-wrap msgid "" "Borrowed pointers (`&`)\n" @@ -5344,7 +5312,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2834 +#: doc/rust.md:2828 #, no-wrap msgid "" "Raw pointers (`*`)\n" @@ -5359,12 +5327,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2837 +#: doc/rust.md:2831 msgid "### Function types" msgstr "" #. type: Plain text -#: doc/rust.md:2841 +#: doc/rust.md:2835 msgid "" "The function type constructor `fn` forms new function types. A function " "type consists of a possibly-empty set of function-type modifiers (such as " @@ -5372,12 +5340,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2843 +#: doc/rust.md:2837 msgid "An example of a `fn` type:" msgstr "" #. type: Plain text -#: doc/rust.md:2848 +#: doc/rust.md:2842 #, no-wrap msgid "" "~~~~~~~~\n" @@ -5387,24 +5355,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2850 +#: doc/rust.md:2844 msgid "let mut x = add(5,7);" msgstr "" #. type: Plain text -#: doc/rust.md:2855 +#: doc/rust.md:2849 msgid "" "type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = " "bo(5,7); ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:2857 +#: doc/rust.md:2851 msgid "### Object types" msgstr "" #. type: Plain text -#: doc/rust.md:2864 +#: doc/rust.md:2858 msgid "" "Every trait item (see [traits](#traits)) defines a type with the same name " "as the trait. This type is called the _object type_ of the trait. Object " @@ -5417,7 +5385,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2869 +#: doc/rust.md:2863 msgid "" "Given a pointer-typed expression `E` of type `&T`, `~T` or `@T`, where `T` " "implements trait `R`, casting `E` to the corresponding pointer type `&R`, " @@ -5427,12 +5395,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2871 +#: doc/rust.md:2865 msgid "An example of an object type:" msgstr "" #. type: Plain text -#: doc/rust.md:2877 +#: doc/rust.md:2871 #, no-wrap msgid "" "~~~~~~~~\n" @@ -5443,7 +5411,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2881 +#: doc/rust.md:2875 #, no-wrap msgid "" "impl Printable for int {\n" @@ -5452,7 +5420,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2885 +#: doc/rust.md:2879 #, no-wrap msgid "" "fn print(a: @Printable) {\n" @@ -5461,7 +5429,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2890 +#: doc/rust.md:2884 #, no-wrap msgid "" "fn main() {\n" @@ -5471,59 +5439,61 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2893 +#: doc/rust.md:2887 msgid "" "In this example, the trait `Printable` occurs as an object type in both the " "type signature of `print`, and the cast expression in `main`." msgstr "" #. type: Plain text -#: doc/rust.md:2895 +#: doc/rust.md:2889 msgid "### Type parameters" msgstr "" #. type: Plain text -#: doc/rust.md:2897 +#: doc/rust.md:2891 msgid "" "Within the body of an item that has type parameter declarations, the names " "of its type parameters are types:" msgstr "" #. type: Plain text -#: doc/rust.md:2906 +#: doc/rust.md:2902 #, no-wrap msgid "" "~~~~~~~\n" -"fn map(f: &fn(A) -> B, xs: &[A]) -> ~[B] {\n" -" if xs.len() == 0 { return ~[]; }\n" -" let first: B = f(copy xs[0]);\n" -" let rest: ~[B] = map(f, xs.slice(1, xs.len()));\n" -" return ~[first] + rest;\n" +"fn map(f: &fn(A) -> B, xs: &[A]) -> ~[B] {\n" +" if xs.len() == 0 {\n" +" return ~[];\n" +" }\n" +" let first: B = f(xs[0].clone());\n" +" let rest: ~[B] = map(f, xs.slice(1, xs.len()));\n" +" return ~[first] + rest;\n" "}\n" "~~~~~~~\n" msgstr "" #. type: Plain text -#: doc/rust.md:2909 +#: doc/rust.md:2905 msgid "" "Here, `first` has type `B`, referring to `map`'s `B` type parameter; and " "`rest` has type `~[B]`, a vector type with element type `B`." msgstr "" #. type: Plain text -#: doc/rust.md:2911 +#: doc/rust.md:2907 msgid "### Self types" msgstr "" #. type: Plain text -#: doc/rust.md:2915 +#: doc/rust.md:2911 msgid "" "The special type `self` has a meaning within methods inside an impl item. It " "refers to the type of the implicit `self` argument. For example, in:" msgstr "" #. type: Plain text -#: doc/rust.md:2920 +#: doc/rust.md:2916 #, no-wrap msgid "" "~~~~~~~~\n" @@ -5533,61 +5503,69 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2925 +#: doc/rust.md:2923 #, no-wrap msgid "" "impl Printable for ~str {\n" -" fn make_string(&self) -> ~str { copy *self }\n" +" fn make_string(&self) -> ~str {\n" +" (*self).clone()\n" +" }\n" "}\n" "~~~~~~~~\n" msgstr "" #. type: Plain text -#: doc/rust.md:2928 +#: doc/rust.md:2926 msgid "" "`self` refers to the value of type `~str` that is the receiver for a call to " "the method `make_string`." msgstr "" #. type: Plain text -#: doc/rust.md:2930 +#: doc/rust.md:2928 msgid "## Type kinds" msgstr "" #. type: Plain text -#: doc/rust.md:2933 +#: doc/rust.md:2931 msgid "" "Types in Rust are categorized into kinds, based on various properties of the " "components of the type. The kinds are:" msgstr "" #. type: Plain text -#: doc/rust.md:2953 +#: doc/rust.md:2957 #, no-wrap msgid "" "`Freeze`\n" " : Types of this kind are deeply immutable;\n" -" they contain no mutable memory locations directly or indirectly via pointers.\n" +" they contain no mutable memory locations\n" +" directly or indirectly via pointers.\n" "`Send`\n" " : Types of this kind can be safely sent between tasks.\n" " This kind includes scalars, owning pointers, owned closures, and\n" -" structural types containing only other owned types. All `Send` types are `Static`.\n" -"`Copy`\n" -" : This kind includes all types that can be copied. All types with\n" -" sendable kind are copyable, as are managed boxes, managed closures,\n" -" trait types, and structural types built out of these.\n" -" Types with destructors (types that implement `Drop`) can not implement `Copy`.\n" +" structural types containing only other owned types.\n" +" All `Send` types are `'static`.\n" +"`'static`\n" +" : Types of this kind do not contain any borrowed pointers;\n" +" this can be a useful guarantee for code\n" +" that breaks borrowing assumptions\n" +" using [`unsafe` operations](#unsafe-functions).\n" "`Drop`\n" -" : This is not strictly a kind, but its presence interacts with kinds: the `Drop`\n" -" trait provides a single method `drop` that takes no parameters, and is run\n" -" when values of the type are dropped. Such a method is called a \"destructor\",\n" -" and are always executed in \"top-down\" order: a value is completely destroyed\n" -" before any of the values it owns run their destructors. Only `Send` types\n" -" that do not implement `Copy` can implement `Drop`.\n" +" : This is not strictly a kind,\n" +" but its presence interacts with kinds:\n" +" the `Drop` trait provides a single method `drop`\n" +" that takes no parameters,\n" +" and is run when values of the type are dropped.\n" +" Such a method is called a \"destructor\",\n" +" and are always executed in \"top-down\" order:\n" +" a value is completely destroyed\n" +" before any of the values it owns run their destructors.\n" +" Only `Send` types can implement `Drop`.\n" msgstr "" #. type: Plain text -#: doc/rust.md:2960 +#: doc/rust.md:2964 #, no-wrap msgid "" "_Default_\n" @@ -5599,67 +5577,36 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:2963 +#: doc/rust.md:2967 msgid "" "Kinds can be supplied as _bounds_ on type parameters, like traits, in which " "case the parameter is constrained to types satisfying that kind." msgstr "" -#. type: Plain text -#: doc/rust.md:2965 -msgid "" -"By default, type parameters do not carry any assumed kind-bounds at all." -msgstr "" - -#. type: Plain text -#: doc/rust.md:2969 -msgid "" -"Any operation that causes a value to be copied requires the type of that " -"value to be of copyable kind, so the `Copy` bound is frequently required on " -"function type parameters. For example, this is not a valid program:" -msgstr "" - #. type: Plain text #: doc/rust.md:2973 -msgid "~~~~{.xfail-test} fn box(x: T) -> @T { @x } ~~~~" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2976 msgid "" -"Putting `x` into a managed box involves copying, and the `T` parameter has " -"the default (non-copyable) kind. To change that, a bound is declared:" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2980 -msgid "~~~~ fn box(x: T) -> @T { @x } ~~~~" -msgstr "" - -#. type: Plain text -#: doc/rust.md:2985 -msgid "" -"Calling this second version of `box` on a noncopyable type is not allowed. " +"By default, type parameters do not carry any assumed kind-bounds at all. " "When instantiating a type parameter, the kind bounds on the parameter are " "checked to be the same or narrower than the kind of the type that it is " "instantiated with." msgstr "" #. type: Plain text -#: doc/rust.md:2989 +#: doc/rust.md:2978 msgid "" "Sending operations are not part of the Rust language, but are implemented in " -"the library. Generic functions that send values bound the kind of these " +"the library. Generic functions that send values bound the kind of these " "values to sendable." msgstr "" #. type: Plain text -#: doc/rust.md:2991 +#: doc/rust.md:2980 msgid "# Memory and concurrency models" msgstr "" #. type: Plain text -#: doc/rust.md:2996 +#: doc/rust.md:2985 msgid "" "Rust has a memory model centered around concurrently-executing _tasks_. Thus " "its memory model and its concurrency model are best discussed " @@ -5668,7 +5615,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3001 +#: doc/rust.md:2990 msgid "" "When reading about the memory model, keep in mind that it is partitioned in " "order to support tasks; and when reading about tasks, keep in mind that " @@ -5677,12 +5624,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3003 +#: doc/rust.md:2992 msgid "## Memory model" msgstr "" #. type: Plain text -#: doc/rust.md:3007 +#: doc/rust.md:2996 msgid "" "A Rust program's memory consists of a static set of *items*, a set of [tasks]" "(#tasks) each with its own *stack*, and a *heap*. Immutable portions of the " @@ -5690,19 +5637,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3010 +#: doc/rust.md:2999 msgid "" "Allocations in the stack consist of *slots*, and allocations in the heap " "consist of *boxes*." msgstr "" #. type: Plain text -#: doc/rust.md:3013 +#: doc/rust.md:3002 msgid "### Memory allocation and lifetime" msgstr "" #. type: Plain text -#: doc/rust.md:3018 +#: doc/rust.md:3007 msgid "" "The _items_ of a program are those functions, modules and types that have " "their value calculated at compile-time and stored uniquely in the memory " @@ -5710,7 +5657,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3022 +#: doc/rust.md:3011 msgid "" "A task's _stack_ consists of activation frames automatically allocated on " "entry to each function as the task executes. A stack allocation is reclaimed " @@ -5718,7 +5665,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3029 +#: doc/rust.md:3018 msgid "" "The _heap_ is a general term that describes two separate sets of boxes: " "managed boxes -- which may be subject to garbage collection -- and owned " @@ -5729,19 +5676,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3031 +#: doc/rust.md:3020 msgid "### Memory ownership" msgstr "" #. type: Plain text -#: doc/rust.md:3034 +#: doc/rust.md:3023 msgid "" "A task owns all memory it can *safely* reach through local variables, as " "well as managed, owning and borrowed pointers." msgstr "" #. type: Plain text -#: doc/rust.md:3041 +#: doc/rust.md:3030 msgid "" "When a task sends a value that has the `Send` trait to another task, it " "loses ownership of the value sent and can no longer refer to it. This is " @@ -5752,14 +5699,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3044 +#: doc/rust.md:3033 msgid "" "When a stack frame is exited, its local allocations are all released, and " "its references to boxes (both managed and owned) are dropped." msgstr "" #. type: Plain text -#: doc/rust.md:3050 +#: doc/rust.md:3039 msgid "" "A managed box may (in the case of a recursive, mutable managed type) be " "cyclic; in this case the release of memory inside the managed structure may " @@ -5769,38 +5716,38 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3053 +#: doc/rust.md:3042 msgid "" "When a task finishes, its stack is necessarily empty and it therefore has no " "references to any boxes; the remainder of its heap is immediately freed." msgstr "" #. type: Plain text -#: doc/rust.md:3056 +#: doc/rust.md:3045 msgid "### Memory slots" msgstr "" #. type: Plain text -#: doc/rust.md:3058 +#: doc/rust.md:3047 msgid "A task's stack contains slots." msgstr "" #. type: Plain text -#: doc/rust.md:3061 +#: doc/rust.md:3050 msgid "" "A _slot_ is a component of a stack frame, either a function parameter, a " "[temporary](#lvalues-rvalues-and-temporaries), or a local variable." msgstr "" #. type: Plain text -#: doc/rust.md:3064 +#: doc/rust.md:3053 msgid "" "A _local variable_ (or *stack-local* allocation) holds a value directly, " "allocated within the stack's memory. The value is a part of the stack frame." msgstr "" #. type: Plain text -#: doc/rust.md:3069 +#: doc/rust.md:3058 msgid "" "Local variables are immutable unless declared with `let mut`. The `mut` " "keyword applies to all local variables declared within that declaration (so " @@ -5808,7 +5755,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3074 +#: doc/rust.md:3063 msgid "" "Function parameters are immutable unless declared with `mut`. The `mut` " "keyword applies only to the following parameter (so `|mut x, y|` and `fn " @@ -5817,7 +5764,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3080 +#: doc/rust.md:3069 msgid "" "Local variables are not initialized when allocated; the entire frame worth " "of local variables are allocated at once, on frame-entry, in an " @@ -5827,31 +5774,31 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3083 +#: doc/rust.md:3072 msgid "### Memory boxes" msgstr "" #. type: Plain text -#: doc/rust.md:3086 +#: doc/rust.md:3075 msgid "" "A _box_ is a reference to a heap allocation holding another value. There are " "two kinds of boxes: *managed boxes* and *owned boxes*." msgstr "" #. type: Plain text -#: doc/rust.md:3088 +#: doc/rust.md:3077 msgid "" "A _managed box_ type or value is constructed by the prefix *at* sigil `@`." msgstr "" #. type: Plain text -#: doc/rust.md:3090 +#: doc/rust.md:3079 msgid "" "An _owned box_ type or value is constructed by the prefix *tilde* sigil `~`." msgstr "" #. type: Plain text -#: doc/rust.md:3095 +#: doc/rust.md:3084 msgid "" "Multiple managed box values can point to the same heap allocation; copying a " "managed box value makes a shallow copy of the pointer (optionally " @@ -5860,41 +5807,39 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3099 +#: doc/rust.md:3086 msgid "" -"Owned box values exist in 1:1 correspondence with their heap allocation; " -"copying an owned box value makes a deep copy of the heap allocation and " -"produces a pointer to the new allocation." +"Owned box values exist in 1:1 correspondence with their heap allocation." msgstr "" #. type: Plain text -#: doc/rust.md:3102 +#: doc/rust.md:3089 msgid "" "An example of constructing one managed box type and value, and one owned box " "type and value:" msgstr "" #. type: Plain text -#: doc/rust.md:3107 +#: doc/rust.md:3094 msgid "~~~~~~~~ let x: @int = @10; let x: ~int = ~10; ~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:3110 +#: doc/rust.md:3097 msgid "" "Some operations (such as field selection) implicitly dereference boxes. An " "example of an _implicit dereference_ operation performed on box values:" msgstr "" #. type: Plain text -#: doc/rust.md:3116 +#: doc/rust.md:3103 msgid "" "~~~~~~~~ struct Foo { y: int } let x = @Foo{y: 10}; assert!(x.y == 10); " "~~~~~~~~" msgstr "" #. type: Plain text -#: doc/rust.md:3122 +#: doc/rust.md:3109 msgid "" "Other operations act on box values as single-word-sized address values. For " "these operations, to access the value held in the box requires an explicit " @@ -5904,33 +5849,33 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3125 +#: doc/rust.md:3112 msgid "copying box values (`x = y`)" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3125 +#: doc/rust.md:3112 msgid "passing box values to functions (`f(x,y)`)" msgstr "" #. type: Plain text -#: doc/rust.md:3128 +#: doc/rust.md:3115 msgid "" "An example of an explicit-dereference operation performed on box values:" msgstr "" #. type: Plain text -#: doc/rust.md:3132 +#: doc/rust.md:3119 msgid "~~~~~~~~ fn takes_boxed(b: @int) { }" msgstr "" #. type: Plain text -#: doc/rust.md:3135 +#: doc/rust.md:3122 msgid "fn takes_unboxed(b: int) { }" msgstr "" #. type: Plain text -#: doc/rust.md:3142 +#: doc/rust.md:3129 #, no-wrap msgid "" "fn main() {\n" @@ -5942,12 +5887,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3144 +#: doc/rust.md:3131 msgid "## Tasks" msgstr "" #. type: Plain text -#: doc/rust.md:3152 +#: doc/rust.md:3139 msgid "" "An executing Rust program consists of a tree of tasks. A Rust _task_ " "consists of an entry function, a stack, a set of outgoing communication " @@ -5958,7 +5903,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3167 +#: doc/rust.md:3154 msgid "" "Multiple Rust tasks may coexist in a single operating-system process. The " "runtime scheduler maps tasks to a certain number of operating-system " @@ -5977,12 +5922,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3170 +#: doc/rust.md:3157 msgid "### Communication between tasks" msgstr "" #. type: Plain text -#: doc/rust.md:3175 +#: doc/rust.md:3162 msgid "" "Rust tasks are isolated and generally unable to interfere with one another's " "memory directly, except through [`unsafe` code](#unsafe-functions). All " @@ -5991,33 +5936,33 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3178 +#: doc/rust.md:3165 msgid "" "Inter-task communication and co-ordination facilities are provided in the " "standard library. These include:" msgstr "" #. type: Bullet: ' - ' -#: doc/rust.md:3182 +#: doc/rust.md:3169 msgid "" "synchronous and asynchronous communication channels with various " "communication topologies" msgstr "" #. type: Bullet: ' - ' -#: doc/rust.md:3182 +#: doc/rust.md:3169 msgid "" "read-only and read-write shared variables with various safe mutual exclusion " "patterns" msgstr "" #. type: Bullet: ' - ' -#: doc/rust.md:3182 +#: doc/rust.md:3169 msgid "simple locks and semaphores" msgstr "" #. type: Plain text -#: doc/rust.md:3187 +#: doc/rust.md:3174 msgid "" "When such facilities carry values, the values are restricted to the [`Send` " "type-kind](#type-kinds). Restricting communication interfaces to this kind " @@ -6028,39 +5973,39 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3190 +#: doc/rust.md:3177 msgid "### Task lifecycle" msgstr "" #. type: Plain text -#: doc/rust.md:3193 +#: doc/rust.md:3180 msgid "" "The _lifecycle_ of a task consists of a finite set of states and events that " "cause transitions between the states. The lifecycle states of a task are:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3198 +#: doc/rust.md:3185 msgid "running" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3198 +#: doc/rust.md:3185 msgid "blocked" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3198 +#: doc/rust.md:3185 msgid "failing" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3198 +#: doc/rust.md:3185 msgid "dead" msgstr "" #. type: Plain text -#: doc/rust.md:3202 +#: doc/rust.md:3189 msgid "" "A task begins its lifecycle -- once it has been spawned -- in the *running* " "state. In this state it executes the statements of its entry function, and " @@ -6068,7 +6013,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3208 +#: doc/rust.md:3195 msgid "" "A task may transition from the *running* state to the *blocked* state any " "time it makes a blocking communication call. When the call can be completed " @@ -6078,7 +6023,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3227 +#: doc/rust.md:3214 msgid "" "A task may transition to the *failing* state at any time, due being killed " "by some external event or internally, from the evaluation of a `fail!()` " @@ -6101,7 +6046,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3231 +#: doc/rust.md:3218 msgid "" "A task in the *dead* state cannot transition to other states; it exists only " "to have its termination status inspected by other tasks, and/or to await " @@ -6109,12 +6054,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3234 +#: doc/rust.md:3221 msgid "### Task scheduling" msgstr "" #. type: Plain text -#: doc/rust.md:3238 +#: doc/rust.md:3225 msgid "" "The currently scheduled task is given a finite *time slice* in which to " "execute, after which it is *descheduled* at a loop-edge or similar " @@ -6122,7 +6067,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3242 +#: doc/rust.md:3229 msgid "" "An executing task can yield control at any time, by making a library call to " "`std::task::yield`, which deschedules it immediately. Entering any other non-" @@ -6130,12 +6075,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3245 +#: doc/rust.md:3232 msgid "# Runtime services, linkage and debugging" msgstr "" #. type: Plain text -#: doc/rust.md:3252 +#: doc/rust.md:3239 msgid "" "The Rust _runtime_ is a relatively compact collection of C++ and Rust code " "that provides fundamental services and datatypes to all Rust tasks at run-" @@ -6145,19 +6090,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3254 +#: doc/rust.md:3241 msgid "" "> **Note:** The runtime library will merge with the `std` library in future " "versions of Rust." msgstr "" #. type: Plain text -#: doc/rust.md:3256 +#: doc/rust.md:3243 msgid "### Memory allocation" msgstr "" #. type: Plain text -#: doc/rust.md:3262 +#: doc/rust.md:3249 msgid "" "The runtime memory-management system is based on a _service-provider " "interface_, through which the runtime requests blocks of memory from its " @@ -6167,7 +6112,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3266 +#: doc/rust.md:3253 msgid "" "The runtime memory-management system, in turn, supplies Rust tasks with " "facilities for allocating, extending and releasing stacks, as well as " @@ -6175,12 +6120,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3268 +#: doc/rust.md:3255 msgid "### Built in types" msgstr "" #. type: Plain text -#: doc/rust.md:3272 +#: doc/rust.md:3259 msgid "" "The runtime provides C and Rust code to assist with various built-in types, " "such as vectors, strings, and the low level communication system (ports, " @@ -6188,19 +6133,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3275 +#: doc/rust.md:3262 msgid "" "Support for other built-in types such as simple types, tuples, records, and " "enums is open-coded by the Rust compiler." msgstr "" #. type: Plain text -#: doc/rust.md:3279 +#: doc/rust.md:3266 msgid "### Task scheduling and communication" msgstr "" #. type: Plain text -#: doc/rust.md:3285 +#: doc/rust.md:3272 msgid "" "The runtime provides code to manage inter-task communication. This includes " "the system of task-lifecycle state transitions depending on the contents of " @@ -6210,12 +6155,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3288 +#: doc/rust.md:3275 msgid "### Logging system" msgstr "" #. type: Plain text -#: doc/rust.md:3292 +#: doc/rust.md:3279 msgid "" "The runtime contains a system for directing [logging expressions](#log-" "expressions) to a logging console and/or internal logging buffers. Logging " @@ -6223,7 +6168,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3299 +#: doc/rust.md:3286 msgid "" "Logging output is enabled by setting the `RUST_LOG` environment variable. " "`RUST_LOG` accepts a logging specification made up of a comma-separated list " @@ -6234,7 +6179,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3307 +#: doc/rust.md:3294 msgid "" "The path to a module consists of the crate name, any parent modules, then " "the module itself, all separated by double colons (`::`). The optional log " @@ -6245,7 +6190,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3313 +#: doc/rust.md:3300 msgid "" "As an example, to see all the logs generated by the compiler, you would set " "`RUST_LOG` to `rustc`, which is the crate name (as specified in its `link` " @@ -6255,17 +6200,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3318 +#: doc/rust.md:3305 msgid "" -"Note that when compiling either `.rs` or `.rc` files that don't specify a " -"crate name the crate is given a default name that matches the source file, " -"with the extension removed. In that case, to turn on logging for a program " -"compiled from, e.g. `helloworld.rs`, `RUST_LOG` should be set to " -"`helloworld`." +"Note that when compiling source files that don't specify a crate name the " +"crate is given a default name that matches the source file, with the " +"extension removed. In that case, to turn on logging for a program compiled " +"from, e.g. `helloworld.rs`, `RUST_LOG` should be set to `helloworld`." msgstr "" #. type: Plain text -#: doc/rust.md:3322 +#: doc/rust.md:3309 msgid "" "As a convenience, the logging spec can also be set to a special pseudo-" "crate, `::help`. In this case, when the application starts, the runtime will " @@ -6273,7 +6217,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3327 +#: doc/rust.md:3314 msgid "" "The Rust runtime itself generates logging information. The runtime's logs " "are generated for a number of artificial modules in the `::rt` pseudo-crate, " @@ -6282,84 +6226,84 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::mem` Memory management" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::comm` Messaging and task communication" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::task` Task management" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::dom` Task scheduling" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::trace` Unused" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::cache` Type descriptor cache" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::upcall` Compiler-generated runtime calls" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::timer` The scheduler timer" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::gc` Garbage collection" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::stdlib` Functions used directly by the standard library" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::kern` The runtime kernel" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::backtrace` Log a backtrace on task failure" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3341 +#: doc/rust.md:3328 msgid "`::rt::callback` Unused" msgstr "" #. type: Plain text -#: doc/rust.md:3343 +#: doc/rust.md:3330 msgid "#### Logging Expressions" msgstr "" #. type: Plain text -#: doc/rust.md:3346 +#: doc/rust.md:3333 msgid "" "Rust provides several macros to log information. Here's a simple Rust " "program that demonstrates all four of them:" msgstr "" #. type: Plain text -#: doc/rust.md:3355 +#: doc/rust.md:3342 #, no-wrap msgid "" "```rust\n" @@ -6373,13 +6317,13 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3357 +#: doc/rust.md:3344 msgid "" "These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:" msgstr "" #. type: Plain text -#: doc/rust.md:3364 +#: doc/rust.md:3351 msgid "" "```bash $ RUST_LOG=rust=3 ./rust rust: ~\"\\\"This is an error log\\\"\" " "rust: ~\"\\\"This is a warn log\\\"\" rust: ~\"\\\"this is an info log\\\"\" " @@ -6387,28 +6331,28 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3366 +#: doc/rust.md:3353 msgid "# Appendix: Rationales and design tradeoffs" msgstr "" #. type: Plain text -#: doc/rust.md:3368 +#: doc/rust.md:3355 #, no-wrap msgid "*TODO*.\n" msgstr "" #. type: Plain text -#: doc/rust.md:3370 +#: doc/rust.md:3357 msgid "# Appendix: Influences and further references" msgstr "" #. type: Plain text -#: doc/rust.md:3372 +#: doc/rust.md:3359 msgid "## Influences" msgstr "" #. type: Plain text -#: doc/rust.md:3381 +#: doc/rust.md:3368 msgid "" "> The essential problem that must be solved in making a fault-tolerant > " "software system is therefore that of fault-isolation. Different programmers " @@ -6419,7 +6363,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3393 +#: doc/rust.md:3380 msgid "" "> In our approach, all data is private to some process, and processes can > " "only communicate through communications channels. *Security*, as used > in " @@ -6431,7 +6375,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3401 +#: doc/rust.md:3388 msgid "" "> Concurrent and applicative programming complement each other. The > " "ability to send messages on channels provides I/O without side effects, > " @@ -6440,7 +6384,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3408 +#: doc/rust.md:3395 msgid "" "Rust is not a particularly original language. It may however appear unusual " "by contemporary standards, as its design elements are drawn from a number of " @@ -6450,7 +6394,7 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3412 +#: doc/rust.md:3399 msgid "" "The NIL (1981) and Hermes (1990) family. These languages were developed by " "Robert Strom, Shaula Yemini, David Bacon and others in their group at IBM " @@ -6458,7 +6402,7 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3416 +#: doc/rust.md:3403 msgid "" "The Erlang (1987) language, developed by Joe Armstrong, Robert Virding, " "Claes Wikström, Mike Williams and others in their group at the Ericsson " @@ -6466,7 +6410,7 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3421 +#: doc/rust.md:3408 msgid "" "The Sather (1990) language, developed by Stephen Omohundro, Chu-Cheow Lim, " "Heinz Schmidt and others in their group at The International Computer " @@ -6475,7 +6419,7 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3426 +#: doc/rust.md:3413 msgid "" "The Newsqueak (1988), Alef (1995), and Limbo (1996) family. These languages " "were developed by Rob Pike, Phil Winterbottom, Sean Dorward and others in " @@ -6484,7 +6428,7 @@ msgid "" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3430 +#: doc/rust.md:3417 msgid "" "The Napier (1985) and Napier88 (1988) family. These languages were developed " "by Malcolm Atkinson, Ron Morrison and others in their group at the " @@ -6492,47 +6436,47 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:3432 +#: doc/rust.md:3419 msgid "" "Additional specific influences can be seen from the following languages:" msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The stack-growth implementation of Go." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The structural algebraic types and compilation manager of SML." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The attribute and assembly systems of C#." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The references and deterministic destructor system of C++." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The memory region systems of the ML Kit and Cyclone." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The typeclass system of Haskell." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The lexical identifier rule of Python." msgstr "" #. type: Bullet: '* ' -#: doc/rust.md:3440 +#: doc/rust.md:3427 msgid "The block syntax of Ruby." msgstr "" diff --git a/doc/po/rustpkg.md.pot b/doc/po/rustpkg.md.pot index 134aa56b3da..9c4fa4b6c2a 100644 --- a/doc/po/rustpkg.md.pot +++ b/doc/po/rustpkg.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-07-30 07:07+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -160,7 +160,7 @@ msgid "# Package identifiers" msgstr "" #. type: Plain text -#: doc/rustpkg.md:79 +#: doc/rustpkg.md:87 msgid "" "A package identifier identifies a package uniquely. A package can be stored " "in a workspace on the local file system, or on a remote Web server, in which " @@ -169,51 +169,59 @@ msgid "" "github.com/mozilla/rust`. A package ID can also specify a version, like: " "`github.com/mozilla/rust#0.3`. In this case, `rustpkg` will check that the " "repository `github.com/mozilla/rust` has a tag named `0.3`, and report an " -"error otherwise." +"error otherwise. A package ID can also specify a particular revision of a " +"repository, like: `github.com/mozilla/rust#release-0.7`. When the refspec " +"(portion of the package ID after the `#`) can't be parsed as a decimal " +"number, rustpkg passes the refspec along to the version control system " +"without interpreting it. rustpkg also interprets any dependencies on such a " +"package ID literally (as opposed to versions, where a newer version " +"satisfies a dependency on an older version). Thus, `github.com/mozilla/" +"rust#5c4cd30f80` is also a valid package ID, since git can deduce that " +"5c4cd30f80 refers to a revision of the desired repository." msgstr "" #. type: Plain text -#: doc/rustpkg.md:81 +#: doc/rustpkg.md:89 msgid "## Source files" msgstr "" #. type: Plain text -#: doc/rustpkg.md:83 +#: doc/rustpkg.md:91 msgid "" "rustpkg searches for four different fixed filenames in order to determine " "the crates to build:" msgstr "" #. type: Bullet: '* ' -#: doc/rustpkg.md:88 +#: doc/rustpkg.md:96 msgid "`main.rs`: Assumed to be a main entry point for building an executable." msgstr "" #. type: Bullet: '* ' -#: doc/rustpkg.md:88 +#: doc/rustpkg.md:96 msgid "`lib.rs`: Assumed to be a library crate." msgstr "" #. type: Bullet: '* ' -#: doc/rustpkg.md:88 +#: doc/rustpkg.md:96 msgid "" "`test.rs`: Assumed to contain tests declared with the `#[test]` attribute." msgstr "" #. type: Bullet: '* ' -#: doc/rustpkg.md:88 +#: doc/rustpkg.md:96 msgid "" "`bench.rs`: Assumed to contain benchmarks declared with the `#[bench]` " "attribute." msgstr "" #. type: Plain text -#: doc/rustpkg.md:90 +#: doc/rustpkg.md:98 msgid "## Versions" msgstr "" #. type: Plain text -#: doc/rustpkg.md:97 +#: doc/rustpkg.md:105 msgid "" "`rustpkg` packages do not need to declare their versions with an attribute " "inside one of the source files, because `rustpkg` infers it from the version " @@ -224,12 +232,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rustpkg.md:99 +#: doc/rustpkg.md:107 msgid "# Dependencies" msgstr "" #. type: Plain text -#: doc/rustpkg.md:103 +#: doc/rustpkg.md:111 msgid "" "rustpkg infers dependencies from `extern mod` directives. Thus, there " "should be no need to pass a `-L` flag to rustpkg to tell it where to find a " @@ -238,12 +246,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rustpkg.md:105 +#: doc/rustpkg.md:113 msgid "# Custom build scripts" msgstr "" #. type: Plain text -#: doc/rustpkg.md:109 +#: doc/rustpkg.md:117 msgid "" "A file called `pkg.rs` at the root level in a workspace is called a *package " "script*. If a package script exists, rustpkg executes it to build the " @@ -251,7 +259,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rustpkg.md:113 +#: doc/rustpkg.md:121 msgid "" "Inside `pkg.rs`, it's possible to call back into rustpkg to finish up the " "build. `rustpkg::api` contains functions to build, install, or clean " @@ -260,17 +268,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rustpkg.md:115 +#: doc/rustpkg.md:123 msgid "# Command reference" msgstr "" #. type: Plain text -#: doc/rustpkg.md:117 +#: doc/rustpkg.md:125 msgid "## build" msgstr "" #. type: Plain text -#: doc/rustpkg.md:123 +#: doc/rustpkg.md:131 msgid "" "`rustpkg build foo` searches for a package with ID `foo` and builds it in " "any workspace(s) where it finds one. Supposing such packages are found in " @@ -279,22 +287,22 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rustpkg.md:125 +#: doc/rustpkg.md:133 msgid "## clean" msgstr "" #. type: Plain text -#: doc/rustpkg.md:127 +#: doc/rustpkg.md:135 msgid "`rustpkg clean foo` deletes the contents of `foo`'s `build` directory." msgstr "" #. type: Plain text -#: doc/rustpkg.md:129 +#: doc/rustpkg.md:137 msgid "## install" msgstr "" #. type: Plain text -#: doc/rustpkg.md:133 +#: doc/rustpkg.md:141 msgid "" "`rustpkg install foo` builds the libraries and/or executables that are " "targets for `foo`, and then installs them either into `foo`'s `lib` and " @@ -303,12 +311,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rustpkg.md:135 +#: doc/rustpkg.md:143 msgid "## test" msgstr "" #. type: Plain text -#: doc/rustpkg.md:137 +#: doc/rustpkg.md:145 msgid "" "`rustpkg test foo` builds `foo`'s `test.rs` file if necessary, then runs the " "resulting test executable." diff --git a/doc/po/tutorial-borrowed-ptr.md.pot b/doc/po/tutorial-borrowed-ptr.md.pot index 816b3eeea61..4678d3ae366 100644 --- a/doc/po/tutorial-borrowed-ptr.md.pot +++ b/doc/po/tutorial-borrowed-ptr.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-07-22 23:37+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -24,7 +24,7 @@ msgid "# Introduction" msgstr "" #. type: Plain text -#: doc/tutorial.md:1111 doc/tutorial-borrowed-ptr.md:72 +#: doc/tutorial.md:1108 doc/tutorial-borrowed-ptr.md:72 msgid "Now we can call `compute_distance()` in various ways:" msgstr "" @@ -60,8 +60,8 @@ msgstr "" msgid "" "Although borrowed pointers have rather elaborate theoretical underpinnings " "(region pointers), the core concepts will be familiar to anyone who has " -"worked with C or C++. Therefore, the best way to explain how they are " -"usedand their limitationsis probably just to work through several examples." +"worked with C or C++. Therefore, the best way to explain how they are used—" +"and their limitations—is probably just to work through several examples." msgstr "" #. type: Plain text @@ -115,7 +115,7 @@ msgid "" "any two points, no matter where they were stored. For example, we might like " "to compute the distance between `on_the_stack` and `managed_box`, or between " "`managed_box` and `owned_box`. One option is to define a function that takes " -"two arguments of type `Point`that is, it takes the points by value. But if " +"two arguments of type `Point`—that is, it takes the points by value. But if " "we define it this way, calling the function will cause the points to be " "copied. For points, this is probably not so bad, but often copies are " "expensive. Worse, if the data type contains mutable fields, copying can " @@ -313,8 +313,8 @@ msgstr "" #. type: Plain text #: doc/tutorial-borrowed-ptr.md:186 msgid "" -"Weve seen a few examples so far of borrowing heap boxes, both managed and " -"owned. Up till this point, weve glossed over issues of safety. As stated in " +"We’ve seen a few examples so far of borrowing heap boxes, both managed and " +"owned. Up till this point, we’ve glossed over issues of safety. As stated in " "the introduction, at runtime a borrowed pointer is simply a pointer, nothing " "more. Therefore, avoiding C's problems with dangling pointers requires a " "compile-time safety check." @@ -626,7 +626,7 @@ msgstr "" #. type: Plain text #: doc/tutorial-borrowed-ptr.md:376 msgid "" -"As an example, lets look at the following `shape` type that can represent " +"As an example, let’s look at the following `shape` type that can represent " "both rectangles and circles:" msgstr "" @@ -792,7 +792,7 @@ msgstr "" #: doc/tutorial-borrowed-ptr.md:483 msgid "" "So far, all of the examples we have looked at, use borrowed pointers in a " -"downward direction. That is, a method or code block creates a borrowed " +"“downward” direction. That is, a method or code block creates a borrowed " "pointer, then uses it within the same scope. It is also possible to return " "borrowed pointers as the result of a function, but as we'll see, doing so " "requires some explicit annotation." @@ -844,7 +844,7 @@ msgstr "" msgid "" "Named lifetimes that appear in function signatures are conceptually the same " "as the other lifetimes we have seen before, but they are a bit abstract: " -"they dont refer to a specific expression within `get_x()`, but rather to " +"they don’t refer to a specific expression within `get_x()`, but rather to " "some expression within the *caller of `get_x()`*. The lifetime `r` is " "actually a kind of *lifetime parameter*: it is defined by the caller to " "`get_x()`, just as the value for the parameter `p` is defined by that caller." @@ -862,7 +862,7 @@ msgstr "" #. type: Plain text #: doc/tutorial-borrowed-ptr.md:526 msgid "" -"To emphasize this point, lets look at a variation on the example, this time " +"To emphasize this point, let’s look at a variation on the example, this time " "one that does not compile:" msgstr "" diff --git a/doc/po/tutorial-container.md.pot b/doc/po/tutorial-container.md.pot index 3435a51dbef..7f4f896076f 100644 --- a/doc/po/tutorial-container.md.pot +++ b/doc/po/tutorial-container.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-08-05 19:40+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -242,40 +242,41 @@ msgstr "" #: doc/tutorial-container.md:112 msgid "" "Containers implement iteration over the contained elements by returning an " -"iterator object. For example, vector slices have four iterators available:" +"iterator object. For example, vector slices several iterators available:" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial-container.md:117 -msgid "`vector.iter()`, for immutable references to the elements" +#: doc/tutorial-container.md:116 +msgid "`iter()` and `rev_iter()`, for immutable references to the elements" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial-container.md:117 -msgid "`vector.mut_iter()`, for mutable references to the elements" -msgstr "" - -#. type: Bullet: '* ' -#: doc/tutorial-container.md:117 +#: doc/tutorial-container.md:116 msgid "" -"`vector.rev_iter()`, for immutable references to the elements in reverse " -"order" +"`mut_iter()` and `mut_rev_iter()`, for mutable references to the elements" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial-container.md:117 +#: doc/tutorial-container.md:116 msgid "" -"`vector.mut_rev_iter()`, for mutable references to the elements in reverse " -"order" +"`consume_iter()` and `consume_rev_iter`, to move the elements out by-value" msgstr "" #. type: Plain text #: doc/tutorial-container.md:119 +msgid "" +"A typical mutable container will implement at least `iter()`, `mut_iter()` " +"and `consume_iter()` along with the reverse variants if it maintains an " +"order." +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:121 msgid "### Freezing" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:123 +#: doc/tutorial-container.md:125 msgid "" "Unlike most other languages with external iterators, Rust has no *iterator " "invalidation*. As long an iterator is still in scope, the compiler will " @@ -283,7 +284,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:128 +#: doc/tutorial-container.md:130 #, no-wrap msgid "" "~~~\n" @@ -293,7 +294,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:134 +#: doc/tutorial-container.md:136 #, no-wrap msgid "" " // the vector is frozen for this scope, the compiler will statically\n" @@ -304,19 +305,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:137 +#: doc/tutorial-container.md:139 msgid "" "These semantics are due to most container iterators being implemented with " "`&` and `&mut`." msgstr "" #. type: Plain text -#: doc/tutorial-container.md:139 +#: doc/tutorial-container.md:141 msgid "## Iterator adaptors" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:143 +#: doc/tutorial-container.md:145 msgid "" "The `IteratorUtil` trait implements common algorithms as methods extending " "every `Iterator` implementation. For example, the `fold` method will " @@ -324,28 +325,28 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:149 +#: doc/tutorial-container.md:151 msgid "" "~~~ let xs = [1, 9, 2, 3, 14, 12]; let result = xs.iter().fold(0, |" "accumulator, item| accumulator - *item); assert_eq!(result, -41); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:151 +#: doc/tutorial-container.md:153 msgid "" "Some adaptors return an adaptor object implementing the `Iterator` trait " "itself:" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:158 +#: doc/tutorial-container.md:160 msgid "" "~~~ let xs = [1, 9, 2, 3, 14, 12]; let ys = [5, 2, 1, 8]; let sum = xs." "iter().chain_(ys.iter()).fold(0, |a, b| a + *b); assert_eq!(sum, 57); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:162 +#: doc/tutorial-container.md:164 msgid "" "Note that some adaptors like the `chain_` method above use a trailing " "underscore to work around an issue with method resolve. The underscores will " @@ -353,17 +354,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:164 +#: doc/tutorial-container.md:166 msgid "## For loops" msgstr "" #. type: Plain text #: doc/tutorial-container.md:168 msgid "" -"The `for` loop syntax is currently in transition, and will switch from the " -"old closure-based iteration protocol to iterator objects. For now, the " -"`advance` adaptor is required as a compatibility shim to use iterators with " -"for loops." +"The `for` keyword can be used as sugar for iterating through any iterator:" msgstr "" #. type: Plain text @@ -419,7 +417,7 @@ msgstr "" msgid "" "// print out the pairs of elements up to (&3, &\"baz\")\n" "for (x, y) in it {\n" -" println(fmt!(\"%d %s\", *x, *y));\n" +" printfln!(\"%d %s\", *x, *y);\n" msgstr "" #. type: Plain text @@ -435,8 +433,8 @@ msgstr "" #. type: Plain text #: doc/tutorial-container.md:204 msgid "" -"// yield and print the last pair from the iterator println(fmt!(\"last: %?" -"\", it.next()));" +"// yield and print the last pair from the iterator printfln!(\"last: %?\", " +"it.next());" msgstr "" #. type: Plain text @@ -577,9 +575,9 @@ msgstr "" #. type: Plain text #: doc/tutorial-container.md:300 msgid "" -"~~~ let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter(); println(fmt!(\"%?" -"\", it.next())); // prints `Some(&1)` println(fmt!(\"%?\", it.next())); // " -"prints `Some(&2)` println(fmt!(\"%?\", it.next_back())); // prints `Some(&6)`" +"~~~ let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter(); printfln!(\"%?\", " +"it.next()); // prints `Some(&1)` printfln!(\"%?\", it.next()); // prints " +"`Some(&2)` printfln!(\"%?\", it.next_back()); // prints `Some(&6)`" msgstr "" #. type: Plain text @@ -588,14 +586,88 @@ msgstr "" msgid "" "// prints `5`, `4` and `3`\n" "for &x in it.invert() {\n" -" println(fmt!(\"%?\", x))\n" +" printfln!(\"%?\", x)\n" "}\n" "~~~\n" msgstr "" #. type: Plain text -#: doc/tutorial-container.md:308 +#: doc/tutorial-container.md:309 msgid "" "The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted " "version of the standard immutable and mutable vector iterators." msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:312 +msgid "" +"The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are " +"`DoubleEndedIterator` implementations if the underlying iterators are." +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:317 +msgid "" +"~~~ let xs = [1, 2, 3, 4]; let ys = [5, 6, 7, 8]; let mut it = xs.iter()." +"chain_(ys.iter()).transform(|&x| x * 2);" +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:319 +msgid "printfln!(\"%?\", it.next()); // prints `Some(2)`" +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:325 +#, no-wrap +msgid "" +"// prints `16`, `14`, `12`, `10`, `8`, `6`, `4`\n" +"for x in it.invert() {\n" +" printfln!(\"%?\", x);\n" +"}\n" +"~~~\n" +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:327 +msgid "## Random-access iterators" +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:331 +msgid "" +"The `RandomAccessIterator` trait represents an iterator offering random " +"access to the whole range. The `indexable` method retrieves the number of " +"elements accessible with the `idx` method." +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:334 +msgid "" +"The `chain_` adaptor is an implementation of `RandomAccessIterator` if the " +"underlying iterators are." +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:343 +msgid "" +"~~~ let xs = [1, 2, 3, 4, 5]; let ys = ~[7, 9, 11]; let mut it = xs.iter()." +"chain_(ys.iter()); printfln!(\"%?\", it.idx(0)); // prints `Some(&1)` " +"printfln!(\"%?\", it.idx(5)); // prints `Some(&7)` printfln!(\"%?\", it." +"idx(7)); // prints `Some(&11)` printfln!(\"%?\", it.idx(8)); // prints `None`" +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:348 +msgid "" +"// yield two elements from the beginning, and one from the end it.next(); it." +"next(); it.next_back();" +msgstr "" + +#. type: Plain text +#: doc/tutorial-container.md:352 +msgid "" +"printfln!(\"%?\", it.idx(0)); // prints `Some(&3)` printfln!(\"%?\", it." +"idx(4)); // prints `Some(&9)` printfln!(\"%?\", it.idx(6)); // prints `None` " +"~~~" +msgstr "" diff --git a/doc/po/tutorial-ffi.md.pot b/doc/po/tutorial-ffi.md.pot index c43b6652331..97d3a44d708 100644 --- a/doc/po/tutorial-ffi.md.pot +++ b/doc/po/tutorial-ffi.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-08-10 07:44+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -24,7 +24,7 @@ msgid "# Introduction" msgstr "" #. type: Plain text -#: doc/tutorial.md:876 doc/tutorial-ffi.md:143 +#: doc/tutorial.md:868 doc/tutorial-ffi.md:143 msgid "# Destructors" msgstr "" @@ -446,11 +446,87 @@ msgstr "" #. type: Plain text #: doc/tutorial-ffi.md:232 +msgid "# Accessing foreign globals" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:236 +msgid "" +"Foreign APIs often export a global variable which could do something like " +"track global state. In order to access these variables, you declare them in " +"`extern` blocks with the `static` keyword:" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:239 +msgid "~~~{.xfail-test} use std::libc;" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:244 +#, no-wrap +msgid "" +"#[link_args = \"-lreadline\"]\n" +"extern {\n" +" static rl_readline_version: libc::c_int;\n" +"}\n" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:250 +#, no-wrap +msgid "" +"fn main() {\n" +" println(fmt!(\"You have readline version %d installed.\",\n" +" rl_readline_version as int));\n" +"}\n" +"~~~\n" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:254 +msgid "" +"Alternatively, you may need to alter global state provided by a foreign " +"interface. To do this, statics can be declared with `mut` so rust can mutate " +"them." +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:258 +msgid "~~~{.xfail-test} use std::libc; use std::ptr;" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:263 +#, no-wrap +msgid "" +"#[link_args = \"-lreadline\"]\n" +"extern {\n" +" static mut rl_prompt: *libc::c_char;\n" +"}\n" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:272 +#, no-wrap +msgid "" +"fn main() {\n" +" do \"[my-awesome-shell] $\".as_c_str |buf| {\n" +" unsafe { rl_prompt = buf; }\n" +" // get a line, process it\n" +" unsafe { rl_prompt = ptr::null(); }\n" +" }\n" +"}\n" +"~~~\n" +msgstr "" + +#. type: Plain text +#: doc/tutorial-ffi.md:274 msgid "# Foreign calling conventions" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:237 +#: doc/tutorial-ffi.md:279 msgid "" "Most foreign code exposes a C ABI, and Rust uses the platform's C calling " "convention by default when calling foreign functions. Some foreign " @@ -460,7 +536,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:246 +#: doc/tutorial-ffi.md:288 #, no-wrap msgid "" "~~~~\n" @@ -474,7 +550,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:250 +#: doc/tutorial-ffi.md:292 msgid "" "The `abi` attribute applies to a foreign module (it cannot be applied to a " "single function within a module), and must be either `\"cdecl\"` or `" @@ -482,12 +558,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:252 +#: doc/tutorial-ffi.md:294 msgid "# Interoperability with foreign code" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:256 +#: doc/tutorial-ffi.md:298 msgid "" "Rust guarantees that the layout of a `struct` is compatible with the " "platform's representation in C. A `#[packed]` attribute is available, which " @@ -496,7 +572,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:263 +#: doc/tutorial-ffi.md:305 msgid "" "Rust's owned and managed boxes use non-nullable pointers as handles which " "point to the contained object. However, they should not be manually created " @@ -508,7 +584,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:268 +#: doc/tutorial-ffi.md:310 msgid "" "Vectors and strings share the same basic memory layout, and utilities are " "available in the `vec` and `str` modules for working with C APIs. Strings " @@ -518,7 +594,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-ffi.md:270 +#: doc/tutorial-ffi.md:312 msgid "" "The standard library includes type aliases and function definitions for the " "C standard library in the `libc` module, and Rust links against `libc` and " diff --git a/doc/po/tutorial-macros.md.pot b/doc/po/tutorial-macros.md.pot index 5487ab5ebbd..1b540ea8b1e 100644 --- a/doc/po/tutorial-macros.md.pot +++ b/doc/po/tutorial-macros.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-07-22 23:37+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -24,7 +24,7 @@ msgid "# Introduction" msgstr "" #. type: Plain text -#: doc/rust.md:2033 doc/rust.md:2174 doc/tutorial-macros.md:323 +#: doc/rust.md:2136 doc/rust.md:2223 doc/tutorial-macros.md:323 msgid "~~~~" msgstr "" diff --git a/doc/po/tutorial-tasks.md.pot b/doc/po/tutorial-tasks.md.pot index ff1f25f83b3..893b3dc1491 100644 --- a/doc/po/tutorial-tasks.md.pot +++ b/doc/po/tutorial-tasks.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-08-08 22:27+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -24,7 +24,7 @@ msgid "# Introduction" msgstr "" #. type: Plain text -#: doc/rust.md:1849 doc/tutorial-tasks.md:649 +#: doc/rust.md:1952 doc/tutorial-tasks.md:648 msgid "# } ~~~~" msgstr "" @@ -249,15 +249,15 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:124 -msgid "~~~ # use std::io::print; # use std::task::spawn; # use std::int;" +#: doc/tutorial-tasks.md:123 +msgid "~~~ # use std::io::print; # use std::task::spawn;" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:131 +#: doc/tutorial-tasks.md:130 #, no-wrap msgid "" -"for int::range(0, 20) |child_task_number| {\n" +"for child_task_number in range(0, 20) {\n" " do spawn {\n" " print(fmt!(\"I am child number %d\\n\", child_task_number));\n" " }\n" @@ -266,12 +266,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:133 +#: doc/tutorial-tasks.md:132 msgid "## Communication" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:138 +#: doc/tutorial-tasks.md:137 msgid "" "Now that we have spawned a new task, it would be nice if we could " "communicate with it. Recall that Rust does not have shared mutable state, so " @@ -280,7 +280,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:143 +#: doc/tutorial-tasks.md:142 msgid "" "A pipe is simply a pair of endpoints: one for sending messages and another " "for receiving messages. Pipes are low-level communication building-blocks " @@ -289,7 +289,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:149 +#: doc/tutorial-tasks.md:148 msgid "" "The simplest way to create a pipe is to use the `pipes::stream` function to " "create a `(Port, Chan)` pair. In Rust parlance, a *channel* is a sending " @@ -298,17 +298,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:153 +#: doc/tutorial-tasks.md:152 msgid "~~~~ # use std::task::spawn; # use std::comm::{stream, Port, Chan};" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:155 +#: doc/tutorial-tasks.md:154 msgid "let (port, chan): (Port, Chan) = stream();" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:160 +#: doc/tutorial-tasks.md:159 #, no-wrap msgid "" "do spawn || {\n" @@ -318,7 +318,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:166 +#: doc/tutorial-tasks.md:165 msgid "" "some_other_expensive_computation(); let result = port.recv(); # fn " "some_expensive_computation() -> int { 42 } # fn " @@ -326,7 +326,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:171 +#: doc/tutorial-tasks.md:170 msgid "" "Let's examine this example in detail. First, the `let` statement creates a " "stream for sending and receiving integers (the left-hand side of the `let`, " @@ -335,14 +335,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:176 +#: doc/tutorial-tasks.md:175 msgid "" "~~~~ # use std::comm::{stream, Chan, Port}; let (port, chan): (Port, " "Chan) = stream(); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:180 +#: doc/tutorial-tasks.md:179 msgid "" "The child task will use the channel to send data to the parent task, which " "will wait to receive the data on the port. The next statement spawns the " @@ -350,7 +350,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:191 +#: doc/tutorial-tasks.md:190 #, no-wrap msgid "" "~~~~\n" @@ -366,7 +366,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:197 +#: doc/tutorial-tasks.md:196 msgid "" "Notice that the creation of the task closure transfers `chan` to the child " "task implicitly: the closure captures `chan` in its environment. Both `Chan` " @@ -376,14 +376,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:201 +#: doc/tutorial-tasks.md:200 msgid "" "Finally, the parent continues with some other expensive computation, then " "waits for the child's result to arrive on the port:" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:210 +#: doc/tutorial-tasks.md:209 msgid "" "~~~~ # use std::comm::{stream}; # fn some_other_expensive_computation() {} # " "let (port, chan) = stream::(); # chan.send(0); " @@ -391,7 +391,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:216 +#: doc/tutorial-tasks.md:215 msgid "" "The `Port` and `Chan` pair created by `stream` enables efficient " "communication between a single sender and a single receiver, but multiple " @@ -401,7 +401,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:222 +#: doc/tutorial-tasks.md:221 msgid "" "~~~ {.xfail-test} # use std::task::{spawn}; # use std::comm::{stream, Port, " "Chan}; # fn some_expensive_computation() -> int { 42 } let (port, chan) = " @@ -409,7 +409,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:226 +#: doc/tutorial-tasks.md:225 #, no-wrap msgid "" "do spawn {\n" @@ -418,7 +418,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:233 +#: doc/tutorial-tasks.md:232 #, no-wrap msgid "" "// ERROR! The previous spawn statement already owns the channel,\n" @@ -430,29 +430,27 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:236 +#: doc/tutorial-tasks.md:235 msgid "" "Instead we can use a `SharedChan`, a type that allows a single `Chan` to be " "shared by multiple senders." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:241 -msgid "" -"~~~ # use std::task::spawn; # use std::comm::{stream, SharedChan}; # use " -"std::uint;" +#: doc/tutorial-tasks.md:239 +msgid "~~~ # use std::task::spawn; # use std::comm::{stream, SharedChan};" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:244 +#: doc/tutorial-tasks.md:242 msgid "let (port, chan) = stream(); let chan = SharedChan::new(chan);" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:252 +#: doc/tutorial-tasks.md:250 #, no-wrap msgid "" -"for uint::range(0, 3) |init_val| {\n" +"for init_val in range(0u, 3) {\n" " // Create a new channel handle to distribute to the child task\n" " let child_chan = chan.clone();\n" " do spawn {\n" @@ -462,14 +460,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:256 +#: doc/tutorial-tasks.md:254 msgid "" "let result = port.recv() + port.recv() + port.recv(); # fn " "some_expensive_computation(_i: uint) -> int { 42 } ~~~" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:265 +#: doc/tutorial-tasks.md:263 msgid "" "Here we transfer ownership of the channel into a new `SharedChan` value. " "Like `Chan`, `SharedChan` is a non-copyable, owned type (sometimes also " @@ -482,7 +480,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:270 +#: doc/tutorial-tasks.md:268 msgid "" "Note that the above `SharedChan` example is somewhat contrived since you " "could also simply use three `stream` pairs, but it serves to illustrate the " @@ -491,12 +489,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:275 +#: doc/tutorial-tasks.md:273 msgid "~~~ # use std::task::spawn; # use std::comm::stream; # use std::vec;" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:284 +#: doc/tutorial-tasks.md:282 #, no-wrap msgid "" "// Create a vector of ports, one for each child task\n" @@ -510,7 +508,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:289 +#: doc/tutorial-tasks.md:287 msgid "" "// Wait on each port, accumulating the results let result = ports.iter()." "fold(0, |accum, port| accum + port.recv() ); # fn " @@ -518,14 +516,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:293 +#: doc/tutorial-tasks.md:291 msgid "" "## Backgrounding computations: Futures With `extra::future`, rust has a " "mechanism for requesting a computation and getting the result later." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:301 +#: doc/tutorial-tasks.md:299 #, no-wrap msgid "" "The basic example below illustrates this.\n" @@ -538,14 +536,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:306 +#: doc/tutorial-tasks.md:304 msgid "" "let mut delayed_fib = extra::future::spawn (|| fib(50) ); make_a_sandwich(); " "println(fmt!(\"fib(50) = %?\", delayed_fib.get())) ~~~" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:312 +#: doc/tutorial-tasks.md:310 msgid "" "The call to `future::spawn` returns immediately a `future` object regardless " "of how long it takes to run `fib(50)`. You can then make yourself a sandwich " @@ -557,17 +555,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:325 +#: doc/tutorial-tasks.md:322 #, no-wrap msgid "" "Here is another example showing how futures allow you to background computations. The workload will\n" "be distributed on the available cores.\n" "~~~\n" "# use std::vec;\n" -"# use std::uint;\n" "fn partial_sum(start: uint) -> f64 {\n" " let mut local_sum = 0f64;\n" -" for uint::range(start*100000, (start+1)*100000) |num| {\n" +" for num in range(start*100000, (start+1)*100000) {\n" " local_sum += (num as f64 + 1.0).pow(&-2.0);\n" " }\n" " local_sum\n" @@ -575,7 +572,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:328 +#: doc/tutorial-tasks.md:325 #, no-wrap msgid "" "fn main() {\n" @@ -583,25 +580,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:336 +#: doc/tutorial-tasks.md:333 #, no-wrap msgid "" " let mut final_res = 0f64;\n" " for ft in futures.mut_iter() {\n" " final_res += ft.get();\n" " }\n" -" println(fmt!(\"^2/6 is not far from : %?\", final_res));\n" +" println(fmt!(\"π^2/6 is not far from : %?\", final_res));\n" "}\n" "~~~\n" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:338 +#: doc/tutorial-tasks.md:335 msgid "## Sharing immutable data without copy: Arc" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:343 +#: doc/tutorial-tasks.md:340 msgid "" "To share immutable data between tasks, a first approach would be to only use " "pipes as we have seen previously. A copy of the data to share would then be " @@ -610,7 +607,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:347 +#: doc/tutorial-tasks.md:344 msgid "" "To tackle this issue, one can use an Atomically Reference Counted wrapper " "(`Arc`) as implemented in the `extra` library of Rust. With an Arc, the data " @@ -619,16 +616,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:355 +#: doc/tutorial-tasks.md:351 msgid "" "Here is a small example showing how to use Arcs. We wish to run concurrently " "several computations on a single large vector of floats. Each task needs the " -"full vector to perform its duty. ~~~ # use std::vec; # use std::uint; # use " -"std::rand; use extra::arc::Arc;" +"full vector to perform its duty. ~~~ # use std::vec; # use std::rand; use " +"extra::arc::Arc;" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:359 +#: doc/tutorial-tasks.md:355 #, no-wrap msgid "" "fn pnorm(nums: &~[float], p: uint) -> float {\n" @@ -637,7 +634,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:363 +#: doc/tutorial-tasks.md:359 #, no-wrap msgid "" "fn main() {\n" @@ -646,22 +643,22 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:365 +#: doc/tutorial-tasks.md:361 #, no-wrap msgid " let numbers_arc = Arc::new(numbers);\n" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:369 +#: doc/tutorial-tasks.md:365 #, no-wrap msgid "" -" for uint::range(1,10) |num| {\n" +" for num in range(1u, 10) {\n" " let (port, chan) = stream();\n" " chan.send(numbers_arc.clone());\n" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:378 +#: doc/tutorial-tasks.md:374 #, no-wrap msgid "" " do spawn {\n" @@ -675,45 +672,45 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:400 +#: doc/tutorial-tasks.md:396 msgid "" "The function `pnorm` performs a simple computation on the vector (it " "computes the sum of its items at the power given as argument and takes the " "inverse power of this value). The Arc on the vector is created by the line " "~~~ # use extra::arc::Arc; # use std::vec; # use std::rand; # let numbers = " -"vec::from_fn(1000000, |_| rand::random::()); let " -"numbers_arc=Arc::new(numbers); ~~~ and a clone of it is sent to each task ~~~ # " -"use extra::arc::Arc; # use std::vec; # use std::rand; # let numbers=vec::" -"from_fn(1000000, |_| rand::random::()); # let numbers_arc = " -"Arc::new(numbers); # let (port, chan) = stream(); chan.send(numbers_arc." +"vec::from_fn(1000000, |_| rand::random::()); let numbers_arc=Arc::" +"new(numbers); ~~~ and a clone of it is sent to each task ~~~ # use extra::" +"arc::Arc; # use std::vec; # use std::rand; # let numbers=vec::" +"from_fn(1000000, |_| rand::random::()); # let numbers_arc = Arc::" +"new(numbers); # let (port, chan) = stream(); chan.send(numbers_arc." "clone()); ~~~ copying only the wrapper and not its contents." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:414 +#: doc/tutorial-tasks.md:410 msgid "" "Each task recovers the underlying data by ~~~ # use extra::arc::Arc; # use " "std::vec; # use std::rand; # let numbers=vec::from_fn(1000000, |_| rand::" -"random::()); # let numbers_arc=Arc::new(numbers); # let (port, chan) = " -"stream(); # chan.send(numbers_arc.clone()); # let local_arc : Arc<~[float]> " -"= port.recv(); let task_numbers = local_arc.get(); ~~~ and can use it as if " -"it were local." +"random::()); # let numbers_arc=Arc::new(numbers); # let (port, chan) " +"= stream(); # chan.send(numbers_arc.clone()); # let local_arc : " +"Arc<~[float]> = port.recv(); let task_numbers = local_arc.get(); ~~~ and can " +"use it as if it were local." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:416 +#: doc/tutorial-tasks.md:412 msgid "" "The `arc` module also implements Arcs around mutable data that are not " "covered here." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:418 +#: doc/tutorial-tasks.md:414 msgid "# Handling task failure" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:427 +#: doc/tutorial-tasks.md:423 msgid "" "Rust has a built-in mechanism for raising exceptions. The `fail!()` macro " "(which can also be written with an error string as an argument: `fail!" @@ -726,29 +723,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:430 +#: doc/tutorial-tasks.md:426 msgid "" "All tasks are, by default, _linked_ to each other. That means that the fates " "of all tasks are intertwined: if one fails, so do all the others." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:438 +#: doc/tutorial-tasks.md:434 msgid "" -"~~~ # use std::task::spawn; # use std::task; # fn do_some_work() { loop " -"{ task::yield() } } # do task::try { // Create a child task that fails do " -"spawn { fail!() }" +"~~~{.xfail-test .linked-failure} # use std::task::spawn; # use std::task; # " +"fn do_some_work() { loop { task::yield() } } # do task::try { // Create a " +"child task that fails do spawn { fail!() }" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:443 +#: doc/tutorial-tasks.md:439 msgid "" "// This will also fail because the task we spawned failed do_some_work(); " "# }; ~~~" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:453 +#: doc/tutorial-tasks.md:449 msgid "" "While it isn't possible for a task to recover from failure, tasks may notify " "each other of failure. The simplest way of handling task failure is with the " @@ -762,10 +759,10 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:467 +#: doc/tutorial-tasks.md:463 #, no-wrap msgid "" -"~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use std::task;\n" "# fn some_condition() -> bool { false }\n" "# fn calculate_result() -> int { 0 }\n" @@ -781,7 +778,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:473 +#: doc/tutorial-tasks.md:469 msgid "" "Unlike `spawn`, the function spawned using `try` may return a value, which " "`try` will dutifully propagate back to the caller in a [`Result`] enum. If " @@ -790,12 +787,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:475 +#: doc/tutorial-tasks.md:471 msgid "[`Result`]: std/result.html" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:480 +#: doc/tutorial-tasks.md:476 msgid "" "> ***Note:*** A failed task does not currently produce a useful error > " "value (`try` always returns `Err(())`). In the > future, it may be possible " @@ -803,14 +800,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:483 +#: doc/tutorial-tasks.md:479 msgid "" "TODO: Need discussion of `future_result` in order to make failure modes " "useful." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:491 +#: doc/tutorial-tasks.md:487 msgid "" "But not all failures are created equal. In some cases you might need to " "abort the entire program (perhaps you're writing an assert which, if it " @@ -822,24 +819,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:493 +#: doc/tutorial-tasks.md:489 msgid "## Failure modes" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:496 +#: doc/tutorial-tasks.md:492 msgid "" "By default, task failure is _bidirectionally linked_, which means that if " "either task fails, it kills the other one." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:510 +#: doc/tutorial-tasks.md:507 #, no-wrap msgid "" -"~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use std::task;\n" -"# fn sleep_forever() { loop { task::yield() } }\n" +"# use std::comm::oneshot;\n" +"# fn sleep_forever() { loop { let (p, c) = oneshot::<()>(); p.recv(); } }\n" "# do task::try {\n" "do spawn {\n" " do spawn {\n" @@ -853,7 +851,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:517 +#: doc/tutorial-tasks.md:514 msgid "" "If you want parent tasks to be able to kill their children, but do not want " "a parent to fail automatically if one of its child task fails, you can call " @@ -864,14 +862,15 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:538 +#: doc/tutorial-tasks.md:536 #, no-wrap msgid "" -"~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use std::comm::{stream, Chan, Port};\n" +"# use std::comm::oneshot;\n" "# use std::task::{spawn, try};\n" "# use std::task;\n" -"# fn sleep_forever() { loop { task::yield() } }\n" +"# fn sleep_forever() { loop { let (p, c) = oneshot::<()>(); p.recv(); } }\n" "# do task::try {\n" "let (receiver, sender): (Port, Chan) = stream();\n" "do spawn { // Bidirectionally linked\n" @@ -890,7 +889,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:544 +#: doc/tutorial-tasks.md:542 msgid "" "Supervised failure is useful in any situation where one task manages " "multiple fallible child tasks, and the parent task can recover if any child " @@ -899,20 +898,21 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:547 +#: doc/tutorial-tasks.md:545 msgid "" "Supervised task failure propagates across multiple generations even if an " "intermediate generation has already exited:" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:563 +#: doc/tutorial-tasks.md:562 #, no-wrap msgid "" -"~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use std::task;\n" -"# fn sleep_forever() { loop { task::yield() } }\n" -"# fn wait_for_a_while() { for 1000.times { task::yield() } }\n" +"# use std::comm::oneshot;\n" +"# fn sleep_forever() { loop { let (p, c) = oneshot::<()>(); p.recv(); } }\n" +"# fn wait_for_a_while() { for _ in range(0, 1000u) { task::yield() } }\n" "# do task::try:: {\n" "do task::spawn_supervised {\n" " do task::spawn_supervised {\n" @@ -927,20 +927,20 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:566 +#: doc/tutorial-tasks.md:565 msgid "" "Finally, tasks can be configured to not propagate failure to each other at " "all, using `task::spawn_unlinked` for _isolated failure_." msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:582 +#: doc/tutorial-tasks.md:581 #, no-wrap msgid "" -"~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use std::task;\n" "# fn random() -> uint { 100 }\n" -"# fn sleep_for(i: uint) { for i.times { task::yield() } }\n" +"# fn sleep_for(i: uint) { for _ in range(0, i) { task::yield() } }\n" "# do task::try::<()> {\n" "let (time1, time2) = (random(), random());\n" "do task::spawn_unlinked {\n" @@ -955,12 +955,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:584 +#: doc/tutorial-tasks.md:583 msgid "## Creating a task with a bi-directional communication path" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:589 +#: doc/tutorial-tasks.md:588 msgid "" "A very common thing to do is to spawn a child task where the parent and " "child both need to exchange messages with each other. The function `extra::" @@ -969,7 +969,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:594 +#: doc/tutorial-tasks.md:593 msgid "" "To see how `DuplexStream()` works, we will create a child task that " "repeatedly receives a `uint` message, converts it to a string, and sends the " @@ -978,10 +978,10 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:607 +#: doc/tutorial-tasks.md:606 #, no-wrap msgid "" -"~~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use extra::comm::DuplexStream;\n" "# use std::uint;\n" "fn stringifier(channel: &DuplexStream<~str, uint>) {\n" @@ -996,7 +996,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:615 +#: doc/tutorial-tasks.md:614 msgid "" "The implementation of `DuplexStream` supports both sending and receiving. " "The `stringifier` function takes a `DuplexStream` that can send strings (the " @@ -1007,15 +1007,15 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:617 +#: doc/tutorial-tasks.md:616 msgid "Here is the code for the parent task:" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:631 +#: doc/tutorial-tasks.md:630 #, no-wrap msgid "" -"~~~~\n" +"~~~{.xfail-test .linked-failure}\n" "# use std::task::spawn;\n" "# use std::uint;\n" "# use extra::comm::DuplexStream;\n" @@ -1031,12 +1031,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:633 +#: doc/tutorial-tasks.md:632 msgid "let (from_child, to_child) = DuplexStream();" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:637 +#: doc/tutorial-tasks.md:636 #, no-wrap msgid "" "do spawn {\n" @@ -1045,23 +1045,23 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:640 +#: doc/tutorial-tasks.md:639 msgid "from_child.send(22); assert!(from_child.recv() == ~\"22\");" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:643 +#: doc/tutorial-tasks.md:642 msgid "from_child.send(23); from_child.send(0);" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:646 +#: doc/tutorial-tasks.md:645 msgid "" "assert!(from_child.recv() == ~\"23\"); assert!(from_child.recv() == ~\"0\");" msgstr "" #. type: Plain text -#: doc/tutorial-tasks.md:653 +#: doc/tutorial-tasks.md:652 msgid "" "The parent task first calls `DuplexStream` to create a pair of bidirectional " "endpoints. It then uses `task::spawn` to create the child task, which " diff --git a/doc/po/tutorial.md.pot b/doc/po/tutorial.md.pot index 5d8a03343ae..2aea69cc573 100644 --- a/doc/po/tutorial.md.pot +++ b/doc/po/tutorial.md.pot @@ -7,13 +7,13 @@ msgid "" msgstr "" "Project-Id-Version: Rust 0.8-pre\n" -"POT-Creation-Date: 2013-07-17 07:18+0900\n" +"POT-Creation-Date: 2013-08-12 02:06+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: Plain text @@ -24,7 +24,7 @@ msgid "# Introduction" msgstr "" #. type: Plain text -#: doc/rust.md:1231 doc/tutorial.md:2177 +#: doc/rust.md:1277 doc/tutorial.md:2176 msgid "" "In type-parameterized functions, methods of the supertrait may be called on " "values of subtrait-bound type parameters. Refering to the previous example " @@ -32,7 +32,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1240 doc/tutorial.md:2186 +#: doc/rust.md:1286 doc/tutorial.md:2185 #, no-wrap msgid "" "~~~\n" @@ -46,7 +46,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/rust.md:1242 doc/tutorial.md:2188 +#: doc/rust.md:1288 doc/tutorial.md:2187 msgid "Likewise, supertrait methods may also be called on trait objects." msgstr "" @@ -226,8 +226,8 @@ msgstr "" #. type: Plain text #: doc/tutorial.md:88 msgid "" -"[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]:" -"\thttps://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust" +"[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]: " +"https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust" msgstr "" #. type: Plain text @@ -296,27 +296,26 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:124 +#: doc/tutorial.md:123 msgid "" -"[wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-" -"developing-Rust [tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz " -"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe" +"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: " +"http://static.rust-lang.org/dist/rust-0.7-install.exe" msgstr "" #. type: Plain text -#: doc/tutorial.md:126 +#: doc/tutorial.md:125 msgid "## Compiling your first program" msgstr "" #. type: Plain text -#: doc/tutorial.md:129 +#: doc/tutorial.md:128 msgid "" "Rust program files are, by convention, given the extension `.rs`. Say we " "have a file `hello.rs` containing this program:" msgstr "" #. type: Plain text -#: doc/tutorial.md:135 +#: doc/tutorial.md:134 #, no-wrap msgid "" "~~~~\n" @@ -327,7 +326,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:139 +#: doc/tutorial.md:138 msgid "" "If the Rust compiler was installed successfully, running `rustc hello.rs` " "will produce an executable called `hello` (or `hello.exe` on Windows) which, " @@ -335,7 +334,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:144 +#: doc/tutorial.md:143 msgid "" "The Rust compiler tries to provide useful information when it encounters an " "error. If you introduce an error into the program (for example, by changing " @@ -344,7 +343,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:150 +#: doc/tutorial.md:149 #, no-wrap msgid "" "~~~~ {.notrust}\n" @@ -355,7 +354,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:157 +#: doc/tutorial.md:156 msgid "" "In its simplest form, a Rust program is a `.rs` file with some types and " "functions defined in it. If it has a `main` function, it can be compiled to " @@ -366,12 +365,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:159 +#: doc/tutorial.md:158 msgid "## Using the rust tool" msgstr "" #. type: Plain text -#: doc/tutorial.md:164 +#: doc/tutorial.md:163 msgid "" "While using `rustc` directly to generate your executables, and then running " "them manually is a perfectly valid way to test your code, for smaller " @@ -380,7 +379,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:170 +#: doc/tutorial.md:169 msgid "" "The `rust` tool provides central access to the other rust tools, as well as " "handy shortcuts for directly running source files. For example, if you have " @@ -389,19 +388,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:173 +#: doc/tutorial.md:172 msgid "" "To get a list of all available commands, simply call `rust` without any " "argument." msgstr "" #. type: Plain text -#: doc/tutorial.md:175 +#: doc/tutorial.md:174 msgid "## Editing Rust code" msgstr "" #. type: Plain text -#: doc/tutorial.md:185 +#: doc/tutorial.md:184 msgid "" "There are vim highlighting and indentation scripts in the Rust source " "distribution under `src/etc/vim/`. There is an emacs mode under `src/etc/" @@ -414,7 +413,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:189 +#: doc/tutorial.md:188 msgid "" "There is ctags support via `src/etc/ctags.rust`, but many other tools and " "editors are not yet supported. If you end up writing a Rust mode for your " @@ -422,19 +421,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:192 +#: doc/tutorial.md:191 msgid "" "[sublime]: http://github.com/dbp/sublime-rust [sublime-pkg]: http://wbond." "net/sublime_packages/package_control" msgstr "" #. type: Plain text -#: doc/tutorial.md:194 +#: doc/tutorial.md:193 msgid "# Syntax basics" msgstr "" #. type: Plain text -#: doc/tutorial.md:202 +#: doc/tutorial.md:201 msgid "" "Assuming you've programmed in any C-family language (C++, Java, JavaScript, " "C#, or PHP), Rust will feel familiar. Code is arranged in blocks delineated " @@ -446,7 +445,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:207 +#: doc/tutorial.md:206 msgid "" "The main surface difference to be aware of is that the condition at the head " "of control structures like `if` and `while` does not require parentheses, " @@ -455,7 +454,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:220 +#: doc/tutorial.md:219 #, no-wrap msgid "" "~~~~\n" @@ -473,7 +472,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:224 +#: doc/tutorial.md:223 msgid "" "The `let` keyword introduces a local variable. Variables are immutable by " "default. To introduce a local variable that you can re-assign later, use " @@ -481,12 +480,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:228 +#: doc/tutorial.md:227 msgid "~~~~ let hi = \"hi\"; let mut count = 0;" msgstr "" #. type: Plain text -#: doc/tutorial.md:234 +#: doc/tutorial.md:233 #, no-wrap msgid "" "while count < 10 {\n" @@ -497,7 +496,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:238 +#: doc/tutorial.md:237 msgid "" "Although Rust can almost always infer the types of local variables, you can " "specify a variable's type by following it with a colon, then the type name. " @@ -505,14 +504,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:244 +#: doc/tutorial.md:243 msgid "" "~~~~ static MONSTER_FACTOR: float = 57.8; let monster_size = MONSTER_FACTOR " "* 10.0; let monster_size: int = 50; ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:253 +#: doc/tutorial.md:252 msgid "" "Local variables may shadow earlier declarations, as in the previous example: " "`monster_size` was first declared as a `float`, and then a second " @@ -525,7 +524,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:259 +#: doc/tutorial.md:258 msgid "" "Rust identifiers start with an alphabetic character or an underscore, and " "after that may contain any sequence of alphabetic characters, numbers, or " @@ -535,7 +534,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:264 +#: doc/tutorial.md:263 #, no-wrap msgid "" "~~~\n" @@ -545,12 +544,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:266 +#: doc/tutorial.md:265 msgid "## Expressions and semicolons" msgstr "" #. type: Plain text -#: doc/tutorial.md:272 +#: doc/tutorial.md:271 msgid "" "Though it isn't apparent in all code, there is a fundamental difference " "between Rust's syntax and predecessors like C. Many constructs that are " @@ -559,7 +558,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:284 +#: doc/tutorial.md:283 #, no-wrap msgid "" "~~~~\n" @@ -576,12 +575,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:286 +#: doc/tutorial.md:285 msgid "But, in Rust, you don't have to repeat the name `price`:" msgstr "" #. type: Plain text -#: doc/tutorial.md:298 +#: doc/tutorial.md:297 #, no-wrap msgid "" "~~~~\n" @@ -598,7 +597,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:304 +#: doc/tutorial.md:303 msgid "" "Both pieces of code are exactly equivalent: they assign a value to `price` " "depending on the condition that holds. Note that there are no semicolons in " @@ -608,7 +607,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:310 +#: doc/tutorial.md:309 msgid "" "Put another way, the semicolon in Rust *ignores the value of an " "expression*. Thus, if the branches of the `if` had looked like `{ 4; }`, " @@ -618,16 +617,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:315 +#: doc/tutorial.md:314 msgid "" "In short, everything that's not a declaration (declarations are `let` for " "variables; `fn` for functions; and any top-level named items such as [traits]" -"(#traits), [enum types](#enums), and [constants](#constants)) is an " -"expression, including function bodies." +"(#traits), [enum types](#enums), and static items) is an expression, " +"including function bodies." msgstr "" #. type: Plain text -#: doc/tutorial.md:323 +#: doc/tutorial.md:322 #, no-wrap msgid "" "~~~~\n" @@ -640,12 +639,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:325 +#: doc/tutorial.md:324 msgid "## Primitive types and literals" msgstr "" #. type: Plain text -#: doc/tutorial.md:332 +#: doc/tutorial.md:331 msgid "" "There are general signed and unsigned integer types, `int` and `uint`, as " "well as 8-, 16-, 32-, and 64-bit variants, `i8`, `u16`, etc. Integers can " @@ -656,7 +655,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:338 +#: doc/tutorial.md:337 msgid "" "In the absence of an integer literal suffix, Rust will infer the integer " "type based on type annotations and function signatures in the surrounding " @@ -665,7 +664,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:345 +#: doc/tutorial.md:344 #, no-wrap msgid "" "~~~~\n" @@ -677,7 +676,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:350 +#: doc/tutorial.md:349 msgid "" "There are three floating-point types: `float`, `f32`, and `f64`. Floating-" "point numbers are written `0.0`, `1e6`, or `2.1e-4`. Like integers, " @@ -686,12 +685,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:352 +#: doc/tutorial.md:351 msgid "The keywords `true` and `false` produce literals of type `bool`." msgstr "" #. type: Plain text -#: doc/tutorial.md:359 +#: doc/tutorial.md:358 msgid "" "Characters, the `char` type, are four-byte Unicode codepoints, whose " "literals are written between single quotes, as in `'x'`. Just like C, Rust " @@ -702,17 +701,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:361 +#: doc/tutorial.md:360 msgid "The nil type, written `()`, has a single value, also written `()`." msgstr "" #. type: Plain text -#: doc/tutorial.md:363 +#: doc/tutorial.md:362 msgid "## Operators" msgstr "" #. type: Plain text -#: doc/tutorial.md:368 +#: doc/tutorial.md:367 msgid "" "Rust's set of operators contains very few surprises. Arithmetic is done with " "`*`, `/`, `%`, `+`, and `-` (multiply, quotient, remainder, add, and " @@ -721,14 +720,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:371 +#: doc/tutorial.md:370 msgid "" "Note that, if applied to an integer value, `!` flips all the bits (like `~` " "in C)." msgstr "" #. type: Plain text -#: doc/tutorial.md:375 +#: doc/tutorial.md:374 msgid "" "The comparison operators are the traditional `==`, `!=`, `<`, `>`, `<=`, and " "`>=`. Short-circuiting (lazy) boolean operators are written `&&` (and) and " @@ -736,7 +735,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:380 +#: doc/tutorial.md:379 msgid "" "For type casting, Rust uses the binary `as` operator. It takes an " "expression on the left side and a type on the right side and will, if a " @@ -745,18 +744,18 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:386 +#: doc/tutorial.md:385 msgid "" "~~~~ let x: float = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:388 +#: doc/tutorial.md:387 msgid "## Syntax extensions" msgstr "" #. type: Plain text -#: doc/tutorial.md:395 +#: doc/tutorial.md:394 #, no-wrap msgid "" "*Syntax extensions* are special forms that are not built into the language,\n" @@ -768,7 +767,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:399 +#: doc/tutorial.md:398 msgid "" "`fmt!` supports most of the directives that [printf][pf] supports, but " "unlike printf, will give you a compile-time error when the types of the " @@ -776,51 +775,46 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:402 +#: doc/tutorial.md:401 msgid "~~~~ # let mystery_object = ();" msgstr "" #. type: Plain text -#: doc/tutorial.md:404 +#: doc/tutorial.md:403 msgid "println(fmt!(\"%s is %d\", \"the answer\", 43));" msgstr "" #. type: Plain text -#: doc/tutorial.md:408 +#: doc/tutorial.md:407 msgid "" "// %? will conveniently print any type println(fmt!(\"what is this thing: %?" "\", mystery_object)); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:410 +#: doc/tutorial.md:409 msgid "[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf" msgstr "" #. type: Plain text -#: doc/tutorial.md:412 +#: doc/tutorial.md:411 msgid "" "You can define your own syntax extensions with the macro system. For " "details, see the [macro tutorial][macros]." msgstr "" #. type: Plain text -#: doc/tutorial.md:414 -msgid "[macros]: tutorial-macros.html" -msgstr "" - -#. type: Plain text -#: doc/tutorial.md:416 +#: doc/tutorial.md:413 msgid "# Control structures" msgstr "" #. type: Plain text -#: doc/tutorial.md:418 +#: doc/tutorial.md:415 msgid "## Conditionals" msgstr "" #. type: Plain text -#: doc/tutorial.md:422 +#: doc/tutorial.md:419 msgid "" "We've seen `if` expressions a few times already. To recap, braces are " "compulsory, an `if` can have an optional `else` clause, and multiple `if`/" @@ -828,7 +822,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:432 +#: doc/tutorial.md:429 #, no-wrap msgid "" "~~~~\n" @@ -843,7 +837,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:437 +#: doc/tutorial.md:434 msgid "" "The condition given to an `if` construct *must* be of type `bool` (no " "implicit conversion happens). If the arms are blocks that have a value, this " @@ -852,7 +846,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:445 +#: doc/tutorial.md:442 #, no-wrap msgid "" "~~~~\n" @@ -865,12 +859,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:447 +#: doc/tutorial.md:444 msgid "## Pattern matching" msgstr "" #. type: Plain text -#: doc/tutorial.md:453 +#: doc/tutorial.md:450 msgid "" "Rust's `match` construct is a generalized, cleaned-up version of C's " "`switch` construct. You provide it with a value and a number of *arms*, each " @@ -880,7 +874,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:463 +#: doc/tutorial.md:460 #, no-wrap msgid "" "~~~~\n" @@ -895,7 +889,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:467 +#: doc/tutorial.md:464 msgid "" "Unlike in C, there is no \"falling through\" between arms: only one arm " "executes, and it doesn't have to explicitly `break` out of the construct " @@ -903,7 +897,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:477 +#: doc/tutorial.md:474 msgid "" "A `match` arm consists of a *pattern*, then an arrow `=>`, followed by an " "*action* (expression). Literals are valid patterns and match only their own " @@ -916,7 +910,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:482 +#: doc/tutorial.md:479 msgid "" "The patterns in a match arm are followed by a fat arrow, `=>`, then an " "expression to evaluate. Each case is separated by commas. It's often " @@ -925,7 +919,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:490 +#: doc/tutorial.md:487 #, no-wrap msgid "" "~~~\n" @@ -938,7 +932,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:495 +#: doc/tutorial.md:492 msgid "" "`match` constructs must be *exhaustive*: they must have an arm covering " "every possible case. For example, the typechecker would reject the previous " @@ -946,14 +940,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:499 +#: doc/tutorial.md:496 msgid "" "A powerful application of pattern matching is *destructuring*: matching in " "order to bind names to the contents of data types." msgstr "" #. type: Plain text -#: doc/tutorial.md:503 +#: doc/tutorial.md:500 msgid "" "> ***Note:*** The following code makes use of tuples (`(float, float)`) " "which > are explained in section 5.3. For now you can think of tuples as a " @@ -961,12 +955,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:516 +#: doc/tutorial.md:513 #, no-wrap msgid "" "~~~~\n" -"# use std::float;\n" -"# use std::num::atan;\n" +"use std::float;\n" +"use std::num::atan;\n" "fn angle(vector: (float, float)) -> float {\n" " let pi = float::consts::pi;\n" " match vector {\n" @@ -979,7 +973,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:522 +#: doc/tutorial.md:519 msgid "" "A variable name in a pattern matches any value, *and* binds that name to the " "value of the matched value inside of the arm's action. Thus, `(0f, y)` " @@ -989,7 +983,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:529 +#: doc/tutorial.md:526 msgid "" "Any `match` arm can have a guard clause (written `if EXPR`), called a " "*pattern guard*, which is an expression of type `bool` that determines, " @@ -999,7 +993,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:534 +#: doc/tutorial.md:531 msgid "" "You've already seen simple `let` bindings, but `let` is a little fancier " "than you've been led to believe. It, too, supports destructuring patterns. " @@ -1008,14 +1002,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:539 +#: doc/tutorial.md:536 msgid "" "~~~~ # fn get_tuple_of_two_ints() -> (int, int) { (1, 1) } let (a, b) = " "get_tuple_of_two_ints(); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:543 +#: doc/tutorial.md:540 msgid "" "Let bindings only work with _irrefutable_ patterns: that is, patterns that " "can never fail to match. This excludes `let` from matching literals and most " @@ -1023,12 +1017,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:545 +#: doc/tutorial.md:542 msgid "## Loops" msgstr "" #. type: Plain text -#: doc/tutorial.md:550 +#: doc/tutorial.md:547 msgid "" "`while` denotes a loop that iterates as long as its given condition (which " "must have type `bool`) evaluates to `true`. Inside a loop, the keyword " @@ -1037,7 +1031,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:557 +#: doc/tutorial.md:554 #, no-wrap msgid "" "~~~~\n" @@ -1049,18 +1043,18 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:559 +#: doc/tutorial.md:556 msgid "" "`loop` denotes an infinite loop, and is the preferred way of writing `while " "true`:" msgstr "" #. type: Plain text -#: doc/tutorial.md:569 +#: doc/tutorial.md:566 #, no-wrap msgid "" "~~~~\n" -"# use std::int;\n" +"use std::int;\n" "let mut x = 5;\n" "loop {\n" " x += x - 3;\n" @@ -1071,33 +1065,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:572 +#: doc/tutorial.md:569 msgid "" "This code prints out a weird sequence of numbers and stops as soon as it " "finds one that can be divided by five." msgstr "" #. type: Plain text -#: doc/tutorial.md:577 -msgid "" -"Rust also has a `for` construct. It's different from C's `for` and it works " -"best when iterating over collections. See the section on [closures]" -"(#closures) to find out how to use `for` and higher-order functions for " -"enumerating elements of a collection." -msgstr "" - -#. type: Plain text -#: doc/tutorial.md:579 +#: doc/tutorial.md:571 msgid "# Data structures" msgstr "" #. type: Plain text -#: doc/tutorial.md:581 +#: doc/tutorial.md:573 msgid "## Structs" msgstr "" #. type: Plain text -#: doc/tutorial.md:586 +#: doc/tutorial.md:578 msgid "" "Rust struct types must be declared before they are used using the `struct` " "syntax: `struct Name { field1: T1, field2: T2 [, ...] }`, where `T1`, " @@ -1106,7 +1091,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:590 +#: doc/tutorial.md:582 msgid "" "Structs are quite similar to C structs and are even laid out the same way in " "memory (so you can read from a Rust struct in C, and vice-versa). Use the " @@ -1114,7 +1099,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:597 +#: doc/tutorial.md:589 #, no-wrap msgid "" "~~~~\n" @@ -1126,7 +1111,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:601 +#: doc/tutorial.md:593 msgid "" "Inherited mutability means that any field of a struct may be mutable, if the " "struct is in a mutable slot (or a field of a struct in a mutable slot, and " @@ -1134,7 +1119,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:605 +#: doc/tutorial.md:597 msgid "" "With a value (say, `mypoint`) of such a type in a mutable location, you can " "do `mypoint.y += 1.0`. But in an immutable location, such an assignment to a " @@ -1142,28 +1127,28 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:610 +#: doc/tutorial.md:602 msgid "" "~~~~ {.xfail-test} # struct Point { x: float, y: float } let mut mypoint = " "Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };" msgstr "" #. type: Plain text -#: doc/tutorial.md:614 +#: doc/tutorial.md:606 msgid "" "mypoint.y += 1.0; // mypoint is mutable, and its fields as well origin.y += " "1.0; // ERROR: assigning to immutable field ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:617 +#: doc/tutorial.md:609 msgid "" "`match` patterns destructure structs. The basic syntax is `Name { fieldname: " "pattern, ... }`:" msgstr "" #. type: Plain text -#: doc/tutorial.md:626 +#: doc/tutorial.md:618 #, no-wrap msgid "" "~~~~\n" @@ -1177,7 +1162,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:633 +#: doc/tutorial.md:625 msgid "" "In general, the field names of a struct do not have to appear in the same " "order they appear in the type. When you are not interested in all the fields " @@ -1188,7 +1173,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:641 +#: doc/tutorial.md:633 #, no-wrap msgid "" "~~~\n" @@ -1201,19 +1186,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:643 +#: doc/tutorial.md:635 msgid "## Enums" msgstr "" #. type: Plain text -#: doc/tutorial.md:646 +#: doc/tutorial.md:638 msgid "" "Enums are datatypes that have several alternate representations. For " "example, consider the type shown earlier:" msgstr "" #. type: Plain text -#: doc/tutorial.md:654 +#: doc/tutorial.md:646 #, no-wrap msgid "" "~~~~\n" @@ -1226,7 +1211,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:660 +#: doc/tutorial.md:652 msgid "" "A value of this type is either a `Circle`, in which case it contains a " "`Point` struct and a float, or a `Rectangle`, in which case it contains two " @@ -1236,7 +1221,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:666 +#: doc/tutorial.md:658 msgid "" "The above declaration will define a type `Shape` that can refer to such " "shapes, and two functions, `Circle` and `Rectangle`, which can be used to " @@ -1245,14 +1230,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:669 +#: doc/tutorial.md:661 msgid "" "Enum variants need not have parameters. This `enum` declaration, for " "example, is equivalent to a C enum:" msgstr "" #. type: Plain text -#: doc/tutorial.md:678 +#: doc/tutorial.md:670 #, no-wrap msgid "" "~~~~\n" @@ -1266,14 +1251,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:681 +#: doc/tutorial.md:673 msgid "" "This declaration defines `North`, `East`, `South`, and `West` as constants, " "all of which have type `Direction`." msgstr "" #. type: Plain text -#: doc/tutorial.md:685 +#: doc/tutorial.md:677 msgid "" "When an enum is C-like (that is, when none of the variants have parameters), " "it is possible to explicitly set the discriminator values to a constant " @@ -1281,7 +1266,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:693 +#: doc/tutorial.md:685 #, no-wrap msgid "" "~~~~\n" @@ -1294,7 +1279,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:698 +#: doc/tutorial.md:690 msgid "" "If an explicit discriminator is not specified for a variant, the value " "defaults to the value of the previous variant plus one. If the first variant " @@ -1303,14 +1288,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:701 +#: doc/tutorial.md:693 msgid "" "When an enum is C-like, you can apply the `as` cast operator to convert it " "to its discriminator value as an `int`." msgstr "" #. type: Plain text -#: doc/tutorial.md:705 +#: doc/tutorial.md:697 msgid "" "For enum types with multiple variants, destructuring is the only way to get " "at their contents. All variant constructors can be used as patterns, as in " @@ -1318,11 +1303,11 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:717 +#: doc/tutorial.md:709 #, no-wrap msgid "" "~~~~\n" -"# use std::float;\n" +"use std::float;\n" "# struct Point {x: float, y: float}\n" "# enum Shape { Circle(Point, float), Rectangle(Point, Point) }\n" "fn area(sh: Shape) -> float {\n" @@ -1335,7 +1320,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:722 +#: doc/tutorial.md:714 msgid "" "You can write a lone `_` to ignore an individual field, and can ignore all " "fields of a variant like: `Circle(*)`. As in their introduction form, " @@ -1343,7 +1328,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:735 +#: doc/tutorial.md:727 #, no-wrap msgid "" "~~~~\n" @@ -1361,16 +1346,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:737 +#: doc/tutorial.md:729 msgid "Enum variants may also be structs. For example:" msgstr "" #. type: Plain text -#: doc/tutorial.md:755 +#: doc/tutorial.md:747 #, no-wrap msgid "" "~~~~\n" -"# use std::float;\n" +"use std::float;\n" "# struct Point { x: float, y: float }\n" "# fn square(x: float) -> float { x * x }\n" "enum Shape {\n" @@ -1389,12 +1374,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:757 +#: doc/tutorial.md:749 msgid "## Tuples" msgstr "" #. type: Plain text -#: doc/tutorial.md:762 +#: doc/tutorial.md:754 msgid "" "Tuples in Rust behave exactly like structs, except that their fields do not " "have names. Thus, you cannot access their fields with dot notation. Tuples " @@ -1403,7 +1388,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:769 +#: doc/tutorial.md:761 #, no-wrap msgid "" "~~~~\n" @@ -1415,12 +1400,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:771 +#: doc/tutorial.md:763 msgid "## Tuple structs" msgstr "" #. type: Plain text -#: doc/tutorial.md:776 +#: doc/tutorial.md:768 msgid "" "Rust also has _tuple structs_, which behave like both structs and tuples, " "except that, unlike tuples, tuple structs have names (so `Foo(1, 2)` has a " @@ -1429,7 +1414,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:785 +#: doc/tutorial.md:777 #, no-wrap msgid "" "For example:\n" @@ -1443,12 +1428,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:787 +#: doc/tutorial.md:779 msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:792 +#: doc/tutorial.md:784 msgid "" "There is a special case for tuple structs with a single field, which are " "sometimes called \"newtypes\" (after Haskell's \"newtype\" feature). These " @@ -1457,50 +1442,50 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:796 +#: doc/tutorial.md:788 msgid "~~~~ struct GizmoId(int); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:799 +#: doc/tutorial.md:791 msgid "" "For convenience, you can extract the contents of such a struct with the " "dereference (`*`) unary operator:" msgstr "" #. type: Plain text -#: doc/tutorial.md:805 +#: doc/tutorial.md:797 msgid "" "~~~~ # struct GizmoId(int); let my_gizmo_id: GizmoId = GizmoId(10); let " "id_int: int = *my_gizmo_id; ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:808 +#: doc/tutorial.md:800 msgid "" "Types like this can be useful to differentiate between data that have the " "same type but must be used in different ways." msgstr "" #. type: Plain text -#: doc/tutorial.md:813 +#: doc/tutorial.md:805 msgid "~~~~ struct Inches(int); struct Centimeters(int); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:816 +#: doc/tutorial.md:808 msgid "" "The above definitions allow for a simple way for programs to avoid confusing " "numbers that correspond to different units." msgstr "" #. type: Plain text -#: doc/tutorial.md:818 +#: doc/tutorial.md:810 msgid "# Functions" msgstr "" #. type: Plain text -#: doc/tutorial.md:826 +#: doc/tutorial.md:818 msgid "" "We've already seen several function definitions. Like all other static " "declarations, such as `type`, functions can be declared both at the top " @@ -1512,7 +1497,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:832 +#: doc/tutorial.md:824 #, no-wrap msgid "" "~~~~\n" @@ -1523,7 +1508,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:837 +#: doc/tutorial.md:829 msgid "" "The `return` keyword immediately returns from the body of a function. It is " "optionally followed by an expression to return. A function can also return a " @@ -1531,7 +1516,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:843 +#: doc/tutorial.md:835 #, no-wrap msgid "" "~~~~\n" @@ -1542,7 +1527,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:850 +#: doc/tutorial.md:842 msgid "" "It's better Rust style to write a return value this way instead of writing " "an explicit `return`. The utility of `return` comes in when returning early " @@ -1552,35 +1537,35 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:853 +#: doc/tutorial.md:845 msgid "~~~~ fn do_nothing_the_hard_way() -> () { return (); }" msgstr "" #. type: Plain text -#: doc/tutorial.md:856 +#: doc/tutorial.md:848 msgid "fn do_nothing_the_easy_way() { } ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:858 +#: doc/tutorial.md:850 msgid "" "Ending the function with a semicolon like so is equivalent to returning `()`." msgstr "" #. type: Plain text -#: doc/tutorial.md:862 +#: doc/tutorial.md:854 msgid "" "~~~~ fn line(a: int, b: int, x: int) -> int { a * x + b } fn oops(a: int, b: " "int, x: int) -> () { a * x + b; }" msgstr "" #. type: Plain text -#: doc/tutorial.md:866 +#: doc/tutorial.md:858 msgid "assert!(8 == line(5, 3, 1)); assert!(() == oops(5, 3, 1)); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:870 +#: doc/tutorial.md:862 msgid "" "As with `match` expressions and `let` bindings, function arguments support " "pattern destructuring. Like `let`, argument patterns must be irrefutable, as " @@ -1588,17 +1573,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:874 +#: doc/tutorial.md:866 msgid "~~~ fn first((value, _): (int, float)) -> int { value } ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:876 doc/tutorial-ffi.md:143 +#: doc/tutorial.md:868 doc/tutorial-ffi.md:143 msgid "# Destructors" msgstr "" #. type: Plain text -#: doc/tutorial.md:880 +#: doc/tutorial.md:872 msgid "" "A *destructor* is a function responsible for cleaning up the resources used " "by an object when it is no longer accessible. Destructors can be defined to " @@ -1606,7 +1591,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:884 +#: doc/tutorial.md:876 msgid "" "Objects are never accessible after their destructor has been called, so " "there are no dynamic failures from accessing freed resources. When a task " @@ -1614,13 +1599,13 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:886 +#: doc/tutorial.md:878 msgid "" "The `~` sigil represents a unique handle for a memory allocation on the heap:" msgstr "" #. type: Plain text -#: doc/tutorial.md:894 +#: doc/tutorial.md:886 #, no-wrap msgid "" "~~~~\n" @@ -1633,7 +1618,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:898 +#: doc/tutorial.md:890 msgid "" "Rust includes syntax for heap memory allocation in the language since it's " "commonly used, but the same semantics can be implemented by a type with a " @@ -1641,12 +1626,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:900 +#: doc/tutorial.md:892 msgid "# Ownership" msgstr "" #. type: Plain text -#: doc/tutorial.md:905 +#: doc/tutorial.md:897 msgid "" "Rust formalizes the concept of object ownership to delegate management of an " "object's lifetime to either a variable or a task-local garbage collector. An " @@ -1656,7 +1641,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:911 +#: doc/tutorial.md:903 msgid "" "Ownership is recursive, so mutability is inherited recursively and a " "destructor destroys the contained tree of owned objects. Variables are top-" @@ -1666,14 +1651,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:915 +#: doc/tutorial.md:907 msgid "" "~~~~ // the struct owns the objects contained in the `x` and `y` fields " "struct Foo { x: int, y: ~int }" msgstr "" #. type: Plain text -#: doc/tutorial.md:922 +#: doc/tutorial.md:914 #, no-wrap msgid "" "{\n" @@ -1685,14 +1670,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:927 +#: doc/tutorial.md:919 msgid "" "// `b` is mutable, and the mutability is inherited by the objects it owns " "let mut b = Foo { x: 5, y: ~10 }; b.x = 10; ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:933 +#: doc/tutorial.md:925 msgid "" "If an object doesn't contain garbage-collected boxes, it consists of a " "single ownership tree and is given the `Owned` trait which allows it to be " @@ -1702,12 +1687,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:935 +#: doc/tutorial.md:927 msgid "# Boxes" msgstr "" #. type: Plain text -#: doc/tutorial.md:942 +#: doc/tutorial.md:934 msgid "" "Many modern languages represent values as pointers to heap memory by " "default. In contrast, Rust, like C and C++, represents such types directly. " @@ -1718,7 +1703,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:947 +#: doc/tutorial.md:939 msgid "" "For small structs like `Point`, this is usually more efficient than " "allocating memory and indirecting through a pointer. But for big structs, or " @@ -1727,31 +1712,31 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:949 +#: doc/tutorial.md:941 msgid "## Owned boxes" msgstr "" #. type: Plain text -#: doc/tutorial.md:952 +#: doc/tutorial.md:944 msgid "" "An owned box (`~`) is a uniquely owned allocation on the heap. It inherits " "the mutability and lifetime of the owner as it would if there was no box:" msgstr "" #. type: Plain text -#: doc/tutorial.md:957 +#: doc/tutorial.md:949 msgid "~~~~ let x = 5; // immutable let mut y = 5; // mutable y += 2;" msgstr "" #. type: Plain text -#: doc/tutorial.md:962 +#: doc/tutorial.md:954 msgid "" "let x = ~5; // immutable let mut y = ~5; // mutable *y += 2; // the * " "operator is needed to access the contained value ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:967 +#: doc/tutorial.md:959 msgid "" "The purpose of an owned box is to add a layer of indirection in order to " "create recursive data structures or cheaply pass around an object larger " @@ -1760,14 +1745,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:970 +#: doc/tutorial.md:962 msgid "" "The following struct won't compile, because the lack of indirection would " "mean it has an infinite size:" msgstr "" #. type: Plain text -#: doc/tutorial.md:976 +#: doc/tutorial.md:968 #, no-wrap msgid "" "~~~~ {.xfail-test}\n" @@ -1778,7 +1763,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:980 +#: doc/tutorial.md:972 msgid "" "> ***Note:*** The `Option` type is an enum that represents an *optional* " "value. > It's comparable to a nullable pointer in many other languages, but " @@ -1786,7 +1771,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:984 +#: doc/tutorial.md:976 msgid "" "Adding indirection with an owned pointer allocates the child outside of the " "struct on the heap, which makes it a finite size and won't result in a " @@ -1794,7 +1779,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:990 +#: doc/tutorial.md:982 #, no-wrap msgid "" "~~~~\n" @@ -1805,46 +1790,46 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:992 +#: doc/tutorial.md:984 msgid "## Managed boxes" msgstr "" #. type: Plain text -#: doc/tutorial.md:1000 +#: doc/tutorial.md:992 msgid "" "A managed box (`@`) is a heap allocation with the lifetime managed by a task-" "local garbage collector. It will be destroyed at some point after there are " "no references left to the box, no later than the end of the task. Managed " "boxes lack an owner, so they start a new ownership tree and don't inherit " "mutability. They do own the contained object, and mutability is defined by " -"the type of the shared box (`@` or `@mut`). An object containing a managed " +"the type of the managed box (`@` or `@mut`). An object containing a managed " "box is not `Owned`, and can't be sent between tasks." msgstr "" #. type: Plain text -#: doc/tutorial.md:1003 +#: doc/tutorial.md:995 msgid "~~~~ let a = @5; // immutable" msgstr "" #. type: Plain text -#: doc/tutorial.md:1006 +#: doc/tutorial.md:998 msgid "let mut b = @5; // mutable variable, immutable box b = @10;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1009 +#: doc/tutorial.md:1001 msgid "let c = @mut 5; // immutable variable, mutable box *c = 10;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1014 +#: doc/tutorial.md:1006 msgid "" "let mut d = @mut 5; // mutable variable, mutable box *d += 5; d = @mut 15; " "~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1019 +#: doc/tutorial.md:1011 msgid "" "A mutable variable and an immutable variable can refer to the same box, " "given that their types are compatible. Mutability of a box is a property of " @@ -1853,7 +1838,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1023 +#: doc/tutorial.md:1015 #, no-wrap msgid "" "~~~~\n" @@ -1862,7 +1847,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1026 +#: doc/tutorial.md:1018 #, no-wrap msgid "" "let mut c : @int; // declare a variable with type managed immutable int\n" @@ -1870,7 +1855,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1030 +#: doc/tutorial.md:1022 #, no-wrap msgid "" "c = a; // box type is the same, okay\n" @@ -1879,7 +1864,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1035 +#: doc/tutorial.md:1027 #, no-wrap msgid "" "~~~~ {.xfail-test}\n" @@ -1889,12 +1874,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1037 +#: doc/tutorial.md:1029 msgid "# Move semantics" msgstr "" #. type: Plain text -#: doc/tutorial.md:1043 +#: doc/tutorial.md:1035 msgid "" "Rust uses a shallow copy for parameter passing, assignment and returning " "values from functions. A shallow copy is considered a move of ownership if " @@ -1904,33 +1889,33 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1049 +#: doc/tutorial.md:1041 msgid "" "~~~~ let x = ~5; let y = x.clone(); // y is a newly allocated box let z = " "x; // no new memory allocated, x can no longer be used ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1052 +#: doc/tutorial.md:1044 msgid "" "Since in owned boxes mutability is a property of the owner, not the box, " "mutable boxes may become immutable when they are moved, and vice-versa." msgstr "" #. type: Plain text -#: doc/tutorial.md:1059 +#: doc/tutorial.md:1051 msgid "" "~~~~ let r = ~13; let mut s = r; // box becomes mutable *s += 1; let t = " "s; // box becomes immutable ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1061 +#: doc/tutorial.md:1053 msgid "# Borrowed pointers" msgstr "" #. type: Plain text -#: doc/tutorial.md:1067 +#: doc/tutorial.md:1059 msgid "" "Rust's borrowed pointers are a general purpose reference type. In contrast " "with owned boxes, where the holder of an owned box is the owner of the " @@ -1940,12 +1925,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1069 +#: doc/tutorial.md:1061 msgid "As an example, consider a simple struct type, `Point`:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1076 +#: doc/tutorial.md:1068 #, no-wrap msgid "" "~~~\n" @@ -1957,7 +1942,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1080 +#: doc/tutorial.md:1072 msgid "" "We can use this simple definition to allocate points in many different ways. " "For example, in this code, each of these three local variables contains a " @@ -1965,7 +1950,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1087 +#: doc/tutorial.md:1079 #, no-wrap msgid "" "~~~\n" @@ -1977,22 +1962,21 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1099 +#: doc/tutorial.md:1089 msgid "" "Suppose we want to write a procedure that computes the distance between any " "two points, no matter where they are stored. For example, we might like to " "compute the distance between `on_the_stack` and `managed_box`, or between " "`managed_box` and `owned_box`. One option is to define a function that takes " -"two arguments of type pointthat is, it takes the points by value. But this " +"two arguments of type point—that is, it takes the points by value. But this " "will cause the points to be copied when we call the function. For points, " -"this is probably not so bad, but often copies are expensive or, worse, if " -"there are mutable fields, they can change the semantics of your program. So " -"wed like to define a function that takes the points by pointer. We can use " -"borrowed pointers to do this:" +"this is probably not so bad, but often copies are expensive. So we’d like to " +"define a function that takes the points by pointer. We can use borrowed " +"pointers to do this:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1109 +#: doc/tutorial.md:1099 #, no-wrap msgid "" "~~~\n" @@ -2007,12 +1991,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1111 doc/tutorial-borrowed-ptr.md:72 +#: doc/tutorial.md:1101 doc/tutorial-borrowed-ptr.md:72 msgid "Now we can call `compute_distance()` in various ways:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1121 +#: doc/tutorial.md:1111 #, no-wrap msgid "" "~~~\n" @@ -2027,7 +2011,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1128 +#: doc/tutorial.md:1118 msgid "" "Here the `&` operator is used to take the address of the variable " "`on_the_stack`; this is because `on_the_stack` has the type `Point` (that " @@ -2037,7 +2021,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1134 +#: doc/tutorial.md:1124 msgid "" "In the case of the boxes `managed_box` and `owned_box`, however, no explicit " "action is necessary. The compiler will automatically convert a box like " @@ -2047,7 +2031,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1143 +#: doc/tutorial.md:1133 msgid "" "Whenever a value is borrowed, there are some limitations on what you can do " "with the original. For example, if the contents of a variable have been lent " @@ -2059,31 +2043,31 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1146 +#: doc/tutorial.md:1136 msgid "" "For a more in-depth explanation of borrowed pointers, read the [borrowed " "pointer tutorial][borrowtut]." msgstr "" #. type: Plain text -#: doc/tutorial.md:1148 +#: doc/tutorial.md:1138 msgid "[borrowtut]: tutorial-borrowed-ptr.html" msgstr "" #. type: Plain text -#: doc/tutorial.md:1150 +#: doc/tutorial.md:1140 msgid "## Freezing" msgstr "" #. type: Plain text -#: doc/tutorial.md:1153 +#: doc/tutorial.md:1143 msgid "" "Borrowing an immutable pointer to an object freezes it and prevents " "mutation. `Owned` objects have freezing enforced statically at compile-time." msgstr "" #. type: Plain text -#: doc/tutorial.md:1161 +#: doc/tutorial.md:1152 #, no-wrap msgid "" "~~~~\n" @@ -2092,11 +2076,12 @@ msgid "" " let y = &x; // x is now frozen, it cannot be modified\n" "}\n" "// x is now unfrozen again\n" +"# x = 3;\n" "~~~~\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:1165 +#: doc/tutorial.md:1156 msgid "" "Mutable managed boxes handle freezing dynamically when any of their contents " "are borrowed, and the task will fail if an attempt to modify them is made " @@ -2104,7 +2089,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1175 +#: doc/tutorial.md:1166 #, no-wrap msgid "" "~~~~\n" @@ -2119,29 +2104,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1177 +#: doc/tutorial.md:1168 msgid "# Dereferencing pointers" msgstr "" #. type: Plain text -#: doc/tutorial.md:1180 +#: doc/tutorial.md:1171 msgid "" "Rust uses the unary star operator (`*`) to access the contents of a box or " "pointer, similarly to C." msgstr "" #. type: Plain text -#: doc/tutorial.md:1185 +#: doc/tutorial.md:1176 msgid "~~~ let managed = @10; let owned = ~20; let borrowed = &30;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1188 +#: doc/tutorial.md:1179 msgid "let sum = *managed + *owned + *borrowed; ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1192 +#: doc/tutorial.md:1183 msgid "" "Dereferenced mutable pointers may appear on the left hand side of " "assignments. Such an assignment modifies the value that the pointer points " @@ -2149,17 +2134,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1196 +#: doc/tutorial.md:1187 msgid "~~~ let managed = @mut 10; let mut owned = ~20;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1199 +#: doc/tutorial.md:1190 msgid "let mut value = 30; let borrowed = &mut value;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1204 +#: doc/tutorial.md:1195 #, no-wrap msgid "" "*managed = *owned + 10;\n" @@ -2169,7 +2154,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1208 +#: doc/tutorial.md:1199 msgid "" "Pointers have high operator precedence, but lower precedence than the dot " "operator used for field and method access. This precedence order can " @@ -2177,7 +2162,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1218 +#: doc/tutorial.md:1209 msgid "" "~~~ # struct Point { x: float, y: float } # enum Shape { Rectangle(Point, " "Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point " @@ -2186,7 +2171,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1222 +#: doc/tutorial.md:1213 msgid "" "To combat this ugliness the dot operator applies _automatic pointer " "dereferencing_ to the receiver (the value on the left-hand side of the dot), " @@ -2194,7 +2179,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1232 +#: doc/tutorial.md:1223 msgid "" "~~~ # struct Point { x: float, y: float } # enum Shape { Rectangle(Point, " "Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point " @@ -2203,7 +2188,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1236 +#: doc/tutorial.md:1227 msgid "" "You can write an expression that dereferences any number of pointers " "automatically. For example, if you feel inclined, you could write something " @@ -2211,24 +2196,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1242 +#: doc/tutorial.md:1233 msgid "" "~~~ # struct Point { x: float, y: float } let point = &@~Point { x: 10f, y: " "20f }; println(fmt!(\"%f\", point.x)); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1244 +#: doc/tutorial.md:1235 msgid "The indexing operator (`[]`) also auto-dereferences." msgstr "" #. type: Plain text -#: doc/tutorial.md:1246 +#: doc/tutorial.md:1237 msgid "# Vectors and strings" msgstr "" #. type: Plain text -#: doc/tutorial.md:1251 +#: doc/tutorial.md:1242 msgid "" "A vector is a contiguous section of memory containing zero or more values of " "the same type. Like other types in Rust, vectors can be stored on the stack, " @@ -2237,7 +2222,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1261 +#: doc/tutorial.md:1252 #, no-wrap msgid "" "~~~\n" @@ -2252,64 +2237,69 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1264 +#: doc/tutorial.md:1255 msgid "" "// A borrowed pointer to stack-allocated vector let stack_crayons: &[Crayon] " "= &[Aquamarine, Asparagus, AtomicTangerine];" msgstr "" #. type: Plain text -#: doc/tutorial.md:1267 +#: doc/tutorial.md:1258 msgid "" "// A local heap (managed) vector of crayons let local_crayons: @[Crayon] = " "@[BananaMania, Beaver, Bittersweet];" msgstr "" #. type: Plain text -#: doc/tutorial.md:1271 +#: doc/tutorial.md:1262 msgid "" "// An exchange heap (owned) vector of crayons let exchange_crayons: " "~[Crayon] = ~[Black, BlizzardBlue, Blue]; ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1273 +#: doc/tutorial.md:1264 msgid "The `+` operator means concatenation when applied to vector types." msgstr "" #. type: Plain text -#: doc/tutorial.md:1278 +#: doc/tutorial.md:1274 #, no-wrap msgid "" "~~~~\n" "# enum Crayon { Almond, AntiqueBrass, Apricot,\n" "# Aquamarine, Asparagus, AtomicTangerine,\n" "# BananaMania, Beaver, Bittersweet };\n" +"# impl Clone for Crayon {\n" +"# fn clone(&self) -> Crayon {\n" +"# *self\n" +"# }\n" +"# }\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:1281 +#: doc/tutorial.md:1277 msgid "" "let my_crayons = ~[Almond, AntiqueBrass, Apricot]; let your_crayons = " "~[BananaMania, Beaver, Bittersweet];" msgstr "" #. type: Plain text -#: doc/tutorial.md:1284 +#: doc/tutorial.md:1280 msgid "" "// Add two vectors to create a new one let our_crayons = my_crayons + " "your_crayons;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1289 +#: doc/tutorial.md:1285 msgid "" "// .push_all() will append to a vector, provided it lives in a mutable slot " "let mut my_crayons = my_crayons; my_crayons.push_all(your_crayons); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1294 +#: doc/tutorial.md:1290 msgid "" "> ***Note:*** The above examples of vector addition use owned > vectors. " "Some operations on slices and stack vectors are > not yet well-supported. " @@ -2317,12 +2307,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1296 +#: doc/tutorial.md:1292 msgid "Square brackets denote indexing into a vector:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1308 +#: doc/tutorial.md:1304 #, no-wrap msgid "" "~~~~\n" @@ -2339,16 +2329,16 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1310 +#: doc/tutorial.md:1306 msgid "A vector can be destructured using pattern matching:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1320 +#: doc/tutorial.md:1316 #, no-wrap msgid "" "~~~~\n" -"let numbers: [int, ..3] = [1, 2, 3];\n" +"let numbers: &[int] = &[1, 2, 3];\n" "let score = match numbers {\n" " [] => 0,\n" " [a] => a * 10,\n" @@ -2359,7 +2349,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1324 +#: doc/tutorial.md:1320 msgid "" "The elements of a vector _inherit the mutability of the vector_, and as " "such, individual elements may not be reassigned when the vector lives in an " @@ -2367,7 +2357,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1330 +#: doc/tutorial.md:1326 #, no-wrap msgid "" "~~~ {.xfail-test}\n" @@ -2378,17 +2368,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1333 +#: doc/tutorial.md:1329 msgid "crayons[0] = Apricot; // ERROR: Can't assign to immutable vector ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1335 +#: doc/tutorial.md:1331 msgid "Moving it into a mutable slot makes the elements assignable." msgstr "" #. type: Plain text -#: doc/tutorial.md:1341 +#: doc/tutorial.md:1337 #, no-wrap msgid "" "~~~\n" @@ -2399,25 +2389,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1344 +#: doc/tutorial.md:1340 msgid "" "// Put the vector into a mutable slot let mut mutable_crayons = crayons;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1348 +#: doc/tutorial.md:1344 msgid "// Now it's mutable to the bone mutable_crayons[0] = Apricot; ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1351 +#: doc/tutorial.md:1347 msgid "" "This is a simple example of Rust's _dual-mode data structures_, also " "referred to as _freezing and thawing_." msgstr "" #. type: Plain text -#: doc/tutorial.md:1359 +#: doc/tutorial.md:1355 msgid "" "Strings are implemented with vectors of `u8`, though they have a distinct " "type. They support most of the same allocation options as vectors, though " @@ -2428,47 +2418,47 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1363 +#: doc/tutorial.md:1359 msgid "" "~~~ // A plain string is a slice to read-only (static) memory let " "stack_crayons: &str = \"Almond, AntiqueBrass, Apricot\";" msgstr "" #. type: Plain text -#: doc/tutorial.md:1366 +#: doc/tutorial.md:1362 msgid "" "// The same thing, but with the `&` let stack_crayons: &str = &\"Aquamarine, " "Asparagus, AtomicTangerine\";" msgstr "" #. type: Plain text -#: doc/tutorial.md:1369 +#: doc/tutorial.md:1365 msgid "" "// A local heap (managed) string let local_crayons: @str = @\"BananaMania, " "Beaver, Bittersweet\";" msgstr "" #. type: Plain text -#: doc/tutorial.md:1373 +#: doc/tutorial.md:1369 msgid "" "// An exchange heap (owned) string let exchange_crayons: ~str = ~\"Black, " "BlizzardBlue, Blue\"; ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1377 +#: doc/tutorial.md:1373 msgid "" -"Both vectors and strings support a number of useful [methods](#functions-and-" -"methods), defined in [`std::vec`] and [`std::str`]. Here are some examples." +"Both vectors and strings support a number of useful [methods](#methods), " +"defined in [`std::vec`] and [`std::str`]. Here are some examples." msgstr "" #. type: Plain text -#: doc/tutorial.md:1380 +#: doc/tutorial.md:1376 msgid "[`std::vec`]: std/vec.html [`std::str`]: std/str.html" msgstr "" #. type: Plain text -#: doc/tutorial.md:1391 +#: doc/tutorial.md:1387 #, no-wrap msgid "" "~~~\n" @@ -2484,23 +2474,23 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1393 +#: doc/tutorial.md:1389 msgid "let crayons = [Almond, AntiqueBrass, Apricot];" msgstr "" #. type: Plain text -#: doc/tutorial.md:1397 +#: doc/tutorial.md:1393 msgid "" "// Check the length of the vector assert!(crayons.len() == 3); assert!(!" "crayons.is_empty());" msgstr "" #. type: Plain text -#: doc/tutorial.md:1404 +#: doc/tutorial.md:1400 #, no-wrap msgid "" "// Iterate over a vector, obtaining a pointer to each element\n" -"// (`for` is explained in the next section)\n" +"// (`for` is explained in the container/iterator tutorial)\n" "for crayon in crayons.iter() {\n" " let delicious_crayon_wax = unwrap_crayon(*crayon);\n" " eat_crayon_wax(delicious_crayon_wax);\n" @@ -2508,21 +2498,21 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1408 +#: doc/tutorial.md:1404 msgid "" "// Map vector elements let crayon_names = crayons.map(|v| " "crayon_to_str(*v)); let favorite_crayon_name = crayon_names[0];" msgstr "" #. type: Plain text -#: doc/tutorial.md:1411 +#: doc/tutorial.md:1407 msgid "" "// Remove whitespace from before and after the string let " "new_favorite_crayon_name = favorite_crayon_name.trim();" msgstr "" #. type: Plain text -#: doc/tutorial.md:1417 +#: doc/tutorial.md:1413 #, no-wrap msgid "" "if favorite_crayon_name.len() > 5 {\n" @@ -2533,12 +2523,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1419 +#: doc/tutorial.md:1415 msgid "# Closures" msgstr "" #. type: Plain text -#: doc/tutorial.md:1424 +#: doc/tutorial.md:1420 msgid "" "Named functions, like those we've seen so far, may not refer to local " "variables declared outside the function: they do not close over their " @@ -2547,12 +2537,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1427 +#: doc/tutorial.md:1423 msgid "~~~~ {.ignore} let foo = 10;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1432 +#: doc/tutorial.md:1428 #, no-wrap msgid "" "fn bar() -> int {\n" @@ -2562,31 +2552,31 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1435 +#: doc/tutorial.md:1431 msgid "" "Rust also supports _closures_, functions that can access variables in the " "enclosing scope." msgstr "" #. type: Plain text -#: doc/tutorial.md:1438 +#: doc/tutorial.md:1434 msgid "~~~~ fn call_closure_with_ten(b: &fn(int)) { b(10); }" msgstr "" #. type: Plain text -#: doc/tutorial.md:1441 +#: doc/tutorial.md:1437 msgid "" "let captured_var = 20; let closure = |arg| println(fmt!(\"captured_var=%d, " "arg=%d\", captured_var, arg));" msgstr "" #. type: Plain text -#: doc/tutorial.md:1444 +#: doc/tutorial.md:1440 msgid "call_closure_with_ten(closure); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1450 +#: doc/tutorial.md:1446 msgid "" "Closures begin with the argument list between vertical bars and are followed " "by a single expression. Remember that a block, `{ ; ; ... }`, " @@ -2596,7 +2586,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1455 +#: doc/tutorial.md:1451 msgid "" "The types of the arguments are generally omitted, as is the return type, " "because the compiler can almost always infer them. In the rare case where " @@ -2605,12 +2595,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1459 -msgid "~~~~ let square = |x: int| -> uint { x * x as uint }; ~~~~" +#: doc/tutorial.md:1455 +msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1463 +#: doc/tutorial.md:1459 msgid "" "There are several forms of closure, each with its own role. The most common, " "called a _stack closure_, has type `&fn` and can directly access local " @@ -2618,12 +2608,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1468 +#: doc/tutorial.md:1464 msgid "~~~~ let mut max = 0; [1, 2, 3].map(|x| if *x > max { max = *x }); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1477 +#: doc/tutorial.md:1473 msgid "" "Stack closures are very efficient because their environment is allocated on " "the call stack and refers by pointer to captured locals. To ensure that " @@ -2635,12 +2625,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1479 +#: doc/tutorial.md:1475 msgid "## Managed closures" msgstr "" #. type: Plain text -#: doc/tutorial.md:1485 +#: doc/tutorial.md:1481 msgid "" "When you need to store a closure in a data structure, a stack closure will " "not do, since the compiler will refuse to let you store it. For this " @@ -2650,7 +2640,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1490 +#: doc/tutorial.md:1486 msgid "" "A managed closure does not directly access its environment, but merely " "copies out the values that it closes over into a private data structure. " @@ -2659,14 +2649,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1493 +#: doc/tutorial.md:1489 msgid "" "This code creates a closure that adds a given string to its argument, " "returns it from a function, and then calls it:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1499 +#: doc/tutorial.md:1495 #, no-wrap msgid "" "~~~~\n" @@ -2677,7 +2667,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1505 +#: doc/tutorial.md:1501 #, no-wrap msgid "" "fn main() {\n" @@ -2688,12 +2678,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1507 +#: doc/tutorial.md:1503 msgid "## Owned closures" msgstr "" #. type: Plain text -#: doc/tutorial.md:1514 +#: doc/tutorial.md:1510 msgid "" "Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to " "things that can safely be sent between processes. They copy the values they " @@ -2703,17 +2693,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1516 -msgid "[tasks]: tutorial-tasks.html" -msgstr "" - -#. type: Plain text -#: doc/tutorial.md:1518 +#: doc/tutorial.md:1512 msgid "## Closure compatibility" msgstr "" #. type: Plain text -#: doc/tutorial.md:1525 +#: doc/tutorial.md:1519 msgid "" "Rust closures have a convenient subtyping property: you can pass any kind of " "closure (as long as the arguments and return types match) to functions that " @@ -2724,7 +2709,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1533 +#: doc/tutorial.md:1527 msgid "" "~~~~ fn call_twice(f: &fn()) { f(); f(); } let closure = || { \"I'm a " "closure, and it doesn't matter what type I am\"; }; fn function() { \"I'm a " @@ -2732,7 +2717,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1537 +#: doc/tutorial.md:1531 msgid "" "> ***Note:*** Both the syntax and the semantics will be changing > in small " "ways. At the moment they can be unsound in some > scenarios, particularly " @@ -2740,26 +2725,26 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1539 +#: doc/tutorial.md:1533 msgid "## Do syntax" msgstr "" #. type: Plain text -#: doc/tutorial.md:1542 +#: doc/tutorial.md:1536 msgid "" "The `do` expression provides a way to treat higher-order functions " "(functions that take closures as arguments) as control structures." msgstr "" #. type: Plain text -#: doc/tutorial.md:1545 +#: doc/tutorial.md:1539 msgid "" "Consider this function that iterates over a vector of integers, passing in a " "pointer to each integer in the vector:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1555 +#: doc/tutorial.md:1549 #, no-wrap msgid "" "~~~~\n" @@ -2774,14 +2759,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1559 +#: doc/tutorial.md:1553 msgid "" "As a caller, if we use a closure to provide the final operator argument, we " "can write it in a way that has a pleasant, block-like structure." msgstr "" #. type: Plain text -#: doc/tutorial.md:1567 +#: doc/tutorial.md:1561 #, no-wrap msgid "" "~~~~\n" @@ -2794,14 +2779,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1570 +#: doc/tutorial.md:1564 msgid "" "This is such a useful pattern that Rust has a special form of function call " "that can be written more like a built-in control structure:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1578 +#: doc/tutorial.md:1572 #, no-wrap msgid "" "~~~~\n" @@ -2814,7 +2799,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1583 +#: doc/tutorial.md:1577 msgid "" "The call is prefixed with the keyword `do` and, instead of writing the final " "closure inside the argument list, it appears outside of the parentheses, " @@ -2822,7 +2807,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1588 +#: doc/tutorial.md:1582 msgid "" "`do` is a convenient way to create tasks with the `task::spawn` function. " "`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a " @@ -2830,12 +2815,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1591 +#: doc/tutorial.md:1585 doc/tutorial.md:1597 msgid "~~~~ use std::task::spawn;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1596 +#: doc/tutorial.md:1590 #, no-wrap msgid "" "do spawn() || {\n" @@ -2845,7 +2830,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1600 +#: doc/tutorial.md:1594 msgid "" "Look at all those bars and parentheses -- that's two empty argument lists " "back to back. Since that is so unsightly, empty argument lists may be " @@ -2853,11 +2838,9 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1607 +#: doc/tutorial.md:1602 #, no-wrap msgid "" -"~~~~\n" -"# use std::task::spawn;\n" "do spawn {\n" " debug!(\"Kablam!\");\n" "}\n" @@ -2865,7 +2848,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1610 +#: doc/tutorial.md:1605 msgid "" "If you want to see the output of `debug!` statements, you will need to turn " "on `debug!` logging. To enable `debug!` logging, set the RUST_LOG " @@ -2874,12 +2857,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1612 +#: doc/tutorial.md:1607 msgid "# Methods" msgstr "" #. type: Plain text -#: doc/tutorial.md:1618 +#: doc/tutorial.md:1613 msgid "" "Methods are like functions except that they always begin with a special " "argument, called `self`, which has the type of the method's receiver. The " @@ -2888,7 +2871,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1622 +#: doc/tutorial.md:1617 msgid "" "_Implementations_, written with the `impl` keyword, can define methods on " "most Rust types, including structs and enums. As an example, let's define a " @@ -2896,7 +2879,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1630 +#: doc/tutorial.md:1625 #, no-wrap msgid "" "~~~\n" @@ -2909,7 +2892,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1635 +#: doc/tutorial.md:1630 #, no-wrap msgid "" "enum Shape {\n" @@ -2919,7 +2902,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1644 +#: doc/tutorial.md:1639 #, no-wrap msgid "" "impl Shape {\n" @@ -2933,12 +2916,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1648 +#: doc/tutorial.md:1643 msgid "let s = Circle(Point { x: 1f, y: 2f }, 3f); s.draw(); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1652 +#: doc/tutorial.md:1647 msgid "" "This defines an _implementation_ for `Shape` containing a single method, " "`draw`. In most respects the `draw` method is defined like any other " @@ -2946,7 +2929,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1657 +#: doc/tutorial.md:1652 msgid "" "The type of `self` is the type on which the method is implemented, or a " "pointer thereof. As an argument it is written either `self`, `&self`, " @@ -2955,7 +2938,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1672 +#: doc/tutorial.md:1667 #, no-wrap msgid "" "~~~\n" @@ -2975,26 +2958,26 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1674 +#: doc/tutorial.md:1669 msgid "let s = Circle(Point { x: 1f, y: 2f }, 3f);" msgstr "" #. type: Plain text -#: doc/tutorial.md:1680 +#: doc/tutorial.md:1675 msgid "" "(@s).draw_managed(); (~s).draw_owned(); (&s).draw_borrowed(); s." "draw_value(); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1684 +#: doc/tutorial.md:1679 msgid "" "Methods typically take a borrowed pointer self type, so the compiler will go " "to great lengths to convert a callee to a borrowed pointer." msgstr "" #. type: Plain text -#: doc/tutorial.md:1702 +#: doc/tutorial.md:1697 #, no-wrap msgid "" "~~~\n" @@ -3017,29 +3000,29 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1705 +#: doc/tutorial.md:1700 msgid "(@s).draw_borrowed(); (~s).draw_borrowed();" msgstr "" #. type: Plain text -#: doc/tutorial.md:1709 +#: doc/tutorial.md:1704 msgid "" "// Unlike typical function arguments, the self value will // automatically " "be referenced ... s.draw_borrowed();" msgstr "" #. type: Plain text -#: doc/tutorial.md:1712 +#: doc/tutorial.md:1707 msgid "// ... and dereferenced (& &s).draw_borrowed();" msgstr "" #. type: Plain text -#: doc/tutorial.md:1716 +#: doc/tutorial.md:1711 msgid "// ... and dereferenced and borrowed (&@~s).draw_borrowed(); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1720 +#: doc/tutorial.md:1715 msgid "" "Implementations may also define standalone (sometimes called \"static\") " "methods. The absence of a `self` parameter distinguishes such methods. " @@ -3047,7 +3030,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1727 +#: doc/tutorial.md:1722 #, no-wrap msgid "" "~~~~ {.xfail-test}\n" @@ -3059,17 +3042,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1729 +#: doc/tutorial.md:1724 msgid "" "To call such a method, just prefix it with the type name and a double colon:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1738 +#: doc/tutorial.md:1733 #, no-wrap msgid "" "~~~~\n" -"# use std::float::consts::pi;\n" +"use std::float::consts::pi;\n" "struct Circle { radius: float }\n" "impl Circle {\n" " fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }\n" @@ -3079,12 +3062,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1740 +#: doc/tutorial.md:1735 msgid "# Generics" msgstr "" #. type: Plain text -#: doc/tutorial.md:1748 +#: doc/tutorial.md:1743 msgid "" "Throughout this tutorial, we've been defining functions that act only on " "specific data types. With type parameters we can also define functions whose " @@ -3095,7 +3078,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1758 +#: doc/tutorial.md:1753 #, no-wrap msgid "" "~~~~\n" @@ -3110,7 +3093,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1763 +#: doc/tutorial.md:1758 msgid "" "When defined with type parameters, as denoted by ``, this function can " "be applied to any type of vector, as long as the type of `function`'s " @@ -3118,7 +3101,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1773 +#: doc/tutorial.md:1768 msgid "" "Inside a generic function, the names of the type parameters (capitalized by " "convention) stand for opaque types. All you can do with instances of these " @@ -3131,18 +3114,18 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1775 +#: doc/tutorial.md:1770 msgid "" "Generic `type`, `struct`, and `enum` declarations follow the same pattern:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1779 -msgid "~~~~ # use std::hashmap::HashMap; type Set = HashMap;" +#: doc/tutorial.md:1774 +msgid "~~~~ use std::hashmap::HashMap; type Set = HashMap;" msgstr "" #. type: Plain text -#: doc/tutorial.md:1783 +#: doc/tutorial.md:1778 #, no-wrap msgid "" "struct Stack {\n" @@ -3151,7 +3134,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1789 +#: doc/tutorial.md:1784 #, no-wrap msgid "" "enum Option {\n" @@ -3162,14 +3145,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1792 +#: doc/tutorial.md:1787 msgid "" "These declarations can be instantiated to valid types like `Set`, " "`Stack`, and `Option`." msgstr "" #. type: Plain text -#: doc/tutorial.md:1798 +#: doc/tutorial.md:1793 msgid "" "The last type in that example, `Option`, appears frequently in Rust code. " "Because Rust does not have null pointers (except in unsafe code), we need " @@ -3179,7 +3162,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1809 +#: doc/tutorial.md:1804 #, no-wrap msgid "" "~~~~\n" @@ -3195,7 +3178,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1817 +#: doc/tutorial.md:1812 msgid "" "The Rust compiler compiles generic functions very efficiently by " "*monomorphizing* them. *Monomorphization* is a fancy name for a simple idea: " @@ -3206,12 +3189,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1819 +#: doc/tutorial.md:1814 msgid "## Traits" msgstr "" #. type: Plain text -#: doc/tutorial.md:1829 +#: doc/tutorial.md:1824 msgid "" "Within a generic function the operations available on generic types are very " "limited. After all, since the function doesn't know what types it is " @@ -3224,26 +3207,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1836 +#: doc/tutorial.md:1832 msgid "" -"As motivation, let us consider copying in Rust. The `copy` operation is not " -"defined for all Rust types. One reason is user-defined destructors: copying " +"As motivation, let us consider copying in Rust. The `clone` method is not " +"defined for all Rust types. One reason is user-defined destructors: copying " "a type that has a destructor could result in the destructor running multiple " -"times. Therefore, types with user-defined destructors cannot be copied, " -"either implicitly or explicitly, and neither can types that own other types " -"containing destructors." +"times. Therefore, types with destructors cannot be copied unless you " +"explicitly implement `Clone` for them." msgstr "" #. type: Plain text -#: doc/tutorial.md:1840 +#: doc/tutorial.md:1837 msgid "" -"This complicates handling of generic functions. If you have a type parameter " -"`T`, can you copy values of that type? In Rust, you can't, and if you try to " -"run the following code the compiler will complain." +"This complicates handling of generic functions. If you have a type " +"parameter `T`, can you copy values of that type? In Rust, you can't, and if " +"you try to run the following code the compiler will complain." msgstr "" #. type: Plain text -#: doc/tutorial.md:1847 +#: doc/tutorial.md:1844 #, no-wrap msgid "" "~~~~ {.xfail-test}\n" @@ -3255,77 +3237,71 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1852 +#: doc/tutorial.md:1851 msgid "" "However, we can tell the compiler that the `head` function is only for " -"copyable types: that is, those that have the `Copy` trait. In that case, we " -"can explicitly create a second copy of the value we are returning using the " -"`copy` keyword:" +"copyable types: that is, those that implement the `Clone` trait. In that " +"case, we can explicitly create a second copy of the value we are returning " +"using the `clone` keyword:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1859 +#: doc/tutorial.md:1858 #, no-wrap msgid "" "~~~~\n" "// This does\n" -"fn head(v: &[T]) -> T {\n" -" copy v[0]\n" +"fn head(v: &[T]) -> T {\n" +" v[0].clone()\n" "}\n" "~~~~\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:1867 +#: doc/tutorial.md:1866 msgid "" "This says that we can call `head` on any type `T` as long as that type " -"implements the `Copy` trait. When instantiating a generic function, you can " -"only instantiate it with types that implement the correct trait, so you " -"could not apply `head` to a type with a destructor. (`Copy` is a special " -"trait that is built in to the compiler, making it possible for the compiler " -"to enforce this restriction.)" +"implements the `Clone` trait. When instantiating a generic function, you " +"can only instantiate it with types that implement the correct trait, so you " +"could not apply `head` to a type that does not implement `Clone`." msgstr "" #. type: Plain text #: doc/tutorial.md:1871 msgid "" -"While most traits can be defined and implemented by user code, three traits " +"While most traits can be defined and implemented by user code, two traits " "are automatically derived and implemented for all applicable types by the " "compiler, and may not be overridden:" msgstr "" -#. type: Bullet: '* ' +#. type: Plain text #: doc/tutorial.md:1875 +#, no-wrap msgid "" -"`Copy` - Types that can be copied, either implicitly, or explicitly with the " -"`copy` operator. All types are copyable unless they have destructors or " -"contain types with destructors." -msgstr "" - -#. type: Bullet: '* ' -#: doc/tutorial.md:1879 -msgid "" -"`Owned` - Owned types. Types are owned unless they contain managed boxes, " -"managed closures, or borrowed pointers. Owned types may or may not be " -"copyable." -msgstr "" - -#. type: Bullet: '* ' -#: doc/tutorial.md:1882 -msgid "" -"`Const` - Constant (immutable) types. These are types that do not contain " -"mutable fields." +"* `Send` - Sendable types.\n" +"Types are sendable\n" +"unless they contain managed boxes, managed closures, or borrowed pointers.\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:1885 +#: doc/tutorial.md:1880 +#, no-wrap msgid "" -"> ***Note:*** These three traits were referred to as 'kinds' in earlier > " +"* `Freeze` - Constant (immutable) types.\n" +"These are types that do not contain anything intrinsically mutable.\n" +"Intrinsically mutable values include `@mut`\n" +"and `Cell` in the standard library.\n" +msgstr "" + +#. type: Plain text +#: doc/tutorial.md:1883 +msgid "" +"> ***Note:*** These two traits were referred to as 'kinds' in earlier > " "iterations of the language, and often still are." msgstr "" #. type: Plain text -#: doc/tutorial.md:1891 +#: doc/tutorial.md:1889 msgid "" "Additionally, the `Drop` trait is used to define destructors. This trait " "defines one method called `drop`, which is automatically called when a value " @@ -3334,7 +3310,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1896 +#: doc/tutorial.md:1894 #, no-wrap msgid "" "~~~\n" @@ -3344,12 +3320,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1905 +#: doc/tutorial.md:1903 #, no-wrap msgid "" "impl Drop for TimeBomb {\n" " fn drop(&self) {\n" -" for self.explosivity.times {\n" +" for _ in range(0, self.explosivity) {\n" " println(\"blam!\");\n" " }\n" " }\n" @@ -3358,28 +3334,28 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1908 +#: doc/tutorial.md:1906 msgid "" "It is illegal to call `drop` directly. Only code inserted by the compiler " "may call it." msgstr "" #. type: Plain text -#: doc/tutorial.md:1910 +#: doc/tutorial.md:1908 msgid "## Declaring and implementing traits" msgstr "" #. type: Plain text -#: doc/tutorial.md:1915 +#: doc/tutorial.md:1914 msgid "" -"A trait consists of a set of methods, without bodies, or may be empty, as is " -"the case with `Copy`, `Owned`, and `Const`. For example, we could declare " -"the trait `Printable` for things that can be printed to the console, with a " -"single method:" +"A trait consists of a set of methods without bodies, or may be empty, as is " +"the case with `Send` and `Freeze`. For example, we could declare the trait " +"`Printable` for things that can be printed to the console, with a single " +"method:" msgstr "" #. type: Plain text -#: doc/tutorial.md:1921 +#: doc/tutorial.md:1920 #, no-wrap msgid "" "~~~~\n" @@ -3390,7 +3366,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1926 +#: doc/tutorial.md:1925 msgid "" "Traits may be implemented for specific types with [impls]. An impl that " "implements a trait includes the name of the trait at the start of the " @@ -3398,12 +3374,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1928 -msgid "[impls]: #functions-and-methods" +#: doc/tutorial.md:1927 +msgid "[impls]: #methods" msgstr "" #. type: Plain text -#: doc/tutorial.md:1934 +#: doc/tutorial.md:1933 #, no-wrap msgid "" "~~~~\n" @@ -3414,7 +3390,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1938 +#: doc/tutorial.md:1937 #, no-wrap msgid "" "impl Printable for ~str {\n" @@ -3423,12 +3399,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1942 +#: doc/tutorial.md:1941 msgid "# 1.print(); # (~\"foo\").print(); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:1947 +#: doc/tutorial.md:1946 msgid "" "Methods defined in an implementation of a trait may be called just like any " "other method, using dot notation, as in `1.print()`. Traits may themselves " @@ -3437,7 +3413,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1952 +#: doc/tutorial.md:1951 #, no-wrap msgid "" "~~~~\n" @@ -3447,7 +3423,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1957 +#: doc/tutorial.md:1956 #, no-wrap msgid "" "impl Seq for ~[T] {\n" @@ -3457,7 +3433,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1964 +#: doc/tutorial.md:1963 msgid "" "The implementation has to explicitly declare the type parameter that it " "binds, `T`, before using it to specify its trait type. Rust requires this " @@ -3467,7 +3443,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1969 +#: doc/tutorial.md:1968 msgid "" "The type parameters bound by a trait are in scope in each of the method " "declarations. So, re-declaring the type parameter `T` as an explicit type " @@ -3476,7 +3452,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1974 +#: doc/tutorial.md:1973 msgid "" "Within a trait definition, `Self` is a special type that you can think of as " "a type parameter. An implementation of the trait for any given type `T` " @@ -3485,7 +3461,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1981 +#: doc/tutorial.md:1980 #, no-wrap msgid "" "~~~~\n" @@ -3497,7 +3473,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1987 +#: doc/tutorial.md:1986 #, no-wrap msgid "" "// In an impl, `self` refers just to the value of the receiver\n" @@ -3508,7 +3484,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1992 +#: doc/tutorial.md:1991 msgid "" "Notice that in the trait definition, `equals` takes a second parameter of " "type `Self`. In contrast, in the `impl`, `equals` takes a second parameter " @@ -3516,7 +3492,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:1997 +#: doc/tutorial.md:1996 msgid "" "Just as in type implementations, traits can define standalone (static) " "methods. These methods are called by prefixing the method name with the " @@ -3525,14 +3501,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2003 +#: doc/tutorial.md:2002 msgid "" -"~~~~ # use std::float::consts::pi; trait Shape { fn new(area: float) -> " +"~~~~ use std::float::consts::pi; trait Shape { fn new(area: float) -> " "Self; } struct Circle { radius: float } struct Square { length: float }" msgstr "" #. type: Plain text -#: doc/tutorial.md:2010 +#: doc/tutorial.md:2009 #, no-wrap msgid "" "impl Shape for Circle {\n" @@ -3544,19 +3520,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2015 +#: doc/tutorial.md:2014 msgid "" "let area = 42.5; let c: Circle = Shape::new(area); let s: Square = Shape::" "new(area); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2017 +#: doc/tutorial.md:2016 msgid "## Bounded type parameters and static method dispatch" msgstr "" #. type: Plain text -#: doc/tutorial.md:2022 +#: doc/tutorial.md:2021 msgid "" "Traits give us a language for defining predicates on types, or abstract " "properties that types can have. We can use this language to define _bounds_ " @@ -3564,7 +3540,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2031 +#: doc/tutorial.md:2030 #, no-wrap msgid "" "~~~~\n" @@ -3578,32 +3554,32 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2037 +#: doc/tutorial.md:2036 msgid "" "Declaring `T` as conforming to the `Printable` trait (as we earlier did with " -"`Copy`) makes it possible to call methods from that trait on values of type " +"`Clone`) makes it possible to call methods from that trait on values of type " "`T` inside the function. It will also cause a compile-time error when anyone " "tries to call `print_all` on an array whose element type does not have a " "`Printable` implementation." msgstr "" #. type: Plain text -#: doc/tutorial.md:2040 +#: doc/tutorial.md:2039 msgid "" "Type parameters can have multiple bounds by separating them with `+`, as in " "this version of `print_all` that copies elements." msgstr "" #. type: Plain text -#: doc/tutorial.md:2052 +#: doc/tutorial.md:2051 #, no-wrap msgid "" "~~~\n" "# trait Printable { fn print(&self); }\n" -"fn print_all(printable_things: ~[T]) {\n" +"fn print_all(printable_things: ~[T]) {\n" " let mut i = 0;\n" " while i < printable_things.len() {\n" -" let copy_of_thing = copy printable_things[i];\n" +" let copy_of_thing = printable_things[i].clone();\n" " copy_of_thing.print();\n" " i += 1;\n" " }\n" @@ -3612,7 +3588,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2056 +#: doc/tutorial.md:2055 msgid "" "Method calls to bounded type parameters are _statically dispatched_, " "imposing no more overhead than normal function invocation, so are the " @@ -3620,17 +3596,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2058 +#: doc/tutorial.md:2057 msgid "This usage of traits is similar to Haskell type classes." msgstr "" #. type: Plain text -#: doc/tutorial.md:2060 +#: doc/tutorial.md:2059 msgid "## Trait objects and dynamic method dispatch" msgstr "" #. type: Plain text -#: doc/tutorial.md:2064 +#: doc/tutorial.md:2063 msgid "" "The above allows us to define functions that polymorphically act on values " "of a single unknown type that conforms to a given trait. However, consider " @@ -3638,7 +3614,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2070 +#: doc/tutorial.md:2069 msgid "" "~~~~ # type Circle = int; type Rectangle = int; # impl Drawable for int { fn " "draw(&self) {} } # fn new_circle() -> int { 1 } trait Drawable { fn " @@ -3646,7 +3622,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2077 +#: doc/tutorial.md:2076 #, no-wrap msgid "" "fn draw_all(shapes: ~[T]) {\n" @@ -3658,7 +3634,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2083 +#: doc/tutorial.md:2082 msgid "" "You can call that on an array of circles, or an array of rectangles " "(assuming those have suitable `Drawable` traits defined), but not on an " @@ -3667,7 +3643,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2090 +#: doc/tutorial.md:2089 #, no-wrap msgid "" "~~~~\n" @@ -3679,7 +3655,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2095 +#: doc/tutorial.md:2094 msgid "" "In this example, there is no type parameter. Instead, the `@Drawable` type " "denotes any managed box value that implements the `Drawable` trait. To " @@ -3688,7 +3664,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2102 +#: doc/tutorial.md:2101 msgid "" "~~~~ # type Circle = int; type Rectangle = bool; # trait Drawable { fn " "draw(&self); } # fn new_circle() -> Circle { 1 } # fn new_rectangle() -> " @@ -3696,21 +3672,21 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2105 +#: doc/tutorial.md:2104 msgid "" "impl Drawable for Circle { fn draw(&self) { ... } } impl Drawable for " "Rectangle { fn draw(&self) { ... } }" msgstr "" #. type: Plain text -#: doc/tutorial.md:2110 +#: doc/tutorial.md:2109 msgid "" "let c: @Circle = @new_circle(); let r: @Rectangle = @new_rectangle(); " "draw_all([c as @Drawable, r as @Drawable]); ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2118 +#: doc/tutorial.md:2117 msgid "" "We omit the code for `new_circle` and `new_rectangle`; imagine that these " "just return `Circle`s and `Rectangle`s with a default size. Note that, like " @@ -3721,7 +3697,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2132 +#: doc/tutorial.md:2131 msgid "" "~~~ # type Circle = int; type Rectangle = int; # trait Drawable { fn " "draw(&self); } # impl Drawable for int { fn draw(&self) {} } # fn " @@ -3732,7 +3708,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2137 +#: doc/tutorial.md:2136 msgid "" "Method calls to trait types are _dynamically dispatched_. Since the compiler " "doesn't know specifically which functions to call at compile time, it uses a " @@ -3741,17 +3717,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2139 +#: doc/tutorial.md:2138 msgid "This usage of traits is similar to Java interfaces." msgstr "" #. type: Plain text -#: doc/tutorial.md:2141 +#: doc/tutorial.md:2140 msgid "## Trait inheritance" msgstr "" #. type: Plain text -#: doc/tutorial.md:2146 +#: doc/tutorial.md:2145 msgid "" "We can write a trait declaration that _inherits_ from other traits, called " "_supertraits_. Types that implement a trait must also implement its " @@ -3760,24 +3736,24 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2151 +#: doc/tutorial.md:2150 msgid "" "~~~~ trait Shape { fn area(&self) -> float; } trait Circle : Shape { fn " "radius(&self) -> float; } ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2153 +#: doc/tutorial.md:2152 msgid "" "Now, we can implement `Circle` on a type only if we also implement `Shape`." msgstr "" #. type: Plain text -#: doc/tutorial.md:2168 +#: doc/tutorial.md:2167 #, no-wrap msgid "" "~~~~\n" -"# use std::float::consts::pi;\n" +"use std::float::consts::pi;\n" "# trait Shape { fn area(&self) -> float; }\n" "# trait Circle : Shape { fn radius(&self) -> float; }\n" "# struct Point { x: float, y: float }\n" @@ -3793,7 +3769,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2173 +#: doc/tutorial.md:2172 msgid "" "Notice that methods of `Circle` can call methods on `Shape`, as our `radius` " "implementation calls the `area` method. This is a silly way to compute the " @@ -3802,36 +3778,36 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2197 +#: doc/tutorial.md:2196 msgid "" -"~~~ {.xfail-test} # use std::float::consts::pi; # trait Shape { fn " -"area(&self) -> float; } # trait Circle : Shape { fn radius(&self) -> " -"float; } # struct Point { x: float, y: float } # struct CircleStruct " -"{ center: Point, radius: float } # impl Circle for CircleStruct { fn " -"radius(&self) -> float { (self.area() / pi).sqrt() } } # impl Shape for " -"CircleStruct { fn area(&self) -> float { pi * square(self.radius) } }" +"~~~ {.xfail-test} use std::float::consts::pi; # trait Shape { fn area(&self) " +"-> float; } # trait Circle : Shape { fn radius(&self) -> float; } # struct " +"Point { x: float, y: float } # struct CircleStruct { center: Point, radius: " +"float } # impl Circle for CircleStruct { fn radius(&self) -> float { (self." +"area() / pi).sqrt() } } # impl Shape for CircleStruct { fn area(&self) -> " +"float { pi * square(self.radius) } }" msgstr "" #. type: Plain text -#: doc/tutorial.md:2202 +#: doc/tutorial.md:2201 msgid "" "let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f}; let " -"mycircle: Circle = concrete as @Circle; let nonsense = mycircle.radius() * " +"mycircle: @Circle = concrete as @Circle; let nonsense = mycircle.radius() * " "mycircle.area(); ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2204 +#: doc/tutorial.md:2203 msgid "> ***Note:*** Trait inheritance does not actually work with objects yet" msgstr "" #. type: Plain text -#: doc/tutorial.md:2206 +#: doc/tutorial.md:2205 msgid "## Deriving implementations for traits" msgstr "" #. type: Plain text -#: doc/tutorial.md:2213 +#: doc/tutorial.md:2212 msgid "" "A small number of traits in `std` and `extra` can have implementations that " "can be automatically derived. These instances are specified by placing the " @@ -3842,17 +3818,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2217 +#: doc/tutorial.md:2216 msgid "~~~ #[deriving(Eq)] struct Circle { radius: float }" msgstr "" #. type: Plain text -#: doc/tutorial.md:2221 +#: doc/tutorial.md:2220 msgid "#[deriving(Rand, ToStr)] enum ABC { A, B, C } ~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2225 +#: doc/tutorial.md:2224 msgid "" "The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, " "`Encodable` `Decodable`, `Clone`, `DeepClone`, `IterBytes`, `Rand`, `Zero`, " @@ -3860,19 +3836,19 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2227 +#: doc/tutorial.md:2226 msgid "# Modules and crates" msgstr "" #. type: Plain text -#: doc/tutorial.md:2231 +#: doc/tutorial.md:2230 msgid "" "The Rust namespace is arranged in a hierarchy of modules. Each source (.rs) " "file represents a single module and may in turn contain additional modules." msgstr "" #. type: Plain text -#: doc/tutorial.md:2237 +#: doc/tutorial.md:2236 #, no-wrap msgid "" "~~~~\n" @@ -3883,7 +3859,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2242 +#: doc/tutorial.md:2241 #, no-wrap msgid "" "fn main() {\n" @@ -3893,7 +3869,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2247 +#: doc/tutorial.md:2246 msgid "" "The contents of modules can be imported into the current scope with the " "`use` keyword, optionally giving it an alias. `use` may appear at the " @@ -3901,14 +3877,14 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2253 +#: doc/tutorial.md:2252 msgid "" "~~~ # mod farm { pub fn chicken() { } } # fn main() { // Bring `chicken` " "into scope use farm::chicken;" msgstr "" #. type: Plain text -#: doc/tutorial.md:2263 +#: doc/tutorial.md:2262 #, no-wrap msgid "" "fn chicken_farmer() {\n" @@ -3923,7 +3899,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2270 +#: doc/tutorial.md:2269 msgid "" "These farm animal functions have a new keyword, `pub`, attached to them. The " "`pub` keyword modifies an item's visibility, making it visible outside its " @@ -3933,7 +3909,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2277 +#: doc/tutorial.md:2276 msgid "" "Visibility restrictions in Rust exist only at module boundaries. This is " "quite different from most object-oriented languages that also enforce " @@ -3944,7 +3920,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2290 +#: doc/tutorial.md:2289 #, no-wrap msgid "" "~~~\n" @@ -3962,18 +3938,18 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2296 +#: doc/tutorial.md:2295 #, no-wrap msgid "" " impl Farm {\n" -" priv fn feed_chickens(&self) { ... }\n" -" priv fn feed_cows(&self) { ... }\n" +" fn feed_chickens(&self) { ... }\n" +" fn feed_cows(&self) { ... }\n" " pub fn add_chicken(&self, c: Chicken) { ... }\n" " }\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:2302 +#: doc/tutorial.md:2301 #, no-wrap msgid "" " pub fn feed_animals(farm: &Farm) {\n" @@ -3984,7 +3960,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2312 +#: doc/tutorial.md:2311 #, no-wrap msgid "" "fn main() {\n" @@ -3999,12 +3975,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2314 +#: doc/tutorial.md:2313 msgid "## Crates" msgstr "" #. type: Plain text -#: doc/tutorial.md:2318 +#: doc/tutorial.md:2317 msgid "" "The unit of independent compilation in Rust is the crate: rustc compiles a " "single crate at a time, from which it produces either a library or an " @@ -4012,7 +3988,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2323 +#: doc/tutorial.md:2322 msgid "" "When compiling a single `.rs` source file, the file acts as the whole " "crate. You can compile it with the `--lib` compiler switch to create a " @@ -4021,7 +3997,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2328 +#: doc/tutorial.md:2327 msgid "" "Larger crates typically span multiple files and are, by convention, compiled " "from a source file with the `.rc` extension, called a *crate file*. The " @@ -4030,7 +4006,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2337 +#: doc/tutorial.md:2336 msgid "" "A typical crate file declares attributes associated with the crate that may " "affect how the compiler processes the source. Crate attributes specify " @@ -4041,34 +4017,34 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2341 +#: doc/tutorial.md:2340 msgid "" "~~~~ { .xfail-test } // Crate linkage metadata #[link(name = \"farm\", vers " "= \"2.5\", author = \"mjh\")];" msgstr "" #. type: Plain text -#: doc/tutorial.md:2344 +#: doc/tutorial.md:2343 msgid "// Make a library (\"bin\" is the default) #[crate_type = \"lib\"];" msgstr "" #. type: Plain text -#: doc/tutorial.md:2347 +#: doc/tutorial.md:2346 msgid "// Turn on a warning #[warn(non_camel_case_types)]" msgstr "" #. type: Plain text -#: doc/tutorial.md:2350 +#: doc/tutorial.md:2349 msgid "// Link to the standard library extern mod std;" msgstr "" #. type: Plain text -#: doc/tutorial.md:2355 +#: doc/tutorial.md:2354 msgid "// Load some modules from other files mod cow; mod chicken; mod horse;" msgstr "" #. type: Plain text -#: doc/tutorial.md:2360 +#: doc/tutorial.md:2359 #, no-wrap msgid "" "fn main() {\n" @@ -4078,7 +4054,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2367 +#: doc/tutorial.md:2366 msgid "" "Compiling this file will cause `rustc` to look for files named `cow.rs`, " "`chicken.rs`, and `horse.rs` in the same directory as the `.rc` file, " @@ -4088,21 +4064,21 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2371 +#: doc/tutorial.md:2370 msgid "" "The `#[link(...)]` attribute provides meta information about the module, " "which other crates can use to load the right module. More about that later." msgstr "" #. type: Plain text -#: doc/tutorial.md:2374 +#: doc/tutorial.md:2373 msgid "" "To have a nested directory structure for your source files, you can nest " "mods:" msgstr "" #. type: Plain text -#: doc/tutorial.md:2381 +#: doc/tutorial.md:2380 #, no-wrap msgid "" "~~~~ {.ignore}\n" @@ -4114,7 +4090,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2386 +#: doc/tutorial.md:2385 msgid "" "The compiler will now look for `poultry/chicken.rs` and `poultry/turkey.rs`, " "and export their content in `poultry::chicken` and `poultry::turkey`. You " @@ -4123,12 +4099,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2388 +#: doc/tutorial.md:2387 msgid "## Using other crates" msgstr "" #. type: Plain text -#: doc/tutorial.md:2396 +#: doc/tutorial.md:2395 msgid "" "The `extern mod` directive lets you use a crate (once it's been compiled " "into a library) from inside another crate. `extern mod` can appear at the " @@ -4139,17 +4115,17 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2398 +#: doc/tutorial.md:2397 msgid "For example, `extern mod std` links the [standard library]." msgstr "" #. type: Plain text -#: doc/tutorial.md:2400 +#: doc/tutorial.md:2399 msgid "[standard library]: std/index.html" msgstr "" #. type: Plain text -#: doc/tutorial.md:2407 +#: doc/tutorial.md:2406 msgid "" "When a comma-separated list of name/value pairs appears after `extern mod`, " "the compiler front-end matches these pairs against the attributes provided " @@ -4159,22 +4135,22 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2409 +#: doc/tutorial.md:2408 msgid "Our example crate declared this set of `link` attributes:" msgstr "" #. type: Plain text -#: doc/tutorial.md:2413 +#: doc/tutorial.md:2412 msgid "~~~~ #[link(name = \"farm\", vers = \"2.5\", author = \"mjh\")]; ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2415 +#: doc/tutorial.md:2414 msgid "Which you can then link with any (or all) of the following:" msgstr "" #. type: Plain text -#: doc/tutorial.md:2421 +#: doc/tutorial.md:2420 msgid "" "~~~~ {.xfail-test} extern mod farm; extern mod my_farm (name = \"farm\", " "vers = \"2.5\"); extern mod my_auxiliary_farm (name = \"farm\", author = " @@ -4182,45 +4158,45 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2424 +#: doc/tutorial.md:2423 msgid "" "If any of the requested metadata do not match, then the crate will not be " "compiled successfully." msgstr "" #. type: Plain text -#: doc/tutorial.md:2426 +#: doc/tutorial.md:2425 msgid "## A minimal example" msgstr "" #. type: Plain text -#: doc/tutorial.md:2429 +#: doc/tutorial.md:2428 msgid "" "Now for something that you can actually compile yourself, we have these two " "files:" msgstr "" #. type: Plain text -#: doc/tutorial.md:2435 +#: doc/tutorial.md:2434 msgid "" "~~~~ // world.rs #[link(name = \"world\", vers = \"1.0\")]; pub fn explore() " "-> &str { \"world\" } ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2441 +#: doc/tutorial.md:2440 msgid "" "~~~~ {.xfail-test} // main.rs extern mod world; fn main() { println(~\"hello " "\" + world::explore()); } ~~~~" msgstr "" #. type: Plain text -#: doc/tutorial.md:2443 +#: doc/tutorial.md:2442 msgid "Now compile and run like this (adjust to your platform if necessary):" msgstr "" #. type: Plain text -#: doc/tutorial.md:2450 +#: doc/tutorial.md:2449 #, no-wrap msgid "" "~~~~ {.notrust}\n" @@ -4232,7 +4208,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2455 +#: doc/tutorial.md:2454 msgid "" "Notice that the library produced contains the version in the filename as " "well as an inscrutable string of alphanumerics. These are both part of " @@ -4241,12 +4217,12 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2457 +#: doc/tutorial.md:2456 msgid "## The standard library" msgstr "" #. type: Plain text -#: doc/tutorial.md:2462 +#: doc/tutorial.md:2461 msgid "" "The Rust standard library provides runtime features required by the " "language, including the task scheduler and memory allocators, as well as " @@ -4255,7 +4231,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2473 +#: doc/tutorial.md:2472 msgid "" "[`std`] includes modules corresponding to each of the integer types, each of " "the floating point types, the [`bool`] type, [tuples], [characters], " @@ -4269,25 +4245,25 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2475 +#: doc/tutorial.md:2474 msgid "### Standard Library injection and the Rust prelude" msgstr "" #. type: Plain text -#: doc/tutorial.md:2478 +#: doc/tutorial.md:2477 msgid "" "`std` is imported at the topmost level of every crate by default, as if the " "first line of each crate was" msgstr "" #. type: Plain text -#: doc/tutorial.md:2480 +#: doc/tutorial.md:2479 #, no-wrap msgid " extern mod std;\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:2484 +#: doc/tutorial.md:2483 msgid "" "This means that the contents of std can be accessed from from any context " "with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`, " @@ -4295,7 +4271,7 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2489 +#: doc/tutorial.md:2488 msgid "" "Additionally, `std` contains a `prelude` module that reexports many of the " "most common standard modules, types and traits. The contents of the prelude " @@ -4304,13 +4280,13 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2491 +#: doc/tutorial.md:2490 #, no-wrap msgid " use std::prelude::*;\n" msgstr "" #. type: Plain text -#: doc/tutorial.md:2517 +#: doc/tutorial.md:2516 msgid "" "[`std`]: std/index.html [`bool`]: std/bool.html [tuples]: std/tuple.html " "[characters]: std/char.html [strings]: std/str.html [vectors]: std/vec.html " @@ -4324,66 +4300,55 @@ msgid "" msgstr "" #. type: Plain text -#: doc/tutorial.md:2519 +#: doc/tutorial.md:2518 msgid "# What next?" msgstr "" #. type: Plain text -#: doc/tutorial.md:2522 +#: doc/tutorial.md:2521 msgid "" "Now that you know the essentials, check out any of the additional tutorials " "on individual topics." msgstr "" #. type: Bullet: '* ' -#: doc/tutorial.md:2528 +#: doc/tutorial.md:2527 msgid "[Borrowed pointers][borrow]" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial.md:2528 +#: doc/tutorial.md:2527 msgid "[Tasks and communication][tasks]" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial.md:2528 +#: doc/tutorial.md:2527 msgid "[Macros][macros]" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial.md:2528 +#: doc/tutorial.md:2527 msgid "[The foreign function interface][ffi]" msgstr "" #. type: Bullet: '* ' -#: doc/tutorial.md:2528 +#: doc/tutorial.md:2527 msgid "[Containers and iterators](tutorial-container.html)" msgstr "" #. type: Plain text -#: doc/tutorial.md:2530 +#: doc/tutorial.md:2529 msgid "There is further documentation on the [wiki]." msgstr "" #. type: Plain text -#: doc/tutorial.md:2535 +#: doc/tutorial.md:2534 msgid "" "[borrow]: tutorial-borrowed-ptr.html [tasks]: tutorial-tasks.html [macros]: " "tutorial-macros.html [ffi]: tutorial-ffi.html" msgstr "" #. type: Plain text -#: doc/tutorial.md:2541 -msgid "" -"[wiki]: https://github.com/mozilla/rust/wiki/Docs [unit testing]: https://" -"github.com/mozilla/rust/wiki/Doc-unit-testing [rustdoc]: https://github.com/" -"mozilla/rust/wiki/Doc-using-rustdoc [cargo]: https://github.com/mozilla/rust/" -"wiki/Doc-using-cargo-to-manage-packages [attributes]: https://github.com/" -"mozilla/rust/wiki/Doc-attributes" -msgstr "" - -#. type: Plain text -#: doc/tutorial.md:2542 -msgid "" -"[pound-rust]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust" +#: doc/tutorial.md:2536 +msgid "[wiki]: https://github.com/mozilla/rust/wiki/Docs" msgstr ""