# SOME DESCRIPTIVE TITLE
-# Copyright (C) YEAR Free Software Foundation, Inc.
-# This file is distributed under the same license as the PACKAGE package.
+# Copyright (C) YEAR The Rust Project Developers
+# This file is distributed under the same license as the Rust package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2013-07-07 21:10+0300\n"
+"Project-Id-Version: Rust 0.8-pre\n"
+"POT-Creation-Date: 2013-07-17 07:47+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#. type: Plain text
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
#: doc/tutorial-borrowed-ptr.md:4 doc/tutorial-ffi.md:4
-#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4 doc/tut.md:4
+#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4
msgid "# Introduction"
msgstr ""
#. type: Plain text
#: doc/rust.md:223
msgid ""
-"~~~~~~~~ {.keyword} as break copy do drop 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 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 ~~~~~~~~"
msgstr ""
#. type: Plain text
#. type: Plain text
#: doc/rust.md:807
-msgid "~~~~ use std::float::sin; use std::option::{Some, None};"
+msgid "~~~~ use std::num::sin; use std::option::{Some, None};"
msgstr ""
#. type: Plain text
#, no-wrap
msgid ""
"fn main() {\n"
-" // Equivalent to 'info!(std::float::sin(1.0));'\n"
+" // Equivalent to 'info!(std::num::sin(1.0));'\n"
" info!(sin(1.0));\n"
msgstr ""
msgstr ""
#. type: Plain text
-#: doc/rust.md:1231 doc/tutorial.md:2179
+#: doc/rust.md:1231 doc/tutorial.md:2177
msgid ""
"In type-parameterized functions, methods of the supertrait may be called on "
"values of subtrait-bound type parameters. Refering to the previous example "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1240 doc/tutorial.md:2188
+#: doc/rust.md:1240 doc/tutorial.md:2186
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1242 doc/tutorial.md:2190
+#: doc/rust.md:1242 doc/tutorial.md:2188
msgid "Likewise, supertrait methods may also be called on trait objects."
msgstr ""
msgid "The `test` attribute, for marking functions as unit tests."
msgstr ""
-#. type: Plain text
+#. type: Bullet: '* '
#: doc/rust.md:1425
-#, no-wrap
msgid ""
-"* The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks. Lint checks supported\n"
-"by the compiler can be found via `rustc -W help`.\n"
-"* The `deriving` attribute, for automatically generating\n"
-" implementations of certain traits.\n"
-"* The `static_assert` attribute, for asserting that a static bool is true at compiletime\n"
+"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
+msgid ""
+"The `deriving` attribute, for automatically generating implementations of "
+"certain traits."
+msgstr ""
+
+#. type: Bullet: '* '
+#: doc/rust.md:1425
+msgid ""
+"The `static_assert` attribute, for asserting that a static bool is true at "
+"compiletime"
msgstr ""
#. type: Plain text
#. type: Plain text
#: doc/rust.md:1429
-msgid "### Language items"
+msgid "### Lint check attributes"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1433
+msgid ""
+"A lint check names a potentially undesirable coding pattern, such as "
+"unreachable code or omitted documentation, for the static entity to which "
+"the attribute applies."
msgstr ""
#. type: Plain text
#: doc/rust.md:1435
+msgid "For any lint check `C`:"
+msgstr ""
+
+#. type: Bullet: ' * '
+#: doc/rust.md:1442
+msgid "`warn(C)` warns about violations of `C` but continues compilation,"
+msgstr ""
+
+#. type: Bullet: ' * '
+#: doc/rust.md:1442
+msgid "`deny(C)` signals an error after encountering a violation of `C`,"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1442
+#, no-wrap
+msgid ""
+" * `allow(C)` overrides the check for `C` so that violations will go\n"
+" unreported,\n"
+" * `forbid(C)` is the same as `deny(C)`, but also forbids uses of\n"
+" `allow(C)` within the entity.\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1445
+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
+#, no-wrap
+msgid ""
+"~~~{.xfail-test}\n"
+"mod m1 {\n"
+" // Missing documentation is ignored here\n"
+" #[allow(missing_doc)]\n"
+" pub fn undocumented_one() -> int { 1 }\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1455
+#, no-wrap
+msgid ""
+" // Missing documentation signals a warning here\n"
+" #[warn(missing_doc)]\n"
+" pub fn undocumented_too() -> int { 2 }\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1461
+#, no-wrap
+msgid ""
+" // Missing documentation signals an error here\n"
+" #[deny(missing_doc)]\n"
+" pub fn undocumented_end() -> int { 3 }\n"
+"}\n"
+"~~~\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1464
+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
+#, no-wrap
+msgid ""
+"~~~\n"
+"#[warn(missing_doc)]\n"
+"mod m2{\n"
+" #[allow(missing_doc)]\n"
+" mod nested {\n"
+" // Missing documentation is ignored here\n"
+" pub fn undocumented_one() -> int { 1 }\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1478
+#, no-wrap
+msgid ""
+" // Missing documentation signals a warning here,\n"
+" // despite the allow above.\n"
+" #[warn(missing_doc)]\n"
+" pub fn undocumented_two() -> int { 2 }\n"
+" }\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1483
+#, no-wrap
+msgid ""
+" // Missing documentation signals a warning here\n"
+" pub fn undocumented_too() -> int { 3 }\n"
+"}\n"
+"~~~\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1486
+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
+#, no-wrap
+msgid ""
+"~~~{.xfail-test}\n"
+"#[forbid(missing_doc)]\n"
+"mod m3 {\n"
+" // Attempting to toggle warning signals an error here\n"
+" #[allow(missing_doc)]\n"
+" /// Returns 2.\n"
+" pub fn undocumented_too() -> int { 2 }\n"
+"}\n"
+"~~~\n"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1498
+msgid "### Language items"
+msgstr ""
+
+#. type: Plain text
+#: doc/rust.md:1504
msgid ""
"Some primitive Rust operations are defined in Rust code, rather than being "
"implemented directly in C or assembly language. The definitions of these "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1442
+#: doc/rust.md:1511
#, no-wrap
msgid ""
"~~~ {.xfail-test}\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1446
+#: doc/rust.md:1515
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1448
+#: doc/rust.md:1517
msgid "A complete list of the built-in language items follows:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1450
+#: doc/rust.md:1519
msgid "#### Traits"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1491
+#: doc/rust.md:1560
#, no-wrap
msgid ""
"`const`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1493
+#: doc/rust.md:1562
msgid "#### Operations"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1522
+#: doc/rust.md:1591
#, no-wrap
msgid ""
"`str_eq`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1525
+#: doc/rust.md:1594
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:1527
+#: doc/rust.md:1596
msgid "### Deriving"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1533
+#: doc/rust.md:1602
msgid ""
"The `deriving` attribute allows certain traits to be automatically "
"implemented for data structures. For example, the following will create an "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1541
+#: doc/rust.md:1610
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1543
+#: doc/rust.md:1612
msgid "The generated `impl` for `Eq` is equivalent to"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1550
+#: doc/rust.md:1619
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1556
+#: doc/rust.md:1625
#, no-wrap
msgid ""
" fn ne(&self, other: &Foo<T>) -> bool {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1558
+#: doc/rust.md:1627
msgid "Supported traits for `deriving` are:"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
msgid "Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
msgid "Serialization: `Encodable`, `Decodable`. These require `extra`."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
msgid "`Clone` and `DeepClone`, to perform (deep) copies."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
msgid "`IterBytes`, to iterate over the bytes in a data type."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
msgid "`Rand`, to create a random instance of a data type."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
msgid "`Zero`, to create an zero (or empty) instance of a data type."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:1569
+#: doc/rust.md:1638
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1571
+#: doc/rust.md:1640
msgid "# Statements and expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1578
+#: doc/rust.md:1647
msgid ""
"Rust is _primarily_ an expression language. This means that most forms of "
"value-producing or effect-causing evaluation are directed by the uniform "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1581
+#: doc/rust.md:1650
msgid ""
"In contrast, statements in Rust serve _mostly_ to contain and explicitly "
"sequence expression evaluation."
msgstr ""
#. type: Plain text
-#: doc/rust.md:1583
+#: doc/rust.md:1652
msgid "## Statements"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1586
+#: doc/rust.md:1655
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:1590
+#: doc/rust.md:1659
msgid ""
"Rust has two kinds of statement: [declaration statements](#declaration-"
"statements) and [expression statements](#expression-statements)."
msgstr ""
#. type: Plain text
-#: doc/rust.md:1592
+#: doc/rust.md:1661
msgid "### Declaration statements"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1595
+#: doc/rust.md:1664
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1597
+#: doc/rust.md:1666
msgid "#### Item declarations"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1604
+#: doc/rust.md:1673
msgid ""
"An _item declaration statement_ has a syntactic form identical to an [item]"
"(#items) declaration within a module. Declaring an item -- a function, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1607
+#: doc/rust.md:1676
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:1610
+#: doc/rust.md:1679
msgid "#### Slot declarations"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1615
+#: doc/rust.md:1684
msgid ""
"~~~~~~~~{.ebnf .gram} let_decl : \"let\" pat [':' type ] ? [ init ] ? ';' ; "
"init : [ '=' ] expr ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1621
+#: doc/rust.md:1690
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1623
+#: doc/rust.md:1692
msgid "### Expression statements"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1628
+#: doc/rust.md:1697
msgid ""
"An _expression statement_ is one that evaluates an [expression]"
"(#expressions) and ignores its result. The type of an expression statement "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1630
+#: doc/rust.md:1699
msgid "## Expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1639
+#: doc/rust.md:1708
#, no-wrap
msgid ""
"An expression may have two roles: it always produces a *value*, and it may have *effects*\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1644
+#: doc/rust.md:1713
msgid ""
"In this way, the structure of expressions dictates the structure of "
"execution. Blocks are just another kind of expression, so blocks, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1646
+#: doc/rust.md:1715
msgid "#### Lvalues, rvalues and temporaries"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1650
+#: doc/rust.md:1719
msgid ""
"Expressions are divided into two main categories: _lvalues_ and _rvalues_. "
"Likewise within each expression, sub-expressions may occur in _lvalue "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1653
+#: doc/rust.md:1722
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:1661
+#: doc/rust.md:1730
msgid ""
"The left operand of an [assignment](#assignment-expressions), [binary move]"
"(#binary-move-expressions) or [compound-assignment](#compound-assignment-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1664
+#: doc/rust.md:1733
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1667
+#: doc/rust.md:1736
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1669
+#: doc/rust.md:1738
msgid "#### Moved and copied types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1675
+#: doc/rust.md:1744
msgid ""
"When a [local variable](#memory-slots) is used as an [rvalue](#lvalues-"
"rvalues-and-temporaries) the variable will either be [moved](#move-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1678
+#: doc/rust.md:1747
msgid "### Literal expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1682
+#: doc/rust.md:1751
msgid ""
"A _literal expression_ consists of one of the [literal](#literals) forms "
"described earlier. It directly describes a number, character, string, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1689
+#: doc/rust.md:1758
#, no-wrap
msgid ""
"~~~~~~~~ {.literals}\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1691
+#: doc/rust.md:1760
msgid "### Path expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1694
+#: doc/rust.md:1763
msgid ""
"A [path](#paths) used as an expression context denotes either a local "
"variable or an item. Path expressions are [lvalues](#lvalues-rvalues-and-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1696
+#: doc/rust.md:1765
msgid "### Tuple expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1700
+#: doc/rust.md:1769
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:1706
+#: doc/rust.md:1775
msgid "~~~~~~~~ {.tuple} (0,); (0f, 4.5f); (\"a\", 4u, true); ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1708
+#: doc/rust.md:1777
msgid "### Structure expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1717
+#: doc/rust.md:1786
#, no-wrap
msgid ""
"~~~~~~~~{.ebnf .gram}\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1724
+#: doc/rust.md:1793
msgid ""
"There are several forms of structure expressions. A _structure expression_ "
"consists of the [path](#paths) of a [structure item](#structures), followed "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1729
+#: doc/rust.md:1798
msgid ""
"A _tuple structure expression_ consists of the [path](#paths) of a "
"[structure item](#structures), followed by a parenthesized list of one or "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1731
+#: doc/rust.md:1800
msgid ""
"A _unit-like structure expression_ consists only of the [path](#paths) of a "
"[structure item](#structures)."
msgstr ""
#. type: Plain text
-#: doc/rust.md:1733
+#: doc/rust.md:1802
msgid "The following are examples of structure expressions:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1744
+#: doc/rust.md:1813
msgid ""
"~~~~ # struct Point { x: float, y: float } # struct TuplePoint(float, "
"float); # mod game { pub struct User<'self> { name: &'self str, age: uint, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1747
+#: doc/rust.md:1816
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1754
+#: doc/rust.md:1823
msgid ""
"A structure expression can terminate with the syntax `..` followed by an "
"expression to denote a functional update. The expression following `..` "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1760
+#: doc/rust.md:1829
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:1762
+#: doc/rust.md:1831
msgid "### Record expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1768
+#: doc/rust.md:1837
#, no-wrap
msgid ""
"~~~~~~~~{.ebnf .gram}\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1770
+#: doc/rust.md:1839
msgid "### Method-call expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1774
+#: doc/rust.md:1843
msgid ""
"~~~~~~~~{.ebnf .gram} method_call_expr : expr '.' ident paren_expr_list ; "
"~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1779
+#: doc/rust.md:1848
msgid ""
"A _method call_ consists of an expression followed by a single dot, an "
"identifier, and a parenthesized expression-list. Method calls are resolved "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1782
+#: doc/rust.md:1851
msgid "### Field expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1786
+#: doc/rust.md:1855
msgid "~~~~~~~~{.ebnf .gram} field_expr : expr '.' ident ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1790
+#: doc/rust.md:1859
msgid ""
"A _field expression_ consists of an expression followed by a single dot and "
"an identifier, when not immediately followed by a parenthesized expression-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1795
+#: doc/rust.md:1864
msgid "~~~~~~~~ {.field} myrecord.myfield; {a: 10, b: 20}.a; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1798
+#: doc/rust.md:1867
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1801
+#: doc/rust.md:1870
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1804
+#: doc/rust.md:1873
msgid "### Vector expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1807
+#: doc/rust.md:1876
msgid "~~~~~~~~{.ebnf .gram} vec_expr : '[' \"mut\"? vec_elems? ']'"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1810
+#: doc/rust.md:1879
msgid "vec_elems : [expr [',' expr]*] | [expr ',' \"..\" expr] ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1813
+#: doc/rust.md:1882
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:1817
+#: doc/rust.md:1886
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1824
+#: doc/rust.md:1893
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1826
+#: doc/rust.md:1895
msgid "### Index expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1830
+#: doc/rust.md:1899
msgid "~~~~~~~~{.ebnf .gram} idx_expr : expr '[' expr ']' ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1835
+#: doc/rust.md:1904
msgid ""
"[Vector](#vector-types)-typed expressions can be indexed by writing a square-"
"bracket-enclosed expression (the index) after them. When the vector is "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1839
+#: doc/rust.md:1908
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1843
+#: doc/rust.md:1912
msgid "~~~~ # use std::task; # do task::spawn_unlinked {"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1846
+#: doc/rust.md:1915
msgid "([1, 2, 3, 4])[0]; ([\"a\", \"b\"])[10]; // fails"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1849 doc/tutorial-tasks.md:649
+#: doc/rust.md:1918 doc/tutorial-tasks.md:649
msgid "# } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1851
+#: doc/rust.md:1920
msgid "### Unary operator expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1855
+#: doc/rust.md:1924
msgid ""
"Rust defines six symbolic unary operators, in addition to the unary [copy]"
"(#unary-copy-expressions) and [move](#unary-move-expressions) operators. "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1874
+#: doc/rust.md:1943
#, no-wrap
msgid ""
"`-`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1876
+#: doc/rust.md:1945
msgid "### Binary operator expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1880
+#: doc/rust.md:1949
msgid "~~~~~~~~{.ebnf .gram} binop_expr : expr binop expr ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1883
+#: doc/rust.md:1952
msgid ""
"Binary operators expressions are given in terms of [operator precedence]"
"(#operator-precedence)."
msgstr ""
#. type: Plain text
-#: doc/rust.md:1885
+#: doc/rust.md:1954
msgid "#### Arithmetic operators"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1890
+#: doc/rust.md:1959
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1906
+#: doc/rust.md:1975
#, no-wrap
msgid ""
"`+`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1908
+#: doc/rust.md:1977
msgid "#### Bitwise operators"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1913
+#: doc/rust.md:1982
msgid ""
"Like the [arithmetic operators](#arithmetic-operators), bitwise operators "
"are syntactic sugar for calls to methods of built-in traits. This means "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1929
+#: doc/rust.md:1998
#, no-wrap
msgid ""
"`&`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1931
+#: doc/rust.md:2000
msgid "#### Lazy boolean operators"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1938
+#: doc/rust.md:2007
msgid ""
"The operators `||` and `&&` may be applied to operands of boolean type. The "
"`||` operator denotes logical 'or', and the `&&` operator denotes logical "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1940
+#: doc/rust.md:2009
msgid "#### Comparison operators"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1946
+#: doc/rust.md:2015
msgid ""
"Comparison operators are, like the [arithmetic operators](#arithmetic-"
"operators), and [bitwise operators](#bitwise-operators), syntactic sugar for "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1965
+#: doc/rust.md:2034
#, no-wrap
msgid ""
"`==`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1968
+#: doc/rust.md:2037
msgid "#### Type cast expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1970
+#: doc/rust.md:2039
msgid "A type cast expression is denoted with the binary operator `as`."
msgstr ""
#. type: Plain text
-#: doc/rust.md:1973
+#: doc/rust.md:2042
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:1977
+#: doc/rust.md:2046
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1979
+#: doc/rust.md:2048
msgid "An example of an `as` expression:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1983
+#: doc/rust.md:2052
msgid ""
"~~~~ # fn sum(v: &[float]) -> float { 0.0 } # fn len(v: &[float]) -> int "
"{ 0 }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1990
+#: doc/rust.md:2059
#, no-wrap
msgid ""
"fn avg(v: &[float]) -> float {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1992
+#: doc/rust.md:2061
msgid "#### Assignment expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1995
+#: doc/rust.md:2064
msgid ""
"An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-"
"temporaries) expression followed by an equals sign (`=`) and an [rvalue]"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1997
+#: doc/rust.md:2066
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:2001
+#: doc/rust.md:2070
msgid "~~~~ # let mut x = 0; # let y = 0;"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2004
+#: doc/rust.md:2073
msgid "x = y; ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2006
+#: doc/rust.md:2075
msgid "#### Compound assignment expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2011
+#: doc/rust.md:2080
msgid ""
"The `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, and `>>` operators may be "
"composed with the `=` operator. The expression `lval OP= val` is equivalent "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2013
+#: doc/rust.md:2082
msgid "Any such expression always has the [`unit`](#primitive-types) type."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2015
+#: doc/rust.md:2084
msgid "#### Operator precedence"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2018
+#: doc/rust.md:2087
msgid ""
"The precedence of Rust binary operators is ordered as follows, going from "
"strong to weak:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2031
+#: doc/rust.md:2100
#, no-wrap
msgid ""
"~~~~ {.precedence}\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2033 doc/rust.md:2174 doc/tutorial-macros.md:323
+#: doc/rust.md:2102 doc/rust.md:2243 doc/tutorial-macros.md:323
msgid "~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2036
+#: doc/rust.md:2105
msgid ""
"Operators at the same precedence level are evaluated left-to-right. [Unary "
"operators](#unary-operator-expressions) have the same precedence level and "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2038
+#: doc/rust.md:2107
msgid "### Grouped expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2042
+#: doc/rust.md:2111
msgid ""
"An expression enclosed in parentheses evaluates to the result of the "
"enclosed expression. Parentheses can be used to explicitly specify "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2046
+#: doc/rust.md:2115
msgid "~~~~~~~~{.ebnf .gram} paren_expr : '(' expr ')' ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2048
+#: doc/rust.md:2117
msgid "An example of a parenthesized expression:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2052
+#: doc/rust.md:2121
msgid "~~~~ let x = (2 + 3) * 4; ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2054
+#: doc/rust.md:2123
msgid "### Unary copy expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2058
+#: doc/rust.md:2127
msgid "~~~~~~~~{.ebnf .gram} copy_expr : \"copy\" expr ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2061
+#: 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:2064
+#: 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:2068
+#: 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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2072
+#: 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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2075
+#: 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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2077
+#: doc/rust.md:2146
msgid "An example of a copy expression:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2082
+#: doc/rust.md:2151
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2084
+#: doc/rust.md:2153
msgid "let v = ~[1,2,3];"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2086
+#: doc/rust.md:2155
#, no-wrap
msgid "mutate(copy v); // Pass a copy\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2089
+#: doc/rust.md:2158
msgid "assert!(v[0] == 1); // Original was not modified ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2091
+#: doc/rust.md:2160
msgid "### Unary move expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2095
+#: doc/rust.md:2164
msgid "~~~~~~~~{.ebnf .gram} move_expr : \"move\" expr ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2102
+#: 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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2106
+#: 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) "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2109
+#: doc/rust.md:2178
msgid "### Call expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2115
+#: doc/rust.md:2184
msgid ""
"~~~~~~~~ {.abnf .gram} expr_list : [ expr [ ',' expr ]* ] ? ; "
"paren_expr_list : '(' expr_list ')' ; call_expr : expr paren_expr_list ; "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2120
+#: doc/rust.md:2189
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2122
+#: doc/rust.md:2191
msgid "Some examples of call expressions:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2126
+#: doc/rust.md:2195
msgid ""
"~~~~ # use std::from_str::FromStr; # fn add(x: int, y: int) -> int { 0 }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2130
+#: doc/rust.md:2199
msgid ""
"let x: int = add(1, 2); let pi = FromStr::from_str::<f32>(\"3.14\"); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2132
+#: doc/rust.md:2201
msgid "### Lambda expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2137
+#: doc/rust.md:2206
msgid ""
"~~~~~~~~ {.abnf .gram} ident_list : [ ident [ ',' ident ]* ] ? ; "
"lambda_expr : '|' ident_list '|' expr ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2141
+#: doc/rust.md:2210
msgid ""
"A _lambda expression_ (sometimes called an \"anonymous function expression"
"\") defines a function and denotes it as a value, in a single expression. A "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2146
+#: doc/rust.md:2215
msgid ""
"A lambda expression denotes a function that maps a list of parameters "
"(`ident_list`) onto the expression that follows the `ident_list`. The "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2149
+#: doc/rust.md:2218
msgid ""
"Lambda expressions are most useful when passing functions as arguments to "
"other functions, as an abbreviation for defining and capturing a separate "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2158
+#: doc/rust.md:2227
msgid ""
"Significantly, lambda expressions _capture their environment_, which regular "
"[function definitions](#functions) do not. The exact type of capture "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2161
+#: doc/rust.md:2230
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:2170
+#: doc/rust.md:2239
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2172
+#: doc/rust.md:2241
msgid "ten_times(|j| println(fmt!(\"hello, %d\", j)));"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2176
+#: doc/rust.md:2245
msgid "### While loops"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2180
+#: doc/rust.md:2249
msgid ""
"~~~~~~~~{.ebnf .gram} while_expr : \"while\" expr '{' block '}' ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2185
+#: doc/rust.md:2254
msgid ""
"A `while` loop begins by evaluating the boolean loop conditional "
"expression. If the loop conditional expression evaluates to `true`, the "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2187
+#: doc/rust.md:2256
msgid "An example:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2190
+#: doc/rust.md:2259
msgid "~~~~ let mut i = 0;"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2196
+#: doc/rust.md:2265
#, no-wrap
msgid ""
"while i < 10 {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2198
+#: doc/rust.md:2267
msgid "### Infinite loops"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2202
+#: doc/rust.md:2271
msgid ""
"The keyword `loop` in Rust appears both in _loop expressions_ and in "
"_continue expressions_. A loop expression denotes an infinite loop; see "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2206
+#: doc/rust.md:2275
msgid ""
"~~~~~~~~{.ebnf .gram} loop_expr : [ lifetime ':' ] \"loop\" '{' block '}'; "
"~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2211
+#: doc/rust.md:2280
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2213
+#: doc/rust.md:2282
msgid "### Break expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2217
+#: doc/rust.md:2286
msgid "~~~~~~~~{.ebnf .gram} break_expr : \"break\" [ lifetime ]; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2224
+#: doc/rust.md:2293
msgid ""
"A `break` expression has an optional `label`. If the label is absent, then "
"executing a `break` expression immediately terminates the innermost loop "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2226
+#: doc/rust.md:2295
msgid "### Continue expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2230
+#: doc/rust.md:2299
msgid "~~~~~~~~{.ebnf .gram} continue_expr : \"loop\" [ lifetime ]; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2241
+#: doc/rust.md:2310
msgid ""
"A continue expression, written `loop`, also has an optional `label`. If the "
"label is absent, then executing a `loop` expression immediately terminates "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2243
+#: doc/rust.md:2312
msgid "A `loop` expression is only permitted in the body of a loop."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2246
+#: doc/rust.md:2315
msgid "### Do expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2250
+#: doc/rust.md:2319
msgid ""
"~~~~~~~~{.ebnf .gram} do_expr : \"do\" expr [ '|' ident_list '|' ] ? '{' "
"block '}' ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2253
+#: doc/rust.md:2322
msgid ""
"A _do expression_ provides a more-familiar block-syntax for a [lambda "
"expression](#lambda-expressions), including a special translation of [return "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2261
+#: doc/rust.md:2330
msgid ""
"Any occurrence of a [return expression](#return-expressions) inside this "
"`block` expression is rewritten as a reference to an (anonymous) flag set in "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2264
+#: doc/rust.md:2333
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2270
+#: doc/rust.md:2339
msgid ""
"The lambda expression is then provided as a _trailing argument_ to the "
"outermost [call](#call-expressions) or [method call](#method-call-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2272
+#: doc/rust.md:2341
msgid "In this example, both calls to `f` are equivalent:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2276
+#: doc/rust.md:2345
msgid "~~~~ # fn f(f: &fn(int)) { } # fn g(i: int) { }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2278
+#: doc/rust.md:2347
msgid "f(|j| g(j));"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2283
+#: doc/rust.md:2352
#, no-wrap
msgid ""
"do f |j| {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2285
+#: doc/rust.md:2354
msgid ""
"In this example, both calls to the (binary) function `k` are equivalent:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2289
+#: doc/rust.md:2358
msgid "~~~~ # fn k(x:int, f: &fn(int)) { } # fn l(i: int) { }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2291
+#: doc/rust.md:2360
msgid "k(3, |j| l(j));"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2296
+#: doc/rust.md:2365
#, no-wrap
msgid ""
"do k(3) |j| {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2299
+#: doc/rust.md:2368
msgid "### For expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2303
+#: doc/rust.md:2372
msgid ""
"~~~~~~~~{.ebnf .gram} for_expr : \"for\" expr [ '|' ident_list '|' ] ? '{' "
"block '}' ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2307
+#: doc/rust.md:2376
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2313
+#: doc/rust.md:2382
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2320
+#: doc/rust.md:2389
msgid ""
"In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) "
"expressions are rewritten inside `for` expressions in the same way that "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2322
+#: doc/rust.md:2391
msgid "An example of a for loop over the contents of a vector:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2329
+#: doc/rust.md:2398
msgid ""
"~~~~ # type foo = int; # fn bar(f: foo) { } # let a = 0; # let b = 0; # let "
"c = 0;"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2331
+#: doc/rust.md:2400
msgid "let v: &[foo] = &[a, b, c];"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2336
+#: doc/rust.md:2405
#, no-wrap
msgid ""
"for v.iter().advance |e| {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2338
+#: doc/rust.md:2407
msgid "An example of a for loop over a series of integers:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2346
+#: doc/rust.md:2415
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2348
+#: doc/rust.md:2417
msgid "### If expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2352
+#: doc/rust.md:2421
#, no-wrap
msgid ""
"~~~~~~~~{.ebnf .gram}\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2356
+#: doc/rust.md:2425
#, no-wrap
msgid ""
"else_tail : \"else\" [ if_expr\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2367
+#: doc/rust.md:2436
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2370
+#: doc/rust.md:2439
msgid "### Match expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2373
+#: doc/rust.md:2442
msgid ""
"~~~~~~~~{.ebnf .gram} match_expr : \"match\" expr '{' match_arm [ '|' "
"match_arm ] * '}' ;"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2375
+#: doc/rust.md:2444
msgid "match_arm : match_pat '=>' [ expr \",\" | '{' block '}' ] ;"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2378
+#: doc/rust.md:2447
msgid "match_pat : pat [ \"..\" pat ] ? [ \"if\" expr ] ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2386
+#: doc/rust.md:2455
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2390
+#: doc/rust.md:2459
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* "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2393
+#: doc/rust.md:2462
msgid "~~~~ enum List<X> { Nil, Cons(X, @List<X>) }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2395 doc/rust.md:2424
+#: doc/rust.md:2464 doc/rust.md:2493
msgid "let x: List<int> = Cons(10, @Cons(11, @Nil));"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2402
+#: doc/rust.md:2471
#, no-wrap
msgid ""
"match x {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2407
+#: doc/rust.md:2476
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2413
+#: doc/rust.md:2482
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2415
+#: doc/rust.md:2484
msgid "An example of an `match` expression:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2420
+#: doc/rust.md:2489
msgid "~~~~ # fn process_pair(a: int, b: int) { } # fn process_ten() { }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2422
+#: doc/rust.md:2491
msgid "enum List<X> { Nil, Cons(X, @List<X>) }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2440
+#: doc/rust.md:2509
#, no-wrap
msgid ""
"match x {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2446
+#: doc/rust.md:2515
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2457
+#: doc/rust.md:2526
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2461
+#: doc/rust.md:2530
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:2464
+#: doc/rust.md:2533
msgid "~~~~ # let x = 2;"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2471
+#: doc/rust.md:2540
#, no-wrap
msgid ""
"let message = match x {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2475
+#: doc/rust.md:2544
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2480
+#: doc/rust.md:2549
msgid ""
"Finally, match patterns can accept *pattern guards* to further refine the "
"criteria for matching a case. Pattern guards appear after the pattern and "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2485
+#: doc/rust.md:2554
msgid ""
"~~~~ # let maybe_digit = Some(0); # fn process_digit(i: int) { } # fn "
"process_other(i: int) { }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2492
+#: doc/rust.md:2561
#, no-wrap
msgid ""
"let message = match maybe_digit {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2494
+#: doc/rust.md:2563
msgid "### Return expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2498
+#: doc/rust.md:2567
msgid "~~~~~~~~{.ebnf .gram} return_expr : \"return\" expr ? ; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2503
+#: doc/rust.md:2572
msgid ""
"Return expressions are denoted with the keyword `return`. Evaluating a "
"`return` expression moves its argument into the output slot of the current "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2505
+#: doc/rust.md:2574
msgid "An example of a `return` expression:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2514
+#: doc/rust.md:2583
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2517
+#: doc/rust.md:2586
msgid "# Type system"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2519
+#: doc/rust.md:2588
msgid "## Types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2522
+#: doc/rust.md:2591
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:2526
+#: doc/rust.md:2595
msgid ""
"Built-in types and type-constructors are tightly integrated into the "
"language, in nontrivial ways that are not possible to emulate in user-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2528
+#: doc/rust.md:2597
msgid "### Primitive types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2530
+#: doc/rust.md:2599
msgid "The primitive types are the following:"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2536
+#: doc/rust.md:2605
msgid ""
"The \"unit\" type `()`, having the single \"unit\" value `()` (occasionally "
"called \"nil\"). ^[The \"unit\" value `()` is *not* a sentinel \"null "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2536
+#: doc/rust.md:2605
msgid "The boolean type `bool` with values `true` and `false`."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2536
+#: doc/rust.md:2605
msgid "The machine types."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2536
+#: doc/rust.md:2605
msgid "The machine-dependent integer and floating-point types."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2538
+#: doc/rust.md:2607
msgid "#### Machine types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2540
+#: doc/rust.md:2609
msgid "The machine types are the following:"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2545
+#: doc/rust.md:2614
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]$ "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2550
+#: doc/rust.md:2619
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}), "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2553
+#: doc/rust.md:2622
msgid ""
"The IEEE 754-2008 `binary32` and `binary64` floating-point types: `f32` and "
"`f64`, respectively."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2555
+#: doc/rust.md:2624
msgid "#### Machine-dependent integer types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2560
+#: doc/rust.md:2629
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2565
+#: doc/rust.md:2634
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2568
+#: doc/rust.md:2637
msgid "#### Machine-dependent floating point type"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2575
+#: doc/rust.md:2644
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2578
+#: doc/rust.md:2647
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:2581
+#: doc/rust.md:2650
msgid "### Textual types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2583
+#: doc/rust.md:2652
msgid "The types `char` and `str` hold textual data."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2586
+#: doc/rust.md:2655
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:2592
+#: doc/rust.md:2661
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2595
+#: doc/rust.md:2664
msgid "### Tuple types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2598
+#: doc/rust.md:2667
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:2601
+#: doc/rust.md:2670
msgid "tuple elements cannot be mutable, unlike record fields"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:2601
+#: doc/rust.md:2670
msgid ""
"tuple elements are not named and can be accessed only by pattern-matching"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2605
+#: doc/rust.md:2674
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:2608
+#: doc/rust.md:2677
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:2610
+#: doc/rust.md:2679
msgid "An example of a tuple type and its use:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2617
+#: doc/rust.md:2686
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:2620
+#: doc/rust.md:2689
msgid "### Vector types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2633
+#: doc/rust.md:2702
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2637
+#: doc/rust.md:2706
msgid ""
"Expressions producing vectors of definite size cannot be evaluated in a "
"context expecting a vector of indefinite size; one must copy the definite-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2639
+#: doc/rust.md:2708
msgid "An example of a vector type and its use:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2645
+#: doc/rust.md:2714
msgid ""
"~~~~ let v: &[int] = &[7, 5, 3]; let i: int = v[2]; assert!(i == 3); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2648
+#: doc/rust.md:2717
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:2651
+#: doc/rust.md:2720
msgid "### Structure types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2656
+#: doc/rust.md:2725
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, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2658
+#: doc/rust.md:2727
msgid ""
"New instances of a `struct` can be constructed with a [struct expression]"
"(#struct-expressions)."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2662
+#: doc/rust.md:2731
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2665
+#: doc/rust.md:2734
msgid ""
"The fields of a `struct` may be qualified by [visibility modifiers]"
"(#visibility-modifiers), to restrict access to implementation-private data "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2667
+#: doc/rust.md:2736
msgid ""
"A _tuple struct_ type is just like a structure type, except that the fields "
"are anonymous."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2670
+#: doc/rust.md:2739
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]"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2672
+#: doc/rust.md:2741
msgid "### Enumerated types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2677
+#: doc/rust.md:2746
msgid ""
"An *enumerated type* is a nominal, heterogeneous disjoint union type, "
"denoted by the name of an [`enum` item](#enumerations). ^[The `enum` type "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2680
+#: doc/rust.md:2749
msgid ""
"An [`enum` item](#enumerations) declares both the type and a number of "
"*variant constructors*, each of which is independently named and takes an "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2683
+#: doc/rust.md:2752
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:2685
+#: doc/rust.md:2754
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:2688
+#: doc/rust.md:2757
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:2691
+#: doc/rust.md:2760
msgid "### Recursive types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2695
+#: doc/rust.md:2764
msgid ""
"Nominal types -- [enumerations](#enumerated-types) and [structures]"
"(#structure-types) -- may be recursive. That is, each `enum` constructor or "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2705
+#: doc/rust.md:2774
#, no-wrap
msgid ""
"* Recursive types must include a nominal type in the recursion\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2707
+#: doc/rust.md:2776
msgid "An example of a *recursive* type and its use:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2713
+#: doc/rust.md:2782
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2716
+#: doc/rust.md:2785
msgid "let a: List<int> = Cons(7, @Cons(13, @Nil)); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2719
+#: doc/rust.md:2788
msgid "### Pointer types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2723
+#: doc/rust.md:2792
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2733
+#: doc/rust.md:2802
#, no-wrap
msgid ""
"Managed pointers (`@`)\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2742
+#: doc/rust.md:2811
#, no-wrap
msgid ""
"Owning pointers (`~`)\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2755
+#: doc/rust.md:2824
#, no-wrap
msgid ""
"Borrowed pointers (`&`)\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2765
+#: doc/rust.md:2834
#, no-wrap
msgid ""
"Raw pointers (`*`)\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2768
+#: doc/rust.md:2837
msgid "### Function types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2772
+#: doc/rust.md:2841
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2774
+#: doc/rust.md:2843
msgid "An example of a `fn` type:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2779
+#: doc/rust.md:2848
#, no-wrap
msgid ""
"~~~~~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2781
+#: doc/rust.md:2850
msgid "let mut x = add(5,7);"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2786
+#: doc/rust.md:2855
msgid ""
"type Binop<'self> = &'self fn(int,int) -> int; let bo: Binop = add; x = "
"bo(5,7); ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2788
+#: doc/rust.md:2857
msgid "### Object types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2795
+#: doc/rust.md:2864
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2800
+#: doc/rust.md:2869
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`, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2802
+#: doc/rust.md:2871
msgid "An example of an object type:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2808
+#: doc/rust.md:2877
#, no-wrap
msgid ""
"~~~~~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2812
+#: doc/rust.md:2881
#, no-wrap
msgid ""
"impl Printable for int {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2816
+#: doc/rust.md:2885
#, no-wrap
msgid ""
"fn print(a: @Printable) {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2821
+#: doc/rust.md:2890
#, no-wrap
msgid ""
"fn main() {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2824
+#: doc/rust.md:2893
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:2826
+#: doc/rust.md:2895
msgid "### Type parameters"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2828
+#: doc/rust.md:2897
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:2837
+#: doc/rust.md:2906
#, no-wrap
msgid ""
"~~~~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2840
+#: doc/rust.md:2909
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:2842
+#: doc/rust.md:2911
msgid "### Self types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2846
+#: doc/rust.md:2915
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:2851
+#: doc/rust.md:2920
#, no-wrap
msgid ""
"~~~~~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2856
+#: doc/rust.md:2925
#, no-wrap
msgid ""
"impl Printable for ~str {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2859
+#: doc/rust.md:2928
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:2861
+#: doc/rust.md:2930
msgid "## Type kinds"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2864
+#: doc/rust.md:2933
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:2884
+#: doc/rust.md:2953
#, no-wrap
msgid ""
"`Freeze`\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2891
+#: doc/rust.md:2960
#, no-wrap
msgid ""
"_Default_\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2894
+#: doc/rust.md:2963
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:2896
+#: 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:2900
+#: 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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2904
+#: doc/rust.md:2973
msgid "~~~~{.xfail-test} fn box<T>(x: T) -> @T { @x } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2907
+#: 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:2911
+#: doc/rust.md:2980
msgid "~~~~ fn box<T: Copy>(x: T) -> @T { @x } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2916
+#: doc/rust.md:2985
msgid ""
"Calling this second version of `box` on a noncopyable type is not allowed. "
"When instantiating a type parameter, the kind bounds on the parameter are "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2920
+#: doc/rust.md:2989
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2922
+#: doc/rust.md:2991
msgid "# Memory and concurrency models"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2927
+#: doc/rust.md:2996
msgid ""
"Rust has a memory model centered around concurrently-executing _tasks_. Thus "
"its memory model and its concurrency model are best discussed "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2932
+#: doc/rust.md:3001
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2934
+#: doc/rust.md:3003
msgid "## Memory model"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2938
+#: doc/rust.md:3007
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2941
+#: doc/rust.md:3010
msgid ""
"Allocations in the stack consist of *slots*, and allocations in the heap "
"consist of *boxes*."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2944
+#: doc/rust.md:3013
msgid "### Memory allocation and lifetime"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2949
+#: doc/rust.md:3018
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2953
+#: doc/rust.md:3022
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2960
+#: doc/rust.md:3029
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2962
+#: doc/rust.md:3031
msgid "### Memory ownership"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2965
+#: doc/rust.md:3034
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:2972
+#: doc/rust.md:3041
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2975
+#: doc/rust.md:3044
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:2981
+#: doc/rust.md:3050
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:2984
+#: doc/rust.md:3053
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:2987
+#: doc/rust.md:3056
msgid "### Memory slots"
msgstr ""
#. type: Plain text
-#: doc/rust.md:2989
+#: doc/rust.md:3058
msgid "A task's stack contains slots."
msgstr ""
#. type: Plain text
-#: doc/rust.md:2992
+#: doc/rust.md:3061
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:2995
+#: doc/rust.md:3064
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:3000
+#: doc/rust.md:3069
msgid ""
"Local variables are immutable unless declared with `let mut`. The `mut` "
"keyword applies to all local variables declared within that declaration (so "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3005
+#: doc/rust.md:3074
msgid ""
"Function parameters are immutable unless declared with `mut`. The `mut` "
"keyword applies only to the following parameter (so `|mut x, y|` and `fn "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3011
+#: doc/rust.md:3080
msgid ""
"Local variables are not initialized when allocated; the entire frame worth "
"of local variables are allocated at once, on frame-entry, in an "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3014
+#: doc/rust.md:3083
msgid "### Memory boxes"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3017
+#: doc/rust.md:3086
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:3019
+#: doc/rust.md:3088
msgid ""
"A _managed box_ type or value is constructed by the prefix *at* sigil `@`."
msgstr ""
#. type: Plain text
-#: doc/rust.md:3021
+#: doc/rust.md:3090
msgid ""
"An _owned box_ type or value is constructed by the prefix *tilde* sigil `~`."
msgstr ""
#. type: Plain text
-#: doc/rust.md:3026
+#: doc/rust.md:3095
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3030
+#: doc/rust.md:3099
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3033
+#: doc/rust.md:3102
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:3038
+#: doc/rust.md:3107
msgid "~~~~~~~~ let x: @int = @10; let x: ~int = ~10; ~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3041
+#: doc/rust.md:3110
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:3047
+#: doc/rust.md:3116
msgid ""
"~~~~~~~~ struct Foo { y: int } let x = @Foo{y: 10}; assert!(x.y == 10); "
"~~~~~~~~"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3053
+#: doc/rust.md:3122
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 "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3056
+#: doc/rust.md:3125
msgid "copying box values (`x = y`)"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3056
+#: doc/rust.md:3125
msgid "passing box values to functions (`f(x,y)`)"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3059
+#: doc/rust.md:3128
msgid ""
"An example of an explicit-dereference operation performed on box values:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3063
+#: doc/rust.md:3132
msgid "~~~~~~~~ fn takes_boxed(b: @int) { }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3066
+#: doc/rust.md:3135
msgid "fn takes_unboxed(b: int) { }"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3073
+#: doc/rust.md:3142
#, no-wrap
msgid ""
"fn main() {\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3075
+#: doc/rust.md:3144
msgid "## Tasks"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3083
+#: doc/rust.md:3152
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3098
+#: doc/rust.md:3167
msgid ""
"Multiple Rust tasks may coexist in a single operating-system process. The "
"runtime scheduler maps tasks to a certain number of operating-system "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3101
+#: doc/rust.md:3170
msgid "### Communication between tasks"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3106
+#: doc/rust.md:3175
msgid ""
"Rust tasks are isolated and generally unable to interfere with one another's "
"memory directly, except through [`unsafe` code](#unsafe-functions). All "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3109
+#: doc/rust.md:3178
msgid ""
"Inter-task communication and co-ordination facilities are provided in the "
"standard library. These include:"
msgstr ""
#. type: Bullet: ' - '
-#: doc/rust.md:3113
+#: doc/rust.md:3182
msgid ""
"synchronous and asynchronous communication channels with various "
"communication topologies"
msgstr ""
#. type: Bullet: ' - '
-#: doc/rust.md:3113
+#: doc/rust.md:3182
msgid ""
"read-only and read-write shared variables with various safe mutual exclusion "
"patterns"
msgstr ""
#. type: Bullet: ' - '
-#: doc/rust.md:3113
+#: doc/rust.md:3182
msgid "simple locks and semaphores"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3118
+#: doc/rust.md:3187
msgid ""
"When such facilities carry values, the values are restricted to the [`Send` "
"type-kind](#type-kinds). Restricting communication interfaces to this kind "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3121
+#: doc/rust.md:3190
msgid "### Task lifecycle"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3124
+#: doc/rust.md:3193
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:3129
+#: doc/rust.md:3198
msgid "running"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3129
+#: doc/rust.md:3198
msgid "blocked"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3129
+#: doc/rust.md:3198
msgid "failing"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3129
+#: doc/rust.md:3198
msgid "dead"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3133
+#: doc/rust.md:3202
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3139
+#: doc/rust.md:3208
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3158
+#: doc/rust.md:3227
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!()` "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3162
+#: doc/rust.md:3231
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3165
+#: doc/rust.md:3234
msgid "### Task scheduling"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3169
+#: doc/rust.md:3238
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3173
+#: doc/rust.md:3242
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-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3176
+#: doc/rust.md:3245
msgid "# Runtime services, linkage and debugging"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3183
+#: doc/rust.md:3252
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-"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3185
+#: doc/rust.md:3254
msgid ""
"> **Note:** The runtime library will merge with the `std` library in future "
"versions of Rust."
msgstr ""
#. type: Plain text
-#: doc/rust.md:3187
+#: doc/rust.md:3256
msgid "### Memory allocation"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3193
+#: doc/rust.md:3262
msgid ""
"The runtime memory-management system is based on a _service-provider "
"interface_, through which the runtime requests blocks of memory from its "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3197
+#: doc/rust.md:3266
msgid ""
"The runtime memory-management system, in turn, supplies Rust tasks with "
"facilities for allocating, extending and releasing stacks, as well as "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3199
+#: doc/rust.md:3268
msgid "### Built in types"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3203
+#: doc/rust.md:3272
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, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3206
+#: doc/rust.md:3275
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:3210
+#: doc/rust.md:3279
msgid "### Task scheduling and communication"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3216
+#: doc/rust.md:3285
msgid ""
"The runtime provides code to manage inter-task communication. This includes "
"the system of task-lifecycle state transitions depending on the contents of "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3219
+#: doc/rust.md:3288
msgid "### Logging system"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3223
+#: doc/rust.md:3292
msgid ""
"The runtime contains a system for directing [logging expressions](#log-"
"expressions) to a logging console and/or internal logging buffers. Logging "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3230
+#: doc/rust.md:3299
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3238
+#: doc/rust.md:3307
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3244
+#: doc/rust.md:3313
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` "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3249
+#: doc/rust.md:3318
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, "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3253
+#: doc/rust.md:3322
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 "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3258
+#: doc/rust.md:3327
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, "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::mem` Memory management"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::comm` Messaging and task communication"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::task` Task management"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::dom` Task scheduling"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::trace` Unused"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::cache` Type descriptor cache"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::upcall` Compiler-generated runtime calls"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::timer` The scheduler timer"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::gc` Garbage collection"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::stdlib` Functions used directly by the standard library"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::kern` The runtime kernel"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::backtrace` Log a backtrace on task failure"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3272
+#: doc/rust.md:3341
msgid "`::rt::callback` Unused"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3274
+#: doc/rust.md:3343
msgid "#### Logging Expressions"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3277
+#: doc/rust.md:3346
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:3286
+#: doc/rust.md:3355
#, no-wrap
msgid ""
"```rust\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3288
+#: doc/rust.md:3357
msgid ""
"These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3295
+#: doc/rust.md:3364
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\\\"\" "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3297
+#: doc/rust.md:3366
msgid "# Appendix: Rationales and design tradeoffs"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3299
+#: doc/rust.md:3368
#, no-wrap
msgid "*TODO*.\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3301
+#: doc/rust.md:3370
msgid "# Appendix: Influences and further references"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3303
+#: doc/rust.md:3372
msgid "## Influences"
msgstr ""
#. type: Plain text
-#: doc/rust.md:3312
+#: doc/rust.md:3381
msgid ""
"> The essential problem that must be solved in making a fault-tolerant > "
"software system is therefore that of fault-isolation. Different programmers "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3324
+#: doc/rust.md:3393
msgid ""
"> In our approach, all data is private to some process, and processes can > "
"only communicate through communications channels. *Security*, as used > in "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3332
+#: doc/rust.md:3401
msgid ""
"> Concurrent and applicative programming complement each other. The > "
"ability to send messages on channels provides I/O without side effects, > "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3339
+#: doc/rust.md:3408
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 "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3343
+#: doc/rust.md:3412
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 "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3347
+#: doc/rust.md:3416
msgid ""
"The Erlang (1987) language, developed by Joe Armstrong, Robert Virding, "
"Claes Wikström, Mike Williams and others in their group at the Ericsson "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3352
+#: doc/rust.md:3421
msgid ""
"The Sather (1990) language, developed by Stephen Omohundro, Chu-Cheow Lim, "
"Heinz Schmidt and others in their group at The International Computer "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3357
+#: doc/rust.md:3426
msgid ""
"The Newsqueak (1988), Alef (1995), and Limbo (1996) family. These languages "
"were developed by Rob Pike, Phil Winterbottom, Sean Dorward and others in "
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3361
+#: doc/rust.md:3430
msgid ""
"The Napier (1985) and Napier88 (1988) family. These languages were developed "
"by Malcolm Atkinson, Ron Morrison and others in their group at the "
msgstr ""
#. type: Plain text
-#: doc/rust.md:3363
+#: doc/rust.md:3432
msgid ""
"Additional specific influences can be seen from the following languages:"
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The stack-growth implementation of Go."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The structural algebraic types and compilation manager of SML."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The attribute and assembly systems of C#."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The references and deterministic destructor system of C++."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The memory region systems of the ML Kit and Cyclone."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The typeclass system of Haskell."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The lexical identifier rule of Python."
msgstr ""
#. type: Bullet: '* '
-#: doc/rust.md:3371
+#: doc/rust.md:3440
msgid "The block syntax of Ruby."
msgstr ""
# SOME DESCRIPTIVE TITLE
-# Copyright (C) YEAR Free Software Foundation, Inc.
-# This file is distributed under the same license as the PACKAGE package.
+# Copyright (C) YEAR The Rust Project Developers
+# This file is distributed under the same license as the Rust package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2013-07-07 21:10+0300\n"
+"Project-Id-Version: Rust 0.8-pre\n"
+"POT-Creation-Date: 2013-07-17 07:18+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#. type: Plain text
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
#: doc/tutorial-borrowed-ptr.md:4 doc/tutorial-ffi.md:4
-#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4 doc/tut.md:4
+#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4
msgid "# Introduction"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1231 doc/tutorial.md:2179
+#: doc/rust.md:1231 doc/tutorial.md:2177
msgid ""
"In type-parameterized functions, methods of the supertrait may be called on "
"values of subtrait-bound type parameters. Refering to the previous example "
msgstr ""
#. type: Plain text
-#: doc/rust.md:1240 doc/tutorial.md:2188
+#: doc/rust.md:1240 doc/tutorial.md:2186
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/rust.md:1242 doc/tutorial.md:2190
+#: doc/rust.md:1242 doc/tutorial.md:2188
msgid "Likewise, supertrait methods may also be called on trait objects."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2 doc/tut.md:2
+#: doc/tutorial.md:2
msgid "% The Rust Language Tutorial"
msgstr ""
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:515
+#: doc/tutorial.md:516
#, no-wrap
msgid ""
"~~~~\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"
" (0f, y) if y < 0f => 1.5 * pi,\n"
" (0f, y) => 0.5 * pi,\n"
-" (x, y) => float::atan(y / x)\n"
+" (x, y) => atan(y / x)\n"
" }\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:521
+#: doc/tutorial.md:522
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)` "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:528
+#: doc/tutorial.md:529
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, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:533
+#: doc/tutorial.md:534
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. "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:538
+#: doc/tutorial.md:539
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:542
+#: doc/tutorial.md:543
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:544
+#: doc/tutorial.md:545
msgid "## Loops"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:549
+#: doc/tutorial.md:550
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:556
+#: doc/tutorial.md:557
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:558
+#: doc/tutorial.md:559
msgid ""
"`loop` denotes an infinite loop, and is the preferred way of writing `while "
"true`:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:568
+#: doc/tutorial.md:569
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:571
+#: doc/tutorial.md:572
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:576
+#: 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]"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:578
+#: doc/tutorial.md:579
msgid "# Data structures"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:580
+#: doc/tutorial.md:581
msgid "## Structs"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:585
+#: doc/tutorial.md:586
msgid ""
"Rust struct types must be declared before they are used using the `struct` "
"syntax: `struct Name { field1: T1, field2: T2 [, ...] }`, where `T1`, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:589
+#: doc/tutorial.md:590
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:596
+#: doc/tutorial.md:597
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:600
+#: doc/tutorial.md:601
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:604
+#: doc/tutorial.md:605
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:609
+#: doc/tutorial.md:610
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:613
+#: doc/tutorial.md:614
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:616
+#: doc/tutorial.md:617
msgid ""
"`match` patterns destructure structs. The basic syntax is `Name { fieldname: "
"pattern, ... }`:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:625
+#: doc/tutorial.md:626
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:632
+#: doc/tutorial.md:633
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:640
+#: doc/tutorial.md:641
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:642
+#: doc/tutorial.md:643
msgid "## Enums"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:645
+#: doc/tutorial.md:646
msgid ""
"Enums are datatypes that have several alternate representations. For "
"example, consider the type shown earlier:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:653
+#: doc/tutorial.md:654
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:659
+#: doc/tutorial.md:660
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:665
+#: doc/tutorial.md:666
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:668
+#: doc/tutorial.md:669
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:677
+#: doc/tutorial.md:678
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:680
+#: doc/tutorial.md:681
msgid ""
"This declaration defines `North`, `East`, `South`, and `West` as constants, "
"all of which have type `Direction`."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:684
+#: doc/tutorial.md:685
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:692
+#: doc/tutorial.md:693
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:697
+#: doc/tutorial.md:698
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:700
+#: doc/tutorial.md:701
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:704
+#: doc/tutorial.md:705
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:716
+#: doc/tutorial.md:717
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:721
+#: doc/tutorial.md:722
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, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:734
+#: doc/tutorial.md:735
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:736
+#: doc/tutorial.md:737
msgid "Enum variants may also be structs. For example:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:754
+#: doc/tutorial.md:755
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:756
+#: doc/tutorial.md:757
msgid "## Tuples"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:761
+#: doc/tutorial.md:762
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:768
+#: doc/tutorial.md:769
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:770
+#: doc/tutorial.md:771
msgid "## Tuple structs"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:775
+#: doc/tutorial.md:776
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:784
+#: doc/tutorial.md:785
#, no-wrap
msgid ""
"For example:\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:786
+#: doc/tutorial.md:787
msgid "<a name=\"newtype\"></a>"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:791
+#: doc/tutorial.md:792
msgid ""
"There is a special case for tuple structs with a single field, which are "
"sometimes called \"newtypes\" (after Haskell's \"newtype\" feature). These "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:795
+#: doc/tutorial.md:796
msgid "~~~~ struct GizmoId(int); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:798
+#: doc/tutorial.md:799
msgid ""
"For convenience, you can extract the contents of such a struct with the "
"dereference (`*`) unary operator:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:804
+#: doc/tutorial.md:805
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:807
+#: doc/tutorial.md:808
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:812
+#: doc/tutorial.md:813
msgid "~~~~ struct Inches(int); struct Centimeters(int); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:815
+#: doc/tutorial.md:816
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:817
+#: doc/tutorial.md:818
msgid "# Functions"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:825
+#: doc/tutorial.md:826
msgid ""
"We've already seen several function definitions. Like all other static "
"declarations, such as `type`, functions can be declared both at the top "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:831
+#: doc/tutorial.md:832
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:836
+#: doc/tutorial.md:837
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:842
+#: doc/tutorial.md:843
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:849
+#: doc/tutorial.md:850
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:852
+#: doc/tutorial.md:853
msgid "~~~~ fn do_nothing_the_hard_way() -> () { return (); }"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:855
+#: doc/tutorial.md:856
msgid "fn do_nothing_the_easy_way() { } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:857
+#: doc/tutorial.md:858
msgid ""
"Ending the function with a semicolon like so is equivalent to returning `()`."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:861
+#: doc/tutorial.md:862
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:865
+#: doc/tutorial.md:866
msgid "assert!(8 == line(5, 3, 1)); assert!(() == oops(5, 3, 1)); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:869
+#: doc/tutorial.md:870
msgid ""
"As with `match` expressions and `let` bindings, function arguments support "
"pattern destructuring. Like `let`, argument patterns must be irrefutable, as "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:873
+#: doc/tutorial.md:874
msgid "~~~ fn first((value, _): (int, float)) -> int { value } ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:875 doc/tutorial-ffi.md:143
+#: doc/tutorial.md:876 doc/tutorial-ffi.md:143
msgid "# Destructors"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:879
+#: doc/tutorial.md:880
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:883
+#: doc/tutorial.md:884
msgid ""
"Objects are never accessible after their destructor has been called, so "
"there are no dynamic failures from accessing freed resources. When a task "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:885
+#: doc/tutorial.md:886
msgid ""
"The `~` sigil represents a unique handle for a memory allocation on the heap:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:893
+#: doc/tutorial.md:894
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:897
+#: doc/tutorial.md:898
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:899
+#: doc/tutorial.md:900
msgid "# Ownership"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:904
+#: doc/tutorial.md:905
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:910
+#: doc/tutorial.md:911
msgid ""
"Ownership is recursive, so mutability is inherited recursively and a "
"destructor destroys the contained tree of owned objects. Variables are top-"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:914
+#: doc/tutorial.md:915
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:921
+#: doc/tutorial.md:922
#, no-wrap
msgid ""
"{\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:926
+#: doc/tutorial.md:927
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:932
+#: doc/tutorial.md:933
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:934
+#: doc/tutorial.md:935
msgid "# Boxes"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:941
+#: doc/tutorial.md:942
msgid ""
"Many modern languages represent values as pointers to heap memory by "
"default. In contrast, Rust, like C and C++, represents such types directly. "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:946
+#: doc/tutorial.md:947
msgid ""
"For small structs like `Point`, this is usually more efficient than "
"allocating memory and indirecting through a pointer. But for big structs, or "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:948
+#: doc/tutorial.md:949
msgid "## Owned boxes"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:951
+#: doc/tutorial.md:952
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:956
+#: doc/tutorial.md:957
msgid "~~~~ let x = 5; // immutable let mut y = 5; // mutable y += 2;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:961
+#: doc/tutorial.md:962
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:966
+#: doc/tutorial.md:967
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:969
+#: doc/tutorial.md:970
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:975
+#: doc/tutorial.md:976
#, no-wrap
msgid ""
"~~~~ {.xfail-test}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:979
+#: doc/tutorial.md:980
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:983
+#: doc/tutorial.md:984
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:989
+#: doc/tutorial.md:990
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:991
+#: doc/tutorial.md:992
msgid "## Managed boxes"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:999
+#: doc/tutorial.md:1000
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1002
+#: doc/tutorial.md:1003
msgid "~~~~ let a = @5; // immutable"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1005
+#: doc/tutorial.md:1006
msgid "let mut b = @5; // mutable variable, immutable box b = @10;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1008
+#: doc/tutorial.md:1009
msgid "let c = @mut 5; // immutable variable, mutable box *c = 10;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1013
+#: doc/tutorial.md:1014
msgid ""
"let mut d = @mut 5; // mutable variable, mutable box *d += 5; d = @mut 15; "
"~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1018
+#: doc/tutorial.md:1019
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1022
+#: doc/tutorial.md:1023
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1025
+#: doc/tutorial.md:1026
#, no-wrap
msgid ""
"let mut c : @int; // declare a variable with type managed immutable int\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1029
+#: doc/tutorial.md:1030
#, no-wrap
msgid ""
"c = a; // box type is the same, okay\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1034
+#: doc/tutorial.md:1035
#, no-wrap
msgid ""
"~~~~ {.xfail-test}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1036
+#: doc/tutorial.md:1037
msgid "# Move semantics"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1042
+#: doc/tutorial.md:1043
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1048
+#: doc/tutorial.md:1049
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:1051
+#: doc/tutorial.md:1052
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:1058
+#: doc/tutorial.md:1059
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:1060
+#: doc/tutorial.md:1061
msgid "# Borrowed pointers"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1066
+#: doc/tutorial.md:1067
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1068
+#: doc/tutorial.md:1069
msgid "As an example, consider a simple struct type, `Point`:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1075
+#: doc/tutorial.md:1076
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1079
+#: doc/tutorial.md:1080
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1086
+#: doc/tutorial.md:1087
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1098
+#: doc/tutorial.md:1099
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1108
+#: doc/tutorial.md:1109
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1110 doc/tutorial-borrowed-ptr.md:72
+#: doc/tutorial.md:1111 doc/tutorial-borrowed-ptr.md:72
msgid "Now we can call `compute_distance()` in various ways:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1120
+#: doc/tutorial.md:1121
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1127
+#: doc/tutorial.md:1128
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1133
+#: doc/tutorial.md:1134
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1142
+#: doc/tutorial.md:1143
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1145
+#: doc/tutorial.md:1146
msgid ""
"For a more in-depth explanation of borrowed pointers, read the [borrowed "
"pointer tutorial][borrowtut]."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1147
+#: doc/tutorial.md:1148
msgid "[borrowtut]: tutorial-borrowed-ptr.html"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1149
+#: doc/tutorial.md:1150
msgid "## Freezing"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1152
+#: doc/tutorial.md:1153
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:1160
+#: doc/tutorial.md:1161
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1164
+#: doc/tutorial.md:1165
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1174
+#: doc/tutorial.md:1175
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1176
+#: doc/tutorial.md:1177
msgid "# Dereferencing pointers"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1179
+#: doc/tutorial.md:1180
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:1184
+#: doc/tutorial.md:1185
msgid "~~~ let managed = @10; let owned = ~20; let borrowed = &30;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1187
+#: doc/tutorial.md:1188
msgid "let sum = *managed + *owned + *borrowed; ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1191
+#: doc/tutorial.md:1192
msgid ""
"Dereferenced mutable pointers may appear on the left hand side of "
"assignments. Such an assignment modifies the value that the pointer points "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1195
+#: doc/tutorial.md:1196
msgid "~~~ let managed = @mut 10; let mut owned = ~20;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1198
+#: doc/tutorial.md:1199
msgid "let mut value = 30; let borrowed = &mut value;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1203
+#: doc/tutorial.md:1204
#, no-wrap
msgid ""
"*managed = *owned + 10;\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1207
+#: doc/tutorial.md:1208
msgid ""
"Pointers have high operator precedence, but lower precedence than the dot "
"operator used for field and method access. This precedence order can "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1217
+#: doc/tutorial.md:1218
msgid ""
"~~~ # struct Point { x: float, y: float } # enum Shape { Rectangle(Point, "
"Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1221
+#: doc/tutorial.md:1222
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), "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1231
+#: doc/tutorial.md:1232
msgid ""
"~~~ # struct Point { x: float, y: float } # enum Shape { Rectangle(Point, "
"Point) } # impl Shape { fn area(&self) -> int { 0 } } let start = @Point "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1235
+#: doc/tutorial.md:1236
msgid ""
"You can write an expression that dereferences any number of pointers "
"automatically. For example, if you feel inclined, you could write something "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1241
+#: doc/tutorial.md:1242
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:1243
+#: doc/tutorial.md:1244
msgid "The indexing operator (`[]`) also auto-dereferences."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1245
+#: doc/tutorial.md:1246
msgid "# Vectors and strings"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1250
+#: doc/tutorial.md:1251
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, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1260
+#: doc/tutorial.md:1261
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1263
+#: doc/tutorial.md:1264
msgid ""
"// A borrowed pointer to stack-allocated vector let stack_crayons: &[Crayon] "
"= &[Aquamarine, Asparagus, AtomicTangerine];"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1266
+#: doc/tutorial.md:1267
msgid ""
"// A local heap (managed) vector of crayons let local_crayons: @[Crayon] = "
"@[BananaMania, Beaver, Bittersweet];"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1270
+#: doc/tutorial.md:1271
msgid ""
"// An exchange heap (owned) vector of crayons let exchange_crayons: "
"~[Crayon] = ~[Black, BlizzardBlue, Blue]; ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1272
+#: doc/tutorial.md:1273
msgid "The `+` operator means concatenation when applied to vector types."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1277
+#: doc/tutorial.md:1278
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1280
+#: doc/tutorial.md:1281
msgid ""
"let my_crayons = ~[Almond, AntiqueBrass, Apricot]; let your_crayons = "
"~[BananaMania, Beaver, Bittersweet];"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1283
+#: doc/tutorial.md:1284
msgid ""
"// Add two vectors to create a new one let our_crayons = my_crayons + "
"your_crayons;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1288
+#: doc/tutorial.md:1289
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:1293
+#: doc/tutorial.md:1294
msgid ""
"> ***Note:*** The above examples of vector addition use owned > vectors. "
"Some operations on slices and stack vectors are > not yet well-supported. "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1295
+#: doc/tutorial.md:1296
msgid "Square brackets denote indexing into a vector:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1307
+#: doc/tutorial.md:1308
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1309
+#: doc/tutorial.md:1310
msgid "A vector can be destructured using pattern matching:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1319
+#: doc/tutorial.md:1320
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1323
+#: doc/tutorial.md:1324
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1329
+#: doc/tutorial.md:1330
#, no-wrap
msgid ""
"~~~ {.xfail-test}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1332
+#: doc/tutorial.md:1333
msgid "crayons[0] = Apricot; // ERROR: Can't assign to immutable vector ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1334
+#: doc/tutorial.md:1335
msgid "Moving it into a mutable slot makes the elements assignable."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1340
+#: doc/tutorial.md:1341
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1343
+#: doc/tutorial.md:1344
msgid ""
"// Put the vector into a mutable slot let mut mutable_crayons = crayons;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1347
+#: doc/tutorial.md:1348
msgid "// Now it's mutable to the bone mutable_crayons[0] = Apricot; ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1350
+#: doc/tutorial.md:1351
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:1358
+#: doc/tutorial.md:1359
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1362
+#: doc/tutorial.md:1363
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:1365
+#: doc/tutorial.md:1366
msgid ""
"// The same thing, but with the `&` let stack_crayons: &str = &\"Aquamarine, "
"Asparagus, AtomicTangerine\";"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1368
+#: doc/tutorial.md:1369
msgid ""
"// A local heap (managed) string let local_crayons: @str = @\"BananaMania, "
"Beaver, Bittersweet\";"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1372
+#: doc/tutorial.md:1373
msgid ""
"// An exchange heap (owned) string let exchange_crayons: ~str = ~\"Black, "
"BlizzardBlue, Blue\"; ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1376
+#: doc/tutorial.md:1377
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."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1379
+#: doc/tutorial.md:1380
msgid "[`std::vec`]: std/vec.html [`std::str`]: std/str.html"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1390
+#: doc/tutorial.md:1391
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1392
+#: doc/tutorial.md:1393
msgid "let crayons = [Almond, AntiqueBrass, Apricot];"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1396
+#: doc/tutorial.md:1397
msgid ""
"// Check the length of the vector assert!(crayons.len() == 3); assert!(!"
"crayons.is_empty());"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1403
+#: doc/tutorial.md:1404
#, no-wrap
msgid ""
"// Iterate over a vector, obtaining a pointer to each element\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1407
+#: doc/tutorial.md:1408
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:1410
+#: doc/tutorial.md:1411
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:1416
+#: doc/tutorial.md:1417
#, no-wrap
msgid ""
"if favorite_crayon_name.len() > 5 {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1418
+#: doc/tutorial.md:1419
msgid "# Closures"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1423
+#: doc/tutorial.md:1424
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1426
+#: doc/tutorial.md:1427
msgid "~~~~ {.ignore} let foo = 10;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1431
+#: doc/tutorial.md:1432
#, no-wrap
msgid ""
"fn bar() -> int {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1434
+#: doc/tutorial.md:1435
msgid ""
"Rust also supports _closures_, functions that can access variables in the "
"enclosing scope."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1437
+#: doc/tutorial.md:1438
msgid "~~~~ fn call_closure_with_ten(b: &fn(int)) { b(10); }"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1440
+#: doc/tutorial.md:1441
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:1443
+#: doc/tutorial.md:1444
msgid "call_closure_with_ten(closure); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1449
+#: doc/tutorial.md:1450
msgid ""
"Closures begin with the argument list between vertical bars and are followed "
"by a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1454
+#: doc/tutorial.md:1455
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1458
+#: doc/tutorial.md:1459
msgid "~~~~ let square = |x: int| -> uint { x * x as uint }; ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1462
+#: doc/tutorial.md:1463
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1467
+#: doc/tutorial.md:1468
msgid "~~~~ let mut max = 0; [1, 2, 3].map(|x| if *x > max { max = *x }); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1476
+#: doc/tutorial.md:1477
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1478
+#: doc/tutorial.md:1479
msgid "## Managed closures"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1484
+#: doc/tutorial.md:1485
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1489
+#: doc/tutorial.md:1490
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. "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1492
+#: doc/tutorial.md:1493
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:1498
+#: doc/tutorial.md:1499
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1504
+#: doc/tutorial.md:1505
#, no-wrap
msgid ""
"fn main() {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1506
+#: doc/tutorial.md:1507
msgid "## Owned closures"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1513
+#: doc/tutorial.md:1514
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1515
+#: doc/tutorial.md:1516
msgid "[tasks]: tutorial-tasks.html"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1517
+#: doc/tutorial.md:1518
msgid "## Closure compatibility"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1524
+#: doc/tutorial.md:1525
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1532
+#: doc/tutorial.md:1533
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1536
+#: doc/tutorial.md:1537
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1538
+#: doc/tutorial.md:1539
msgid "## Do syntax"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1541
+#: doc/tutorial.md:1542
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:1544
+#: doc/tutorial.md:1545
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:1554
+#: doc/tutorial.md:1555
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1558
+#: doc/tutorial.md:1559
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:1566
+#: doc/tutorial.md:1567
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1569
+#: doc/tutorial.md:1570
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:1577
+#: doc/tutorial.md:1578
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1582
+#: doc/tutorial.md:1583
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, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1587
+#: doc/tutorial.md:1588
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1590
+#: doc/tutorial.md:1591
msgid "~~~~ use std::task::spawn;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1595
+#: doc/tutorial.md:1596
#, no-wrap
msgid ""
"do spawn() || {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1599
+#: doc/tutorial.md:1600
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1606
+#: doc/tutorial.md:1607
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1609
+#: doc/tutorial.md:1610
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1611
+#: doc/tutorial.md:1612
msgid "# Methods"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1617
+#: doc/tutorial.md:1618
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1621
+#: doc/tutorial.md:1622
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1629
+#: doc/tutorial.md:1630
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1634
+#: doc/tutorial.md:1635
#, no-wrap
msgid ""
"enum Shape {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1643
+#: doc/tutorial.md:1644
#, no-wrap
msgid ""
"impl Shape {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1647
+#: doc/tutorial.md:1648
msgid "let s = Circle(Point { x: 1f, y: 2f }, 3f); s.draw(); ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1651
+#: doc/tutorial.md:1652
msgid ""
"This defines an _implementation_ for `Shape` containing a single method, "
"`draw`. In most respects the `draw` method is defined like any other "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1656
+#: doc/tutorial.md:1657
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`, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1671
+#: doc/tutorial.md:1672
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1673
+#: doc/tutorial.md:1674
msgid "let s = Circle(Point { x: 1f, y: 2f }, 3f);"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1679
+#: doc/tutorial.md:1680
msgid ""
"(@s).draw_managed(); (~s).draw_owned(); (&s).draw_borrowed(); s."
"draw_value(); ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1683
+#: doc/tutorial.md:1684
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:1701
+#: doc/tutorial.md:1702
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1704
+#: doc/tutorial.md:1705
msgid "(@s).draw_borrowed(); (~s).draw_borrowed();"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1708
+#: doc/tutorial.md:1709
msgid ""
"// Unlike typical function arguments, the self value will // automatically "
"be referenced ... s.draw_borrowed();"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1711
+#: doc/tutorial.md:1712
msgid "// ... and dereferenced (& &s).draw_borrowed();"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1715
+#: doc/tutorial.md:1716
msgid "// ... and dereferenced and borrowed (&@~s).draw_borrowed(); ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1719
+#: doc/tutorial.md:1720
msgid ""
"Implementations may also define standalone (sometimes called \"static\") "
"methods. The absence of a `self` parameter distinguishes such methods. "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1726
+#: doc/tutorial.md:1727
#, no-wrap
msgid ""
"~~~~ {.xfail-test}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:1728
+#: doc/tutorial.md:1729
msgid ""
"To call such a method, just prefix it with the type name and a double colon:"
msgstr ""
msgid ""
"~~~~\n"
"# use std::float::consts::pi;\n"
-"# use std::float::sqrt;\n"
"struct Circle { radius: float }\n"
"impl Circle {\n"
-" fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }\n"
+" fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }\n"
"}\n"
"let c = Circle::new(42.5);\n"
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2004
+#: doc/tutorial.md:2003
msgid ""
-"~~~~ # use std::float::consts::pi; # use std::float::sqrt; trait Shape { fn "
-"new(area: float) -> Self; } struct Circle { radius: float } struct Square "
-"{ length: 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:2011
+#: doc/tutorial.md:2010
#, no-wrap
msgid ""
"impl Shape for Circle {\n"
-" fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }\n"
+" fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }\n"
"}\n"
"impl Shape for Square {\n"
-" fn new(area: float) -> Square { Square { length: sqrt(area) } }\n"
+" fn new(area: float) -> Square { Square { length: (area).sqrt() } }\n"
"}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2016
+#: doc/tutorial.md:2015
msgid ""
"let area = 42.5; let c: Circle = Shape::new(area); let s: Square = Shape::"
"new(area); ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2018
+#: doc/tutorial.md:2017
msgid "## Bounded type parameters and static method dispatch"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2023
+#: doc/tutorial.md:2022
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_ "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2032
+#: doc/tutorial.md:2031
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2038
+#: doc/tutorial.md:2037
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2041
+#: doc/tutorial.md:2040
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:2053
+#: doc/tutorial.md:2052
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2057
+#: doc/tutorial.md:2056
msgid ""
"Method calls to bounded type parameters are _statically dispatched_, "
"imposing no more overhead than normal function invocation, so are the "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2059
+#: doc/tutorial.md:2058
msgid "This usage of traits is similar to Haskell type classes."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2061
+#: doc/tutorial.md:2060
msgid "## Trait objects and dynamic method dispatch"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2065
+#: doc/tutorial.md:2064
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2071
+#: doc/tutorial.md:2070
msgid ""
"~~~~ # type Circle = int; type Rectangle = int; # impl Drawable for int { fn "
"draw(&self) {} } # fn new_circle() -> int { 1 } trait Drawable { fn "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2078
+#: doc/tutorial.md:2077
#, no-wrap
msgid ""
"fn draw_all<T: Drawable>(shapes: ~[T]) {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2084
+#: doc/tutorial.md:2083
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2091
+#: doc/tutorial.md:2090
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2096
+#: doc/tutorial.md:2095
msgid ""
"In this example, there is no type parameter. Instead, the `@Drawable` type "
"denotes any managed box value that implements the `Drawable` trait. To "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2103
+#: doc/tutorial.md:2102
msgid ""
"~~~~ # type Circle = int; type Rectangle = bool; # trait Drawable { fn "
"draw(&self); } # fn new_circle() -> Circle { 1 } # fn new_rectangle() -> "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2106
+#: doc/tutorial.md:2105
msgid ""
"impl Drawable for Circle { fn draw(&self) { ... } } impl Drawable for "
"Rectangle { fn draw(&self) { ... } }"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2111
+#: doc/tutorial.md:2110
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:2119
+#: doc/tutorial.md:2118
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2133
+#: doc/tutorial.md:2132
msgid ""
"~~~ # type Circle = int; type Rectangle = int; # trait Drawable { fn "
"draw(&self); } # impl Drawable for int { fn draw(&self) {} } # fn "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2138
+#: doc/tutorial.md:2137
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2140
+#: doc/tutorial.md:2139
msgid "This usage of traits is similar to Java interfaces."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2142
+#: doc/tutorial.md:2141
msgid "## Trait inheritance"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2147
+#: doc/tutorial.md:2146
msgid ""
"We can write a trait declaration that _inherits_ from other traits, called "
"_supertraits_. Types that implement a trait must also implement its "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2152
+#: doc/tutorial.md:2151
msgid ""
"~~~~ trait Shape { fn area(&self) -> float; } trait Circle : Shape { fn "
"radius(&self) -> float; } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2154
+#: doc/tutorial.md:2153
msgid ""
"Now, we can implement `Circle` on a type only if we also implement `Shape`."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2170
+#: doc/tutorial.md:2168
#, no-wrap
msgid ""
"~~~~\n"
"# use std::float::consts::pi;\n"
-"# use std::float::sqrt;\n"
"# trait Shape { fn area(&self) -> float; }\n"
"# trait Circle : Shape { fn radius(&self) -> float; }\n"
"# struct Point { x: float, y: float }\n"
"# fn square(x: float) -> float { x * x }\n"
"struct CircleStruct { center: Point, radius: float }\n"
"impl Circle for CircleStruct {\n"
-" fn radius(&self) -> float { sqrt(self.area() / pi) }\n"
+" fn radius(&self) -> float { (self.area() / pi).sqrt() }\n"
"}\n"
"impl Shape for CircleStruct {\n"
" fn area(&self) -> float { pi * square(self.radius) }\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2175
+#: doc/tutorial.md:2173
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2200
+#: doc/tutorial.md:2197
msgid ""
-"~~~ {.xfail-test} # use std::float::consts::pi; # use std::float::sqrt; # "
-"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 { sqrt(self.area() / pi) } } # impl Shape for "
+"~~~ {.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:2205
+#: doc/tutorial.md:2202
msgid ""
"let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f}; let "
"mycircle: Circle = concrete as @Circle; let nonsense = mycircle.radius() * "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2207
+#: doc/tutorial.md:2204
msgid "> ***Note:*** Trait inheritance does not actually work with objects yet"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2209
+#: doc/tutorial.md:2206
msgid "## Deriving implementations for traits"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2216
+#: doc/tutorial.md:2213
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2220
+#: doc/tutorial.md:2217
msgid "~~~ #[deriving(Eq)] struct Circle { radius: float }"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2224
+#: doc/tutorial.md:2221
msgid "#[deriving(Rand, ToStr)] enum ABC { A, B, C } ~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2228
+#: doc/tutorial.md:2225
msgid ""
"The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `IterBytes`, `Rand`, `Zero`, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2230
+#: doc/tutorial.md:2227
msgid "# Modules and crates"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2234
+#: doc/tutorial.md:2231
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:2240
+#: doc/tutorial.md:2237
#, no-wrap
msgid ""
"~~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2245
+#: doc/tutorial.md:2242
#, no-wrap
msgid ""
"fn main() {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2250
+#: doc/tutorial.md:2247
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2256
+#: doc/tutorial.md:2253
msgid ""
"~~~ # mod farm { pub fn chicken() { } } # fn main() { // Bring `chicken` "
"into scope use farm::chicken;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2266
+#: doc/tutorial.md:2263
#, no-wrap
msgid ""
"fn chicken_farmer() {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2273
+#: doc/tutorial.md:2270
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2280
+#: doc/tutorial.md:2277
msgid ""
"Visibility restrictions in Rust exist only at module boundaries. This is "
"quite different from most object-oriented languages that also enforce "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2293
+#: doc/tutorial.md:2290
#, no-wrap
msgid ""
"~~~\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2299
+#: doc/tutorial.md:2296
#, no-wrap
msgid ""
" impl Farm {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2305
+#: doc/tutorial.md:2302
#, no-wrap
msgid ""
" pub fn feed_animals(farm: &Farm) {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2315
+#: doc/tutorial.md:2312
#, no-wrap
msgid ""
"fn main() {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2317
+#: doc/tutorial.md:2314
msgid "## Crates"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2321
+#: doc/tutorial.md:2318
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2326
+#: doc/tutorial.md:2323
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2331
+#: doc/tutorial.md:2328
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2340
+#: doc/tutorial.md:2337
msgid ""
"A typical crate file declares attributes associated with the crate that may "
"affect how the compiler processes the source. Crate attributes specify "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2344
+#: doc/tutorial.md:2341
msgid ""
"~~~~ { .xfail-test } // Crate linkage metadata #[link(name = \"farm\", vers "
"= \"2.5\", author = \"mjh\")];"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2347
+#: doc/tutorial.md:2344
msgid "// Make a library (\"bin\" is the default) #[crate_type = \"lib\"];"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2350
+#: doc/tutorial.md:2347
msgid "// Turn on a warning #[warn(non_camel_case_types)]"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2353
+#: doc/tutorial.md:2350
msgid "// Link to the standard library extern mod std;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2358
+#: doc/tutorial.md:2355
msgid "// Load some modules from other files mod cow; mod chicken; mod horse;"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2363
+#: doc/tutorial.md:2360
#, no-wrap
msgid ""
"fn main() {\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2370
+#: doc/tutorial.md:2367
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, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2374
+#: doc/tutorial.md:2371
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:2377
+#: doc/tutorial.md:2374
msgid ""
"To have a nested directory structure for your source files, you can nest "
"mods:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2384
+#: doc/tutorial.md:2381
#, no-wrap
msgid ""
"~~~~ {.ignore}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2389
+#: doc/tutorial.md:2386
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2391
+#: doc/tutorial.md:2388
msgid "## Using other crates"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2399
+#: doc/tutorial.md:2396
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2401
+#: doc/tutorial.md:2398
msgid "For example, `extern mod std` links the [standard library]."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2403
+#: doc/tutorial.md:2400
msgid "[standard library]: std/index.html"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2410
+#: doc/tutorial.md:2407
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2412
+#: doc/tutorial.md:2409
msgid "Our example crate declared this set of `link` attributes:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2416
+#: doc/tutorial.md:2413
msgid "~~~~ #[link(name = \"farm\", vers = \"2.5\", author = \"mjh\")]; ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2418
+#: doc/tutorial.md:2415
msgid "Which you can then link with any (or all) of the following:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2424
+#: doc/tutorial.md:2421
msgid ""
"~~~~ {.xfail-test} extern mod farm; extern mod my_farm (name = \"farm\", "
"vers = \"2.5\"); extern mod my_auxiliary_farm (name = \"farm\", author = "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2427
+#: doc/tutorial.md:2424
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:2429
+#: doc/tutorial.md:2426
msgid "## A minimal example"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2432
+#: doc/tutorial.md:2429
msgid ""
"Now for something that you can actually compile yourself, we have these two "
"files:"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2438
+#: doc/tutorial.md:2435
msgid ""
"~~~~ // world.rs #[link(name = \"world\", vers = \"1.0\")]; pub fn explore() "
"-> &str { \"world\" } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2444
+#: doc/tutorial.md:2441
msgid ""
"~~~~ {.xfail-test} // main.rs extern mod world; fn main() { println(~\"hello "
"\" + world::explore()); } ~~~~"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2446
+#: doc/tutorial.md:2443
msgid "Now compile and run like this (adjust to your platform if necessary):"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2453
+#: doc/tutorial.md:2450
#, no-wrap
msgid ""
"~~~~ {.notrust}\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2458
+#: doc/tutorial.md:2455
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2460
+#: doc/tutorial.md:2457
msgid "## The standard library"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2465
+#: doc/tutorial.md:2462
msgid ""
"The Rust standard library provides runtime features required by the "
"language, including the task scheduler and memory allocators, as well as "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2476
+#: doc/tutorial.md:2473
msgid ""
"[`std`] includes modules corresponding to each of the integer types, each of "
"the floating point types, the [`bool`] type, [tuples], [characters], "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2478
+#: doc/tutorial.md:2475
msgid "### Standard Library injection and the Rust prelude"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2481
+#: doc/tutorial.md:2478
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:2483
+#: doc/tutorial.md:2480
#, no-wrap
msgid " extern mod std;\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2487
+#: doc/tutorial.md:2484
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`, "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2492
+#: doc/tutorial.md:2489
msgid ""
"Additionally, `std` contains a `prelude` module that reexports many of the "
"most common standard modules, types and traits. The contents of the prelude "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2494
+#: doc/tutorial.md:2491
#, no-wrap
msgid " use std::prelude::*;\n"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2520
+#: doc/tutorial.md:2517
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 "
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2522
+#: doc/tutorial.md:2519
msgid "# What next?"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2525
+#: doc/tutorial.md:2522
msgid ""
"Now that you know the essentials, check out any of the additional tutorials "
"on individual topics."
msgstr ""
#. type: Bullet: '* '
-#: doc/tutorial.md:2531
+#: doc/tutorial.md:2528
msgid "[Borrowed pointers][borrow]"
msgstr ""
#. type: Bullet: '* '
-#: doc/tutorial.md:2531
+#: doc/tutorial.md:2528
msgid "[Tasks and communication][tasks]"
msgstr ""
#. type: Bullet: '* '
-#: doc/tutorial.md:2531
+#: doc/tutorial.md:2528
msgid "[Macros][macros]"
msgstr ""
#. type: Bullet: '* '
-#: doc/tutorial.md:2531
+#: doc/tutorial.md:2528
msgid "[The foreign function interface][ffi]"
msgstr ""
#. type: Bullet: '* '
-#: doc/tutorial.md:2531
+#: doc/tutorial.md:2528
msgid "[Containers and iterators](tutorial-container.html)"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2533
+#: doc/tutorial.md:2530
msgid "There is further documentation on the [wiki]."
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2538
+#: doc/tutorial.md:2535
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:2544
+#: 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/"
msgstr ""
#. type: Plain text
-#: doc/tutorial.md:2545
+#: doc/tutorial.md:2542
msgid ""
"[pound-rust]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust"
msgstr ""