doc: add webfonts and tweak the styles accordingly
This commit is contained in:
parent
950312960a
commit
fb9ea2eaca
@ -1,6 +1,11 @@
|
|||||||
<style>
|
<style>
|
||||||
/* Display the full TOC */
|
/* Display the full TOC */
|
||||||
#TOC ul ul {
|
nav {
|
||||||
|
column-count: auto;
|
||||||
|
-moz-column-count: auto;
|
||||||
|
-webkit-column-count: auto;
|
||||||
|
}
|
||||||
|
nav ul ul {
|
||||||
display: block;
|
display: block;
|
||||||
padding-left: 2em;
|
padding-left: 2em;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ it. It would violate memory safety for the box that was originally
|
|||||||
assigned to `x` to be garbage-collected, since a non-heap
|
assigned to `x` to be garbage-collected, since a non-heap
|
||||||
pointer *`y`* still points into it.
|
pointer *`y`* still points into it.
|
||||||
|
|
||||||
> ***Note:*** Our current implementation implements the garbage collector
|
> *Note:* Our current implementation implements the garbage collector
|
||||||
> using reference counting and cycle detection.
|
> using reference counting and cycle detection.
|
||||||
|
|
||||||
For this reason, whenever an `&` expression borrows the interior of a
|
For this reason, whenever an `&` expression borrows the interior of a
|
||||||
@ -674,7 +674,7 @@ Named lifetime notation can also be used to control the flow of execution:
|
|||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
> ***Note:*** Labelled breaks are not currently supported within `while` loops.
|
> *Note:* Labelled breaks are not currently supported within `while` loops.
|
||||||
|
|
||||||
Named labels are hygienic and can be used safely within macros.
|
Named labels are hygienic and can be used safely within macros.
|
||||||
See the macros guide section on hygiene for more details.
|
See the macros guide section on hygiene for more details.
|
||||||
|
@ -462,7 +462,7 @@ an `Error` result.
|
|||||||
|
|
||||||
[`Result`]: std/result/index.html
|
[`Result`]: std/result/index.html
|
||||||
|
|
||||||
> ***Note:*** A failed task does not currently produce a useful error
|
> *Note:* A failed task does not currently produce a useful error
|
||||||
> value (`try` always returns `Err(())`). In the
|
> value (`try` always returns `Err(())`). In the
|
||||||
> future, it may be possible for tasks to intercept the value passed to
|
> future, it may be possible for tasks to intercept the value passed to
|
||||||
> `fail!()`.
|
> `fail!()`.
|
||||||
|
@ -196,11 +196,11 @@ msgstr ""
|
|||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
#: src/doc/tutorial.md:57
|
#: src/doc/tutorial.md:57
|
||||||
msgid ""
|
msgid ""
|
||||||
"> ***Warning:*** Rust is a language under ongoing development. Notes > about "
|
"> *Warning:* Rust is a language under ongoing development. Notes > about "
|
||||||
"potential changes to the language, implementation > deficiencies, and other "
|
"potential changes to the language, implementation > deficiencies, and other "
|
||||||
"caveats appear offset in blockquotes."
|
"caveats appear offset in blockquotes."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"> ***警告:*** Rust は開発途上の言語です。将来予定されている言語への変更や、実"
|
"> *警告:* Rust は開発途上の言語です。将来予定されている言語への変更や、実"
|
||||||
"装上の不備、その他の注意事項など、 blockquote の段落 (この段落もそうです) に"
|
"装上の不備、その他の注意事項など、 blockquote の段落 (この段落もそうです) に"
|
||||||
"注意してください。"
|
"注意してください。"
|
||||||
|
|
||||||
@ -287,13 +287,13 @@ msgstr ""
|
|||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
#: src/doc/tutorial.md:88
|
#: src/doc/tutorial.md:88
|
||||||
msgid ""
|
msgid ""
|
||||||
"> ***Note:*** Windows users should read the detailed > \"[getting started]"
|
"> *Note:* Windows users should read the detailed > \"[getting started]"
|
||||||
"[wiki-start]\" notes on the wiki. Even when using > the binary installer, "
|
"[wiki-start]\" notes on the wiki. Even when using > the binary installer, "
|
||||||
"the Windows build requires a MinGW installation, > the precise details of "
|
"the Windows build requires a MinGW installation, > the precise details of "
|
||||||
"which are not discussed here. Finally, `rustc` may > need to be [referred to "
|
"which are not discussed here. Finally, `rustc` may > need to be [referred to "
|
||||||
"as `rustc.exe`][bug-3319]. It's a bummer, we > know."
|
"as `rustc.exe`][bug-3319]. It's a bummer, we > know."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"> ***注意:*** Windows ユーザーは wiki の [getting started][wiki-start] の記事"
|
"> *注意:* Windows ユーザーは wiki の [getting started][wiki-start] の記事"
|
||||||
"を読んでください。 本書では詳細を説明しませんが、インストーラを利用する場合で"
|
"を読んでください。 本書では詳細を説明しませんが、インストーラを利用する場合で"
|
||||||
"も、MinGW のインストールなど、追加の手順が必要です。また、コンパイラは "
|
"も、MinGW のインストールなど、追加の手順が必要です。また、コンパイラは "
|
||||||
"`rustc` ではなく、 [`rustc.exe` として呼び出す必要がある][bug-3319] かもしれ"
|
"`rustc` ではなく、 [`rustc.exe` として呼び出す必要がある][bug-3319] かもしれ"
|
||||||
@ -1254,11 +1254,11 @@ msgstr ""
|
|||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
#: src/doc/tutorial.md:504
|
#: src/doc/tutorial.md:504
|
||||||
msgid ""
|
msgid ""
|
||||||
"> ***Note:*** The following code makes use of tuples (`(f64, f64)`) which > "
|
"> *Note:* The following code makes use of tuples (`(f64, f64)`) which > "
|
||||||
"are explained in section 5.3. For now you can think of tuples as a list of > "
|
"are explained in section 5.3. For now you can think of tuples as a list of > "
|
||||||
"items."
|
"items."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"> ***注意:*** 以下のコード例では5.3 節で説明されるタプル (`(f64, f64)`) を"
|
"> *注意:* 以下のコード例では5.3 節で説明されるタプル (`(f64, f64)`) を"
|
||||||
"使っています。現時点では、タプルは項目のリストのようなものだとみなしてくださ"
|
"使っています。現時点では、タプルは項目のリストのようなものだとみなしてくださ"
|
||||||
"い。"
|
"い。"
|
||||||
|
|
||||||
@ -3005,11 +3005,11 @@ msgstr ""
|
|||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
#: src/doc/tutorial.md:1774
|
#: src/doc/tutorial.md:1774
|
||||||
msgid ""
|
msgid ""
|
||||||
"> ***Note:*** Both the syntax and the semantics will be changing > in small "
|
"> *Note:* Both the syntax and the semantics will be changing > in small "
|
||||||
"ways. At the moment they can be unsound in some > scenarios, particularly "
|
"ways. At the moment they can be unsound in some > scenarios, particularly "
|
||||||
"with non-copyable types."
|
"with non-copyable types."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"> ***注意*** コードの文法と意味は将来的に変更されるかもしれません。現時点では"
|
"> *注意* コードの文法と意味は将来的に変更されるかもしれません。現時点では"
|
||||||
"いくつかの状況、特にコピーできない型が関連するケースにおいて望ましくない振る"
|
"いくつかの状況、特にコピーできない型が関連するケースにおいて望ましくない振る"
|
||||||
"舞いが起こされる場合があります。"
|
"舞いが起こされる場合があります。"
|
||||||
|
|
||||||
@ -3660,10 +3660,10 @@ msgstr ""
|
|||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
#: src/doc/tutorial.md:2099
|
#: src/doc/tutorial.md:2099
|
||||||
msgid ""
|
msgid ""
|
||||||
"> ***Note:*** These two traits were referred to as 'kinds' in earlier > "
|
"> *Note:* These two traits were referred to as 'kinds' in earlier > "
|
||||||
"iterations of the language, and often still are."
|
"iterations of the language, and often still are."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"> ***注意*** これら2つのトレイトは、以前は 「種」 (kind) と呼ばれており、現在"
|
"> *注意* これら2つのトレイトは、以前は 「種」 (kind) と呼ばれており、現在"
|
||||||
"でもそう呼ばれる場合があります。"
|
"でもそう呼ばれる場合があります。"
|
||||||
|
|
||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
@ -4374,9 +4374,9 @@ msgstr ""
|
|||||||
|
|
||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
#: src/doc/tutorial.md:2511
|
#: src/doc/tutorial.md:2511
|
||||||
msgid "> ***Note:*** Trait inheritance does not actually work with objects yet"
|
msgid "> *Note:* Trait inheritance does not actually work with objects yet"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"> ***注意*** トレイトの継承は、実際にはまだオブジェクトに対しては動作しませ"
|
"> *注意* トレイトの継承は、実際にはまだオブジェクトに対しては動作しませ"
|
||||||
"ん。"
|
"ん。"
|
||||||
|
|
||||||
#. type: Plain text
|
#. type: Plain text
|
||||||
|
101
src/doc/rust.css
101
src/doc/rust.css
@ -10,13 +10,43 @@
|
|||||||
* option. This file may not be copied, modified, or distributed
|
* option. This file may not be copied, modified, or distributed
|
||||||
* except according to those terms.
|
* except according to those terms.
|
||||||
*/
|
*/
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Fira Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: local('Fira Sans'), url("http://rust-lang.org/fonts/FiraSans-Regular.woff") format('woff');
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Fira Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 500;
|
||||||
|
src: local('Fira Sans Medium'), url("http://rust-lang.org/fonts/FiraSans-Medium.woff") format('woff');
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Heuristica';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: local('Heuristica Regular'), url("http://rust-lang.org/fonts/Heuristica-Regular.woff") format('woff');
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Heuristica';
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: 400;
|
||||||
|
src: local('Heuristica Italic'), url("http://rust-lang.org/fonts/Heuristica-Italic.woff") format('woff');
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Heuristica';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
src: local('Heuristica Bold'), url("http://rust-lang.org/fonts/Heuristica-Bold.woff") format('woff');
|
||||||
|
}
|
||||||
/* Global page semantics
|
/* Global page semantics
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
body {
|
body {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: Heuristica, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
font-size: 14px;
|
font-size: 18px;
|
||||||
color: #333;
|
color: #333;
|
||||||
line-height: 1.428571429;
|
line-height: 1.428571429;
|
||||||
}
|
}
|
||||||
@ -26,24 +56,36 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6, nav, #versioninfo {
|
||||||
|
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
h1, h2, h3, h4, h5, h6 {
|
h1, h2, h3, h4, h5, h6 {
|
||||||
color: black;
|
color: black;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 1.1;
|
line-height: 1.1;
|
||||||
}
|
}
|
||||||
h1, h2, h3 {
|
h1, h2, h3 {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
@media (min-width: 1170px) {
|
||||||
|
h1, h2, h3 {
|
||||||
|
margin-top: 30px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
h4, h5, h6 {
|
h4, h5, h6 {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding: .2em .8em;
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
h5, h6 {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 36px;
|
font-size: 28px;
|
||||||
|
font-weight: 500;
|
||||||
padding: .1em .4em;
|
padding: .1em .4em;
|
||||||
margin: 0.67em 0;
|
margin: 0.67em 0;
|
||||||
border-bottom: 2px solid #ddd;
|
border-bottom: 2px solid #ddd;
|
||||||
@ -52,7 +94,7 @@ h1.title {
|
|||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 30px;
|
font-size: 26px;
|
||||||
padding: .2em .5em;
|
padding: .2em .5em;
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
@ -62,17 +104,34 @@ h3 {
|
|||||||
border-bottom: 1px solid #DDE8FC;
|
border-bottom: 1px solid #DDE8FC;
|
||||||
}
|
}
|
||||||
h4 {
|
h4 {
|
||||||
font-size: 18px;
|
font-size: 22px;
|
||||||
}
|
}
|
||||||
h5 {
|
h5 {
|
||||||
font-size: 16px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
h6 {
|
h6 {
|
||||||
font-size: 14px;
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
@media (min-width: 992px) {
|
||||||
|
h1 {
|
||||||
|
font-size: 36px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
column-count: 2;
|
||||||
|
-moz-column-count: 2;
|
||||||
|
-webkit-column-count: 2;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
p {
|
p {
|
||||||
margin: 0 0 10px;
|
margin: 0 0 1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
strong {
|
strong {
|
||||||
@ -85,10 +144,10 @@ em {
|
|||||||
|
|
||||||
footer {
|
footer {
|
||||||
border-top: 1px solid #ddd;
|
border-top: 1px solid #ddd;
|
||||||
font-size: 12px;
|
font-size: 14.3px;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
padding-top: 4px;
|
padding-top: 5px;
|
||||||
margin-top: 4em;
|
margin-top: 3em;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,16 +189,14 @@ pre {
|
|||||||
border-radius: 0.5em;
|
border-radius: 0.5em;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
padding: 9.5px;
|
padding: 9.5px;
|
||||||
margin: 10px 0;
|
margin: 20px 0;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
code {
|
code {
|
||||||
padding: 2px 4px;
|
padding: 0 2px;
|
||||||
font-size: 90%;
|
color: #8D1A38;
|
||||||
color: #C7254E;
|
|
||||||
background-color: #F9F2F4;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
pre code {
|
pre code {
|
||||||
@ -170,7 +227,7 @@ pre.rust .lifetime { color: #B76514; }
|
|||||||
margin: 0.5em;
|
margin: 0.5em;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
}
|
}
|
||||||
@media only screen, handheld and (min-width: 768px) {
|
@media handheld, only screen and (min-width: 768px) {
|
||||||
#versioninfo {
|
#versioninfo {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
@ -185,7 +242,7 @@ pre.rust .lifetime { color: #B76514; }
|
|||||||
}
|
}
|
||||||
#versioninfo a.hash {
|
#versioninfo a.hash {
|
||||||
color: gray;
|
color: gray;
|
||||||
font-size: 70%;
|
font-size: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
@ -221,13 +278,13 @@ dd {
|
|||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#TOC ul {
|
nav ul {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding-left: 0px;
|
padding-left: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only display one level of hierarchy in the TOC */
|
/* Only display one level of hierarchy in the TOC */
|
||||||
#TOC ul ul {
|
nav ul ul {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +96,9 @@ The section [Special Unicode Productions](#special-unicode-productions) lists th
|
|||||||
|
|
||||||
## String table productions
|
## String table productions
|
||||||
|
|
||||||
Some rules in the grammar -- notably [unary
|
Some rules in the grammar — notably [unary
|
||||||
operators](#unary-operator-expressions), [binary
|
operators](#unary-operator-expressions), [binary
|
||||||
operators](#binary-operator-expressions), and [keywords](#keywords) --
|
operators](#binary-operator-expressions), and [keywords](#keywords) —
|
||||||
are given in a simplified form: as a listing of a table of unquoted,
|
are given in a simplified form: as a listing of a table of unquoted,
|
||||||
printable whitespace-separated strings. These cases form a subset of
|
printable whitespace-separated strings. These cases form a subset of
|
||||||
the rules regarding the [token](#tokens) rule, and are assumed to be
|
the rules regarding the [token](#tokens) rule, and are assumed to be
|
||||||
@ -645,7 +645,7 @@ The processing of that source file may result in other source files being loaded
|
|||||||
Source files have the extension `.rs`.
|
Source files have the extension `.rs`.
|
||||||
|
|
||||||
A Rust source file describes a module, the name and
|
A Rust source file describes a module, the name and
|
||||||
location of which -- in the module tree of the current crate -- are defined
|
location of which — in the module tree of the current crate — are defined
|
||||||
from outside the source file: either by an explicit `mod_item` in
|
from outside the source file: either by an explicit `mod_item` in
|
||||||
a referencing source file, or by the name of the crate itself.
|
a referencing source file, or by the name of the crate itself.
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ Some items form an implicit scope for the declaration of sub-items. In other
|
|||||||
words, within a function or module, declarations of items can (in many cases)
|
words, within a function or module, declarations of items can (in many cases)
|
||||||
be mixed with the statements, control blocks, and similar artifacts that
|
be mixed with the statements, control blocks, and similar artifacts that
|
||||||
otherwise compose the item body. The meaning of these scoped items is the same
|
otherwise compose the item body. The meaning of these scoped items is the same
|
||||||
as if the item was declared outside the scope -- it is still a static item --
|
as if the item was declared outside the scope — it is still a static item —
|
||||||
except that the item's *path name* within the module namespace is qualified by
|
except that the item's *path name* within the module namespace is qualified by
|
||||||
the name of the enclosing item, or is private to the enclosing item (in the
|
the name of the enclosing item, or is private to the enclosing item (in the
|
||||||
case of functions).
|
case of functions).
|
||||||
@ -1332,7 +1332,6 @@ Traits are implemented for specific types through separate [implementations](#im
|
|||||||
~~~~
|
~~~~
|
||||||
# type Surface = int;
|
# type Surface = int;
|
||||||
# type BoundingBox = int;
|
# type BoundingBox = int;
|
||||||
|
|
||||||
trait Shape {
|
trait Shape {
|
||||||
fn draw(&self, Surface);
|
fn draw(&self, Surface);
|
||||||
fn bounding_box(&self) -> BoundingBox;
|
fn bounding_box(&self) -> BoundingBox;
|
||||||
@ -1363,7 +1362,6 @@ For example:
|
|||||||
~~~~
|
~~~~
|
||||||
# type Surface = int;
|
# type Surface = int;
|
||||||
# trait Shape { fn draw(&self, Surface); }
|
# trait Shape { fn draw(&self, Surface); }
|
||||||
|
|
||||||
fn draw_twice<T: Shape>(surface: Surface, sh: T) {
|
fn draw_twice<T: Shape>(surface: Surface, sh: T) {
|
||||||
sh.draw(surface);
|
sh.draw(surface);
|
||||||
sh.draw(surface);
|
sh.draw(surface);
|
||||||
@ -1379,7 +1377,6 @@ to pointers to the trait name, used as a type.
|
|||||||
# trait Shape { }
|
# trait Shape { }
|
||||||
# impl Shape for int { }
|
# impl Shape for int { }
|
||||||
# let mycircle = 0;
|
# let mycircle = 0;
|
||||||
|
|
||||||
let myshape: ~Shape = ~mycircle as ~Shape;
|
let myshape: ~Shape = ~mycircle as ~Shape;
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
@ -1440,7 +1437,6 @@ Likewise, supertrait methods may also be called on trait objects.
|
|||||||
# impl Shape for int { fn area(&self) -> f64 { 0.0 } }
|
# impl Shape for int { fn area(&self) -> f64 { 0.0 } }
|
||||||
# impl Circle for int { fn radius(&self) -> f64 { 0.0 } }
|
# impl Circle for int { fn radius(&self) -> f64 { 0.0 } }
|
||||||
# let mycircle = 0;
|
# let mycircle = 0;
|
||||||
|
|
||||||
let mycircle: Circle = ~mycircle as ~Circle;
|
let mycircle: Circle = ~mycircle as ~Circle;
|
||||||
let nonsense = mycircle.radius() * mycircle.area();
|
let nonsense = mycircle.radius() * mycircle.area();
|
||||||
~~~~
|
~~~~
|
||||||
@ -1457,7 +1453,6 @@ Implementations are defined with the keyword `impl`.
|
|||||||
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
|
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
|
||||||
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
|
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
|
||||||
# fn do_draw_circle(s: Surface, c: Circle) { }
|
# fn do_draw_circle(s: Surface, c: Circle) { }
|
||||||
|
|
||||||
struct Circle {
|
struct Circle {
|
||||||
radius: f64,
|
radius: f64,
|
||||||
center: Point,
|
center: Point,
|
||||||
@ -1490,7 +1485,6 @@ Implementation parameters are written after the `impl` keyword.
|
|||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
# trait Seq<T> { }
|
# trait Seq<T> { }
|
||||||
|
|
||||||
impl<T> Seq<T> for ~[T] {
|
impl<T> Seq<T> for ~[T] {
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
@ -1730,7 +1724,7 @@ attr : ident [ '=' literal
|
|||||||
| '(' attr_list ')' ] ? ;
|
| '(' attr_list ')' ] ? ;
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
Static entities in Rust -- crates, modules and items -- may have _attributes_
|
Static entities in Rust — crates, modules and items — may have _attributes_
|
||||||
applied to them. Attributes in Rust are modeled on Attributes in ECMA-335,
|
applied to them. Attributes in Rust are modeled on Attributes in ECMA-335,
|
||||||
with the syntax coming from ECMA-334 (C#). An attribute is a general,
|
with the syntax coming from ECMA-334 (C#). An attribute is a general,
|
||||||
free-form metadatum that is interpreted according to name, convention, and
|
free-form metadatum that is interpreted according to name, convention, and
|
||||||
@ -2352,8 +2346,8 @@ The declared names may denote new slots or new items.
|
|||||||
#### Item declarations
|
#### Item declarations
|
||||||
|
|
||||||
An _item declaration statement_ has a syntactic form identical to an
|
An _item declaration statement_ has a syntactic form identical to an
|
||||||
[item](#items) declaration within a module. Declaring an item -- a function,
|
[item](#items) declaration within a module. Declaring an item — a function,
|
||||||
enumeration, structure, type, static, trait, implementation or module -- locally
|
enumeration, structure, type, static, trait, implementation or module — locally
|
||||||
within a statement block is simply a way of restricting its scope to a narrow
|
within a statement block is simply a way of restricting its scope to a narrow
|
||||||
region containing all of its uses; it is otherwise identical in meaning to
|
region containing all of its uses; it is otherwise identical in meaning to
|
||||||
declaring the item outside the statement block.
|
declaring the item outside the statement block.
|
||||||
@ -3382,7 +3376,7 @@ but must be denoted by named reference to an [`enum` item](#enumerations).
|
|||||||
|
|
||||||
### Recursive types
|
### Recursive types
|
||||||
|
|
||||||
Nominal types -- [enumerations](#enumerated-types) and [structures](#structure-types) -- may be recursive.
|
Nominal types — [enumerations](#enumerated-types) and [structures](#structure-types) — may be recursive.
|
||||||
That is, each `enum` constructor or `struct` field may refer, directly or indirectly, to the enclosing `enum` or `struct` type itself.
|
That is, each `enum` constructor or `struct` field may refer, directly or indirectly, to the enclosing `enum` or `struct` type itself.
|
||||||
Such recursion has restrictions:
|
Such recursion has restrictions:
|
||||||
|
|
||||||
@ -3692,7 +3686,7 @@ entry to each function as the task executes. A stack allocation is reclaimed
|
|||||||
when control leaves the frame containing it.
|
when control leaves the frame containing it.
|
||||||
|
|
||||||
The _heap_ is a general term that describes two separate sets of boxes:
|
The _heap_ is a general term that describes two separate sets of boxes:
|
||||||
managed boxes -- which may be subject to garbage collection -- and owned
|
managed boxes — which may be subject to garbage collection — and owned
|
||||||
boxes. The lifetime of an allocation in the heap depends on the lifetime of
|
boxes. The lifetime of an allocation in the heap depends on the lifetime of
|
||||||
the box values pointing to it. Since box values may themselves be passed in
|
the box values pointing to it. Since box values may themselves be passed in
|
||||||
and out of frames, or stored in the heap, heap allocations may outlive the
|
and out of frames, or stored in the heap, heap allocations may outlive the
|
||||||
@ -3758,7 +3752,7 @@ initialized; this is enforced by the compiler.
|
|||||||
### Owned boxes
|
### Owned boxes
|
||||||
|
|
||||||
An _owned box_ is a reference to a heap allocation holding another value, which is constructed
|
An _owned box_ is a reference to a heap allocation holding another value, which is constructed
|
||||||
by the prefix *tilde* sigil `~`
|
by the prefix *tilde* sigil `~`.
|
||||||
|
|
||||||
An example of an owned box type and value:
|
An example of an owned box type and value:
|
||||||
|
|
||||||
@ -3793,7 +3787,7 @@ The runtime scheduler maps tasks to a certain number of operating-system threads
|
|||||||
By default, the scheduler chooses the number of threads based on
|
By default, the scheduler chooses the number of threads based on
|
||||||
the number of concurrent physical CPUs detected at startup.
|
the number of concurrent physical CPUs detected at startup.
|
||||||
It's also possible to override this choice at runtime.
|
It's also possible to override this choice at runtime.
|
||||||
When the number of tasks exceeds the number of threads -- which is likely --
|
When the number of tasks exceeds the number of threads — which is likely —
|
||||||
the scheduler multiplexes the tasks onto threads.^[
|
the scheduler multiplexes the tasks onto threads.^[
|
||||||
This is an M:N scheduler,
|
This is an M:N scheduler,
|
||||||
which is known to give suboptimal results for CPU-bound concurrency problems.
|
which is known to give suboptimal results for CPU-bound concurrency problems.
|
||||||
@ -3832,14 +3826,14 @@ that cause transitions between the states. The lifecycle states of a task are:
|
|||||||
* failing
|
* failing
|
||||||
* dead
|
* dead
|
||||||
|
|
||||||
A task begins its lifecycle -- once it has been spawned -- in the *running*
|
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 any
|
state. In this state it executes the statements of its entry function, and any
|
||||||
functions called by the entry function.
|
functions called by the entry function.
|
||||||
|
|
||||||
A task may transition from the *running* state to the *blocked*
|
A task may transition from the *running* state to the *blocked*
|
||||||
state any time it makes a blocking communication call. When the
|
state any time it makes a blocking communication call. When the
|
||||||
call can be completed -- when a message arrives at a sender, or a
|
call can be completed — when a message arrives at a sender, or a
|
||||||
buffer opens to receive a message -- then the blocked task will
|
buffer opens to receive a message — then the blocked task will
|
||||||
unblock and transition back to *running*.
|
unblock and transition back to *running*.
|
||||||
|
|
||||||
A task may transition to the *failing* state at any time, due being
|
A task may transition to the *failing* state at any time, due being
|
||||||
|
@ -51,13 +51,13 @@ fragments of programs that don't compile on their own. To try them
|
|||||||
out, you might have to wrap them in `fn main() { ... }`, and make sure
|
out, you might have to wrap them in `fn main() { ... }`, and make sure
|
||||||
they don't contain references to names that aren't actually defined.
|
they don't contain references to names that aren't actually defined.
|
||||||
|
|
||||||
> ***Warning:*** Rust is a language under ongoing development. Notes
|
> *Warning:* Rust is a language under ongoing development. Notes
|
||||||
> about potential changes to the language, implementation
|
> about potential changes to the language, implementation
|
||||||
> deficiencies, and other caveats appear offset in blockquotes.
|
> deficiencies, and other caveats appear offset in blockquotes.
|
||||||
|
|
||||||
# Getting started
|
# Getting started
|
||||||
|
|
||||||
> ***Warning:*** The tarball and installer links are for the most recent
|
> *Warning:* The tarball and installer links are for the most recent
|
||||||
> release, not master. To use master, you **must** build from [git].
|
> release, not master. To use master, you **must** build from [git].
|
||||||
|
|
||||||
The Rust compiler currently must be built from a [tarball] or [git], unless
|
The Rust compiler currently must be built from a [tarball] or [git], unless
|
||||||
@ -79,7 +79,7 @@ Snapshot binaries are currently built and tested on several platforms:
|
|||||||
You may find that other platforms work, but these are our "tier 1"
|
You may find that other platforms work, but these are our "tier 1"
|
||||||
supported build environments that are most likely to work.
|
supported build environments that are most likely to work.
|
||||||
|
|
||||||
> ***Note:*** Windows users should read the detailed
|
> *Note:* Windows users should read the detailed
|
||||||
> [Getting started][wiki-start] notes on the wiki. Even when using
|
> [Getting started][wiki-start] notes on the wiki. Even when using
|
||||||
> the binary installer, the Windows build requires a MinGW installation,
|
> the binary installer, the Windows build requires a MinGW installation,
|
||||||
> the precise details of which are not discussed here.
|
> the precise details of which are not discussed here.
|
||||||
@ -130,7 +130,7 @@ fn main() {
|
|||||||
println!("hello?");
|
println!("hello?");
|
||||||
}
|
}
|
||||||
~~~~
|
~~~~
|
||||||
> ***Note:*** An identifier followed by an exclamation point, like
|
> *Note:* An identifier followed by an exclamation point, like
|
||||||
> `println!`, is a macro invocation. Macros are explained
|
> `println!`, is a macro invocation. Macros are explained
|
||||||
> [later](#syntax-extensions); for now just remember to include the
|
> [later](#syntax-extensions); for now just remember to include the
|
||||||
> exclamation point.
|
> exclamation point.
|
||||||
@ -498,7 +498,7 @@ omitted.
|
|||||||
A powerful application of pattern matching is *destructuring*:
|
A powerful application of pattern matching is *destructuring*:
|
||||||
matching in order to bind names to the contents of data types.
|
matching in order to bind names to the contents of data types.
|
||||||
|
|
||||||
> ***Note:*** The following code makes use of tuples (`(f64, f64)`) which
|
> *Note:* The following code makes use of tuples (`(f64, f64)`) which
|
||||||
> are explained in section 5.3. For now you can think of tuples as a list of
|
> are explained in section 5.3. For now you can think of tuples as a list of
|
||||||
> items.
|
> items.
|
||||||
|
|
||||||
@ -781,7 +781,7 @@ fn area(sh: Shape) -> f64 {
|
|||||||
}
|
}
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
> ***Note:*** This feature of the compiler is currently gated behind the
|
> *Note:* This feature of the compiler is currently gated behind the
|
||||||
> `#[feature(struct_variant)]` directive. More about these directives can be
|
> `#[feature(struct_variant)]` directive. More about these directives can be
|
||||||
> found in the manual.
|
> found in the manual.
|
||||||
|
|
||||||
@ -841,7 +841,6 @@ values can be extracted with pattern matching:
|
|||||||
|
|
||||||
~~~
|
~~~
|
||||||
# struct Inches(int);
|
# struct Inches(int);
|
||||||
|
|
||||||
let length_with_unit = Inches(10);
|
let length_with_unit = Inches(10);
|
||||||
let Inches(integer_length) = length_with_unit;
|
let Inches(integer_length) = length_with_unit;
|
||||||
println!("length is {} inches", integer_length);
|
println!("length is {} inches", integer_length);
|
||||||
@ -1061,7 +1060,7 @@ list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil
|
|||||||
+--------------+ +--------------+ +--------------+ +--------------+
|
+--------------+ +--------------+ +--------------+ +--------------+
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
> ***Note:*** the above diagram shows the logical contents of the enum. The actual
|
> *Note:* the above diagram shows the logical contents of the enum. The actual
|
||||||
> memory layout of the enum may vary. For example, for the `List` enum shown
|
> memory layout of the enum may vary. For example, for the `List` enum shown
|
||||||
> above, Rust guarantees that there will be no enum tag field in the actual
|
> above, Rust guarantees that there will be no enum tag field in the actual
|
||||||
> structure. See the language reference for more details.
|
> structure. See the language reference for more details.
|
||||||
@ -1209,7 +1208,7 @@ let ys = Cons(5, ~Cons(10, ~Nil));
|
|||||||
assert!(eq(&xs, &ys));
|
assert!(eq(&xs, &ys));
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
> ***Note:*** Rust doesn't guarantee [tail-call](http://en.wikipedia.org/wiki/Tail_call) optimization,
|
> *Note:* Rust doesn't guarantee [tail-call](http://en.wikipedia.org/wiki/Tail_call) optimization,
|
||||||
> but LLVM is able to handle a simple case like this with optimizations enabled.
|
> but LLVM is able to handle a simple case like this with optimizations enabled.
|
||||||
|
|
||||||
## Lists of other types
|
## Lists of other types
|
||||||
@ -1220,7 +1219,7 @@ element type.
|
|||||||
|
|
||||||
The `u32` in the previous definition can be substituted with a type parameter:
|
The `u32` in the previous definition can be substituted with a type parameter:
|
||||||
|
|
||||||
> ***Note:*** The following code introduces generics, which are explained in a
|
> *Note:* The following code introduces generics, which are explained in a
|
||||||
> [dedicated section](#generics).
|
> [dedicated section](#generics).
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
@ -1794,7 +1793,7 @@ spawn(proc() {
|
|||||||
});
|
});
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
> ***Note:*** If you want to see the output of `debug!` statements, you will need to turn on
|
> *Note:* 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 environment
|
> `debug!` logging. To enable `debug!` logging, set the RUST_LOG environment
|
||||||
> variable to the name of your crate, which, for a file named `foo.rs`, will be
|
> variable to the name of your crate, which, for a file named `foo.rs`, will be
|
||||||
> `foo` (e.g., with bash, `export RUST_LOG=foo`).
|
> `foo` (e.g., with bash, `export RUST_LOG=foo`).
|
||||||
@ -1816,7 +1815,7 @@ call_twice(closure);
|
|||||||
call_twice(function);
|
call_twice(function);
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
> ***Note:*** Both the syntax and the semantics will be changing
|
> *Note:* Both the syntax and the semantics will be changing
|
||||||
> in small ways. At the moment they can be unsound in some
|
> in small ways. At the moment they can be unsound in some
|
||||||
> scenarios, particularly with non-copyable types.
|
> scenarios, particularly with non-copyable types.
|
||||||
|
|
||||||
@ -2011,7 +2010,7 @@ a function that returns `Option<T>` instead of `T`.
|
|||||||
fn radius(shape: Shape) -> Option<f64> {
|
fn radius(shape: Shape) -> Option<f64> {
|
||||||
match shape {
|
match shape {
|
||||||
Circle(_, radius) => Some(radius),
|
Circle(_, radius) => Some(radius),
|
||||||
Rectangle(..) => None
|
Rectangle(..) => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~~~~
|
~~~~
|
||||||
@ -2101,7 +2100,7 @@ references, or types where the only contained references
|
|||||||
have the `'static` lifetime. (For more on named lifetimes and their uses,
|
have the `'static` lifetime. (For more on named lifetimes and their uses,
|
||||||
see the [references and lifetimes guide][lifetimes].)
|
see the [references and lifetimes guide][lifetimes].)
|
||||||
|
|
||||||
> ***Note:*** These built-in traits were referred to as 'kinds' in earlier
|
> *Note:* These built-in traits were referred to as 'kinds' in earlier
|
||||||
> iterations of the language, and often still are.
|
> iterations of the language, and often still are.
|
||||||
|
|
||||||
Additionally, the `Drop` trait is used to define destructors. This
|
Additionally, the `Drop` trait is used to define destructors. This
|
||||||
@ -2512,7 +2511,7 @@ let mycircle: ~Circle = concrete as ~Circle;
|
|||||||
let nonsense = mycircle.radius() * mycircle.area();
|
let nonsense = mycircle.radius() * mycircle.area();
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
> ***Note:*** Trait inheritance does not actually work with objects yet
|
> *Note:* Trait inheritance does not actually work with objects yet
|
||||||
|
|
||||||
## Deriving implementations for traits
|
## Deriving implementations for traits
|
||||||
|
|
||||||
@ -2966,7 +2965,7 @@ use farm::*;
|
|||||||
# fn main() { cow(); chicken() }
|
# fn main() { cow(); chicken() }
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
> ***Note:*** This feature of the compiler is currently gated behind the
|
> *Note:* This feature of the compiler is currently gated behind the
|
||||||
> `#[feature(globs)]` directive. More about these directives can be found in
|
> `#[feature(globs)]` directive. More about these directives can be found in
|
||||||
> the manual.
|
> the manual.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user