auto merge of #14348 : alexcrichton/rust/doc.rust-lang.org, r=huonw
This commit is contained in:
commit
a0960a1223
@ -2,7 +2,7 @@
|
||||
|
||||
If you're just reporting a bug, please see:
|
||||
|
||||
http://static.rust-lang.org/doc/master/complement-bugreport.html
|
||||
http://doc.rust-lang.org/complement-bugreport.html
|
||||
|
||||
## Pull request procedure
|
||||
|
||||
|
@ -13,7 +13,7 @@ documentation.
|
||||
> [getting started][wiki-start] notes on the wiki.
|
||||
|
||||
[installer]: http://www.rust-lang.org/install.html
|
||||
[tutorial]: http://static.rust-lang.org/doc/tutorial.html
|
||||
[tutorial]: http://doc.rust-lang.org/tutorial.html
|
||||
[wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust
|
||||
[win-wiki]: https://github.com/mozilla/rust/wiki/Using-Rust-on-Windows
|
||||
|
||||
@ -60,7 +60,7 @@ documentation.
|
||||
|
||||
[repo]: https://github.com/mozilla/rust
|
||||
[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz
|
||||
[tutorial]: http://static.rust-lang.org/doc/master/tutorial.html
|
||||
[tutorial]: http://doc.rust-lang.org/tutorial.html
|
||||
|
||||
## Notes
|
||||
|
||||
|
@ -156,7 +156,7 @@ doc/footer.tex: $(D)/footer.inc | doc/
|
||||
# HTML (rustdoc)
|
||||
DOC_TARGETS += doc/not_found.html
|
||||
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
|
||||
$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css http://static.rust-lang.org/doc/master/rust.css $<
|
||||
$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css http://doc.rust-lang.org/rust.css $<
|
||||
|
||||
define DEF_DOC
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
**Int to string**
|
||||
|
||||
Use [`ToStr`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToStr.html).
|
||||
Use [`ToStr`](../std/to_str/trait.ToStr.html).
|
||||
|
||||
~~~
|
||||
let x: int = 42;
|
||||
@ -13,7 +13,8 @@ let y: StrBuf = x.to_str().to_strbuf();
|
||||
|
||||
**String to int**
|
||||
|
||||
Use [`FromStr`](http://static.rust-lang.org/doc/master/std/from_str/trait.FromStr.html), and its helper function, [`from_str`](http://static.rust-lang.org/doc/master/std/from_str/fn.from_str.html).
|
||||
Use [`FromStr`](../std/from_str/trait.FromStr.html), and its helper function,
|
||||
[`from_str`](../std/from_str/fn.from_str.html).
|
||||
|
||||
~~~
|
||||
let x: Option<int> = from_str("42");
|
||||
@ -34,7 +35,8 @@ let y: StrBuf = format_strbuf!("{:X}", x); // uppercase hexadecimal
|
||||
|
||||
**String to int, in non-base-10**
|
||||
|
||||
Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.FromStrRadix.html), and its helper function, [`from_str_radix`](http://static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html).
|
||||
Use [`FromStrRadix`](../std/num/trait.FromStrRadix.html), and its helper
|
||||
function, [`from_str_radix`](../std/num/fn.from_str_radix.html).
|
||||
|
||||
~~~
|
||||
use std::num;
|
||||
@ -45,7 +47,8 @@ let y: i64 = x.unwrap();
|
||||
|
||||
**Vector of Bytes to String**
|
||||
|
||||
To return a Borrowed String Slice (&str) use the str helper function [`from_utf8`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8.html).
|
||||
To return a Borrowed String Slice (&str) use the str helper function
|
||||
[`from_utf8`](../std/str/fn.from_utf8.html).
|
||||
|
||||
~~~
|
||||
use std::str;
|
||||
@ -55,7 +58,8 @@ let x: Option<&str> = str::from_utf8(bytes);
|
||||
let y: &str = x.unwrap();
|
||||
~~~
|
||||
|
||||
To return an Owned String (StrBuf) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).
|
||||
To return an Owned String (StrBuf) use the str helper function
|
||||
[`from_utf8_owned`](../std/str/fn.from_utf8_owned.html).
|
||||
|
||||
~~~
|
||||
use std::str;
|
||||
@ -65,7 +69,10 @@ let x: Option<StrBuf> =
|
||||
let y: StrBuf = x.unwrap();
|
||||
~~~
|
||||
|
||||
To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html). This function also replaces non-valid utf-8 sequences with U+FFFD replacement character.
|
||||
To return a [`MaybeOwned`](../std/str/enum.MaybeOwned.html) use the str helper
|
||||
function [`from_utf8_lossy`](../std/str/fn.from_utf8_owned.html).
|
||||
This function also replaces non-valid utf-8 sequences with U+FFFD replacement
|
||||
character.
|
||||
|
||||
~~~
|
||||
use std::str;
|
||||
@ -78,7 +85,13 @@ let y = str::from_utf8_lossy(x);
|
||||
|
||||
## How do I read from a file?
|
||||
|
||||
Use [`File::open`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html#method.open) to create a [`File`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html) struct, which implements the [`Reader`](http://static.rust-lang.org/doc/master/std/io/trait.Reader.html) trait.
|
||||
Use
|
||||
[`File::open`](../std/io/fs/struct.File.html#method.open)
|
||||
to create a
|
||||
[`File`](../std/io/fs/struct.File.html)
|
||||
struct, which implements the
|
||||
[`Reader`](../std/io/trait.Reader.html)
|
||||
trait.
|
||||
|
||||
~~~ {.ignore}
|
||||
use std::path::Path;
|
||||
@ -91,7 +104,7 @@ let reader : File = File::open(&path).unwrap_or_else(on_error);
|
||||
|
||||
## How do I iterate over the lines in a file?
|
||||
|
||||
Use the [`lines`](http://static.rust-lang.org/doc/master/std/io/trait.Buffer.html#method.lines) method on a [`BufferedReader`](http://static.rust-lang.org/doc/master/std/io/buffered/struct.BufferedReader.html).
|
||||
Use the [`lines`](../std/io/trait.Buffer.html#method.lines) method on a [`BufferedReader`](../std/io/buffered/struct.BufferedReader.html).
|
||||
|
||||
~~~
|
||||
use std::io::BufferedReader;
|
||||
@ -109,7 +122,7 @@ for line in reader.lines() {
|
||||
|
||||
## How do I search for a substring?
|
||||
|
||||
Use the [`find_str`](http://static.rust-lang.org/doc/master/std/str/trait.StrSlice.html#tymethod.find_str) method.
|
||||
Use the [`find_str`](../std/str/trait.StrSlice.html#tymethod.find_str) method.
|
||||
|
||||
~~~
|
||||
let str = "Hello, this is some random string";
|
||||
@ -120,7 +133,7 @@ let index: Option<uint> = str.find_str("rand");
|
||||
|
||||
## How do I get the length of a vector?
|
||||
|
||||
The [`Container`](http://static.rust-lang.org/doc/master/std/container/trait.Container.html) trait provides the `len` method.
|
||||
The [`Container`](../std/container/trait.Container.html) trait provides the `len` method.
|
||||
|
||||
~~~
|
||||
let u: ~[u32] = ~[0, 1, 2];
|
||||
@ -132,7 +145,7 @@ println!("u: {}, v: {}, w: {}", u.len(), v.len(), w.len()); // 3, 4, 5
|
||||
|
||||
## How do I iterate over a vector?
|
||||
|
||||
Use the [`iter`](http://static.rust-lang.org/doc/master/std/vec/trait.ImmutableVector.html#tymethod.iter) method.
|
||||
Use the [`iter`](../std/vec/trait.ImmutableVector.html#tymethod.iter) method.
|
||||
|
||||
~~~
|
||||
let values: ~[int] = ~[1, 2, 3, 4, 5];
|
||||
@ -141,7 +154,10 @@ for value in values.iter() { // value: &int
|
||||
}
|
||||
~~~
|
||||
|
||||
(See also [`mut_iter`](http://static.rust-lang.org/doc/master/std/vec/trait.MutableVector.html#tymethod.mut_iter) which yields `&mut int` and [`move_iter`](http://static.rust-lang.org/doc/master/std/vec/trait.OwnedVector.html#tymethod.move_iter) which yields `int` while consuming the `values` vector.)
|
||||
(See also [`mut_iter`](../std/vec/trait.MutableVector.html#tymethod.mut_iter)
|
||||
which yields `&mut int` and
|
||||
[`move_iter`](../std/vec/trait.OwnedVector.html#tymethod.move_iter) which yields
|
||||
`int` while consuming the `values` vector.)
|
||||
|
||||
# Type system
|
||||
|
||||
|
@ -89,11 +89,11 @@ Raw pointers have much fewer guarantees than other pointer types
|
||||
offered by the Rust language and libraries. For example, they
|
||||
|
||||
- are not guaranteed to point to valid memory and are not even
|
||||
guaranteed to be non-null (unlike both `~` and `&`);
|
||||
- do not have any automatic clean-up, unlike `~`, and so require
|
||||
guaranteed to be non-null (unlike both `Box` and `&`);
|
||||
- do not have any automatic clean-up, unlike `Box`, and so require
|
||||
manual resource management;
|
||||
- are plain-old-data, that is, they don't move ownership, again unlike
|
||||
`~`, hence the Rust compiler cannot protect against bugs like
|
||||
`Box`, hence the Rust compiler cannot protect against bugs like
|
||||
use-after-free;
|
||||
- are considered sendable (if their contents is considered sendable),
|
||||
so the compiler offers no assistance with ensuring their use is
|
||||
@ -189,7 +189,7 @@ code:
|
||||
|
||||
As an example, we give a reimplementation of owned boxes by wrapping
|
||||
`malloc` and `free`. Rust's move semantics and lifetimes mean this
|
||||
reimplementation is as safe as the built-in `~` type.
|
||||
reimplementation is as safe as the `Box` type.
|
||||
|
||||
```
|
||||
extern crate libc;
|
||||
@ -198,13 +198,14 @@ use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
// Define a wrapper around the handle returned by the foreign code.
|
||||
// Unique<T> has the same semantics as ~T
|
||||
// Unique<T> has the same semantics as Box<T>
|
||||
pub struct Unique<T> {
|
||||
// It contains a single raw, mutable pointer to the object in question.
|
||||
ptr: *mut T
|
||||
}
|
||||
|
||||
// Implement methods for creating and using the values in the box.
|
||||
|
||||
// NB: For simplicity and correctness, we require that T has kind Send
|
||||
// (owned boxes relax this restriction, and can contain managed (GC) boxes).
|
||||
// This is because, as implemented, the garbage collector would not know
|
||||
@ -215,23 +216,26 @@ impl<T: Send> Unique<T> {
|
||||
let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
|
||||
// we *need* valid pointer.
|
||||
assert!(!ptr.is_null());
|
||||
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
|
||||
// `overwrite` moves a value into this memory without
|
||||
// attempting to drop the original value.
|
||||
// `*ptr` is uninitialized, and `*ptr = value` would
|
||||
// attempt to destroy it `overwrite` moves a value into
|
||||
// this memory without attempting to drop the original
|
||||
// value.
|
||||
mem::overwrite(&mut *ptr, value);
|
||||
Unique{ptr: ptr}
|
||||
}
|
||||
}
|
||||
|
||||
// the 'r lifetime results in the same semantics as `&*x` with ~T
|
||||
// the 'r lifetime results in the same semantics as `&*x` with
|
||||
// Box<T>
|
||||
pub fn borrow<'r>(&'r self) -> &'r T {
|
||||
// By construction, self.ptr is valid
|
||||
unsafe { &*self.ptr }
|
||||
}
|
||||
|
||||
// the 'r lifetime results in the same semantics as `&mut *x` with ~T
|
||||
// the 'r lifetime results in the same semantics as `&mut *x` with
|
||||
// Box<T>
|
||||
pub fn borrow_mut<'r>(&'r mut self) -> &'r mut T {
|
||||
unsafe { &mut*self.ptr }
|
||||
unsafe { &mut *self.ptr }
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +250,6 @@ impl<T: Send> Unique<T> {
|
||||
impl<T: Send> Drop for Unique<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
|
||||
// Copy the object out from the pointer onto the stack,
|
||||
// where it is covered by normal Rust destructor semantics
|
||||
// and cleans itself up, if necessary
|
||||
@ -428,11 +431,9 @@ this is undesirable, and can be avoided with the `#![no_std]`
|
||||
attribute attached to the crate.
|
||||
|
||||
```ignore
|
||||
# // FIXME #12903: linking failures due to no_std
|
||||
// the minimal library
|
||||
// a minimal library
|
||||
#![crate_type="lib"]
|
||||
#![no_std]
|
||||
|
||||
# // fn main() {} tricked you, rustdoc!
|
||||
```
|
||||
|
||||
@ -444,20 +445,23 @@ default shim for the C `main` function with your own.
|
||||
The function marked `#[start]` is passed the command line parameters
|
||||
in the same format as a C:
|
||||
|
||||
```ignore
|
||||
# // FIXME #12903: linking failures due to no_std
|
||||
```
|
||||
#![no_std]
|
||||
|
||||
extern "rust-intrinsic" { fn abort() -> !; }
|
||||
#[no_mangle] pub extern fn rust_stack_exhausted() {
|
||||
unsafe { abort() }
|
||||
}
|
||||
// Pull in the system libc library for what crt0.o likely requires
|
||||
extern crate libc;
|
||||
|
||||
// Entry point for this program
|
||||
#[start]
|
||||
fn start(_argc: int, _argv: **u8) -> int {
|
||||
0
|
||||
}
|
||||
|
||||
// These functions are invoked by the compiler, but not
|
||||
// for a bare-bones hello world. These are normally
|
||||
// provided by libstd.
|
||||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
|
||||
#[lang = "eh_personality"] extern fn eh_personality() {}
|
||||
# // fn main() {} tricked you, rustdoc!
|
||||
```
|
||||
|
||||
@ -467,29 +471,115 @@ correct ABI and the correct name, which requires overriding the
|
||||
compiler's name mangling too:
|
||||
|
||||
```ignore
|
||||
# // FIXME #12903: linking failures due to no_std
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
extern "rust-intrinsic" { fn abort() -> !; }
|
||||
#[no_mangle] pub extern fn rust_stack_exhausted() {
|
||||
unsafe { abort() }
|
||||
}
|
||||
extern crate libc;
|
||||
|
||||
#[no_mangle] // ensure that this symbol is called `main` in the output
|
||||
extern "C" fn main(_argc: int, _argv: **u8) -> int {
|
||||
pub extern fn main(argc: int, argv: **u8) -> int {
|
||||
0
|
||||
}
|
||||
|
||||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
|
||||
#[lang = "eh_personality"] extern fn eh_personality() {}
|
||||
# // fn main() {} tricked you, rustdoc!
|
||||
```
|
||||
|
||||
|
||||
Unfortunately the Rust compiler assumes that symbols with certain
|
||||
names exist; and these have to be defined (or linked in). This is the
|
||||
purpose of the `rust_stack_exhausted`: it is called when a function
|
||||
detects that it will overflow its stack. The example above uses the
|
||||
`abort` intrinsic which ensures that execution halts.
|
||||
The compiler currently makes a few assumptions about symbols which are available
|
||||
in the executable to call. Normally these functions are provided by the standard
|
||||
library, but without it you must define your own.
|
||||
|
||||
The first of these two functions, `stack_exhausted`, is invoked whenever stack
|
||||
overflow is detected. This function has a number of restrictions about how it
|
||||
can be called and what it must do, but if the stack limit register is not being
|
||||
maintained then a task always has an "infinite stack" and this function
|
||||
shouldn't get triggered.
|
||||
|
||||
The second of these two functions, `eh_personality`, is used by the failure
|
||||
mechanisms of the compiler. This is often mapped to GCC's personality function
|
||||
(see the [libstd implementation](../std/rt/unwind/) for more information), but
|
||||
crates which do not trigger failure can be assured that this function is never
|
||||
called.
|
||||
|
||||
## Using libcore
|
||||
|
||||
> **Note**: the core library's structure is unstable, and it is recommended to
|
||||
> use the standard library instead wherever possible.
|
||||
|
||||
With the above techniques, we've got a bare-metal executable running some Rust
|
||||
code. There is a good deal of functionality provided by the standard library,
|
||||
however, that is necessary to be productive in Rust. If the standard library is
|
||||
not sufficient, then [libcore](../core/) is designed to be used instead.
|
||||
|
||||
The core library has very few dependencies and is much more portable than the
|
||||
standard library itself. Additionally, the core library has most of the
|
||||
necessary functionality for writing idiomatic and effective Rust code.
|
||||
|
||||
As an example, here is a program that will calculate the dot product of two
|
||||
vectors provided from C, using idiomatic Rust practices.
|
||||
|
||||
```
|
||||
#![no_std]
|
||||
|
||||
# extern crate libc;
|
||||
extern crate core;
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::mem;
|
||||
use core::raw::Slice;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn dot_product(a: *u32, a_len: u32,
|
||||
b: *u32, b_len: u32) -> u32 {
|
||||
// Convert the provided arrays into Rust slices.
|
||||
// The core::raw module guarantees that the Slice
|
||||
// structure has the same memory layout as a &[T]
|
||||
// slice.
|
||||
//
|
||||
// This is an unsafe operation because the compiler
|
||||
// cannot tell the pointers are valid.
|
||||
let (a_slice, b_slice): (&[u32], &[u32]) = unsafe {
|
||||
mem::transmute((
|
||||
Slice { data: a, len: a_len as uint },
|
||||
Slice { data: b, len: b_len as uint },
|
||||
))
|
||||
};
|
||||
|
||||
// Iterate over the slices, collecting the result
|
||||
let mut ret = 0;
|
||||
for (i, j) in a_slice.iter().zip(b_slice.iter()) {
|
||||
ret += (*i) * (*j);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#[lang = "begin_unwind"]
|
||||
extern fn begin_unwind(args: &core::fmt::Arguments,
|
||||
file: &str,
|
||||
line: uint) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
|
||||
#[lang = "eh_personality"] extern fn eh_personality() {}
|
||||
# #[start] fn start(argc: int, argv: **u8) -> int { 0 }
|
||||
# fn main() {}
|
||||
```
|
||||
|
||||
Note that there is one extra lang item here which differs from the examples
|
||||
above, `begin_unwind`. This must be defined by consumers of libcore because the
|
||||
core library declares failure, but it does not define it. The `begin_unwind`
|
||||
lang item is this crate's definition of failure, and it must be guaranteed to
|
||||
never return.
|
||||
|
||||
As can be seen in this example, the core library is intended to provide the
|
||||
power of Rust in all circumstances, regardless of platform requirements. Further
|
||||
libraries, such as liballoc, add functionality to libcore which make other
|
||||
platform-specific assumptions, but continue to be more portable than the
|
||||
standard library itself.
|
||||
|
||||
# Interacting with the compiler internals
|
||||
|
||||
@ -512,6 +602,10 @@ libraries to interact directly with the compiler and vice versa:
|
||||
|
||||
## Intrinsics
|
||||
|
||||
> **Note**: intrinsics will forever have an unstable interface, it is
|
||||
> recommended to use the stable interfaces of libcore rather than intrinsics
|
||||
> directly.
|
||||
|
||||
These are imported as if they were FFI functions, with the special
|
||||
`rust-intrinsic` ABI. For example, if one was in a freestanding
|
||||
context, but wished to be able to `transmute` between types, and
|
||||
@ -530,6 +624,10 @@ As with any other FFI functions, these are always `unsafe` to call.
|
||||
|
||||
## Lang items
|
||||
|
||||
> **Note**: lang items are often provided by crates in the Rust distribution,
|
||||
> and lang items themselves have an unstable interface. It is recommended to use
|
||||
> officially distributed crates instead of defining your own lang items.
|
||||
|
||||
The `rustc` compiler has certain pluggable operations, that is,
|
||||
functionality that isn't hard-coded into the language, but is
|
||||
implemented in libraries, with a special marker to tell the compiler
|
||||
@ -537,29 +635,22 @@ it exists. The marker is the attribute `#[lang="..."]` and there are
|
||||
various different values of `...`, i.e. various different "lang
|
||||
items".
|
||||
|
||||
For example, `~` pointers require two lang items, one for allocation
|
||||
and one for deallocation. A freestanding program that uses the `~`
|
||||
For example, `Box` pointers require two lang items, one for allocation
|
||||
and one for deallocation. A freestanding program that uses the `Box`
|
||||
sugar for dynamic allocations via `malloc` and `free`:
|
||||
|
||||
```ignore
|
||||
# // FIXME #12903: linking failures due to no_std
|
||||
```
|
||||
#![no_std]
|
||||
|
||||
#[allow(ctypes)] // `uint` == `size_t` on Rust's platforms
|
||||
extern {
|
||||
fn malloc(size: uint) -> *mut u8;
|
||||
fn free(ptr: *mut u8);
|
||||
extern crate libc;
|
||||
|
||||
extern {
|
||||
fn abort() -> !;
|
||||
}
|
||||
|
||||
#[no_mangle] pub extern fn rust_stack_exhausted() {
|
||||
unsafe { abort() }
|
||||
}
|
||||
|
||||
#[lang="exchange_malloc"]
|
||||
unsafe fn allocate(size: uint) -> *mut u8 {
|
||||
let p = malloc(size);
|
||||
unsafe fn allocate(size: uint, _align: uint) -> *mut u8 {
|
||||
let p = libc::malloc(size as libc::size_t) as *mut u8;
|
||||
|
||||
// malloc failed
|
||||
if p as uint == 0 {
|
||||
@ -569,18 +660,19 @@ unsafe fn allocate(size: uint) -> *mut u8 {
|
||||
p
|
||||
}
|
||||
#[lang="exchange_free"]
|
||||
unsafe fn deallocate(ptr: *mut u8) {
|
||||
free(ptr)
|
||||
unsafe fn deallocate(ptr: *mut u8, _size: uint, _align: uint) {
|
||||
libc::free(ptr as *mut libc::c_void)
|
||||
}
|
||||
|
||||
#[start]
|
||||
fn main(_argc: int, _argv: **u8) -> int {
|
||||
let _x = ~1;
|
||||
fn main(argc: int, argv: **u8) -> int {
|
||||
let x = box 1;
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
# // fn main() {} tricked you, rustdoc!
|
||||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
|
||||
#[lang = "eh_personality"] extern fn eh_personality() {}
|
||||
```
|
||||
|
||||
Note the use of `abort`: the `exchange_malloc` lang item is assumed to
|
||||
@ -602,6 +694,6 @@ Other features provided by lang items include:
|
||||
`contravariant_lifetime`, `no_share_bound`, etc.
|
||||
|
||||
Lang items are loaded lazily by the compiler; e.g. if one never uses
|
||||
`~` then there is no need to define functions for `exchange_malloc`
|
||||
`Box` then there is no need to define functions for `exchange_malloc`
|
||||
and `exchange_free`. `rustc` will emit an error when an item is needed
|
||||
but not found in the current crate or any that it depends on.
|
||||
|
@ -13,8 +13,7 @@ Some things that might be helpful to you though:
|
||||
|
||||
## Reference
|
||||
* [The Rust official site](http://rust-lang.org)
|
||||
* [The Rust reference manual](http://static.rust-lang.org/doc/master/rust.html) (* [PDF](http://static.rust-lang.org/doc/master/rust.pdf))
|
||||
* [The Rust reference manual](http://doc.rust-lang.org/rust.html) (* [PDF](http://doc.rust-lang.org/rust.pdf))
|
||||
|
||||
## Docs
|
||||
* [The standard library (stable)](http://doc.rust-lang.org/doc/0.10/std/index.html)
|
||||
* [The standard library (master)](http://doc.rust-lang.org/doc/master/std/index.html)
|
||||
* [The standard library](http://doc.rust-lang.org/std/)
|
||||
|
@ -67,7 +67,7 @@ documentation:
|
||||
~~~
|
||||
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")];
|
||||
html_root_url = "http://doc.rust-lang.org/")];
|
||||
~~~
|
||||
|
||||
The `html_root_url` is the prefix that rustdoc will apply to any references to
|
||||
|
@ -382,7 +382,7 @@ let y: uint = x as uint;
|
||||
assert!(y == 4u);
|
||||
~~~~
|
||||
|
||||
[transmute]: http://static.rust-lang.org/doc/master/std/cast/fn.transmute.html
|
||||
[transmute]: http://doc.rust-lang.org/std/mem/fn.transmute.html
|
||||
|
||||
## Syntax extensions
|
||||
|
||||
@ -409,7 +409,7 @@ println!("what is this thing: {:?}", mystery_object);
|
||||
~~~~
|
||||
|
||||
[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf
|
||||
[fmt]: http://static.rust-lang.org/doc/master/std/fmt/index.html
|
||||
[fmt]: http://doc.rust-lang.org/std/fmt/
|
||||
|
||||
You can define your own syntax extensions with the macro system. For details,
|
||||
see the [macro tutorial][macros]. Note that macro definition is currently
|
||||
@ -959,8 +959,8 @@ that are `Send`, but non-`Send` types can still *contain* types with custom
|
||||
destructors. Example of types which are not `Send` are [`Gc<T>`][gc] and
|
||||
[`Rc<T>`][rc], the shared-ownership types.
|
||||
|
||||
[gc]: http://static.rust-lang.org/doc/master/std/gc/struct.Gc.html
|
||||
[rc]: http://static.rust-lang.org/doc/master/std/rc/struct.Rc.html
|
||||
[gc]: http://doc.rust-lang.org/std/gc/struct.Gc.html
|
||||
[rc]: http://doc.rust-lang.org/std/rc/struct.Rc.html
|
||||
|
||||
# Implementing a linked list
|
||||
|
||||
@ -1486,7 +1486,7 @@ let mut x = 5;
|
||||
# x = 3;
|
||||
~~~~
|
||||
|
||||
[refcell]: http://static.rust-lang.org/doc/master/std/cell/struct.RefCell.html
|
||||
[refcell]: http://doc.rust-lang.org/std/cell/struct.RefCell.html
|
||||
|
||||
# Dereferencing pointers
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![no_std]
|
||||
#![feature(phase)]
|
||||
|
@ -25,7 +25,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![allow(missing_doc)]
|
||||
|
||||
extern crate collections;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules, managed_boxes, default_type_params, phase)]
|
||||
|
||||
|
@ -59,7 +59,7 @@ This `for` loop syntax can be applied to any iterator over any type.
|
||||
## Iteration protocol and more
|
||||
|
||||
More detailed information about iterators can be found in the [container
|
||||
guide](http://static.rust-lang.org/doc/master/guide-container.html) with
|
||||
guide](http://doc.rust-lang.org/guide-container.html) with
|
||||
the rest of the rust manuals.
|
||||
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![no_std]
|
||||
#![feature(globs, macro_rules, managed_boxes, phase)]
|
||||
|
@ -24,7 +24,7 @@ Simple [DEFLATE][def]-based compression. This is a wrapper around the
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(phase)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
||||
|
@ -45,7 +45,7 @@ fn main() {
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![deny(deprecated_owned_vector)]
|
||||
#![feature(macro_registrar, managed_boxes)]
|
||||
|
@ -84,7 +84,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(globs, phase)]
|
||||
#![deny(missing_doc)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
@ -29,7 +29,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
||||
|
@ -272,7 +272,7 @@ pub fn main() {
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![experimental]
|
||||
|
||||
|
@ -203,7 +203,7 @@
|
||||
#![crate_type = "dylib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
// NB this does *not* include globs, please keep it that way.
|
||||
#![feature(macro_rules, phase)]
|
||||
|
@ -42,7 +42,7 @@ fn main() {
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![deny(deprecated_owned_vector)]
|
||||
#![feature(macro_registrar, managed_boxes)]
|
||||
|
@ -111,7 +111,7 @@ if logging is disabled, none of the components of the log will be executed.
|
||||
#![crate_type = "dylib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules)]
|
||||
#![deny(missing_doc, deprecated_owned_vector)]
|
||||
|
@ -47,7 +47,7 @@
|
||||
#![crate_type = "dylib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![deny(unused_result, unused_must_use)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![feature(macro_rules)]
|
||||
|
@ -50,7 +50,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
||||
|
@ -75,7 +75,7 @@ println!("{:?}", tuple_ptr)
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules, managed_boxes, phase)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
@ -359,7 +359,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules, phase)]
|
||||
#![deny(missing_doc, deprecated_owned_vector)]
|
||||
|
@ -17,7 +17,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_registrar, managed_boxes, quote)]
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![no_std]
|
||||
#![experimental]
|
||||
|
@ -42,7 +42,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
|
||||
}
|
||||
|
||||
static BUG_REPORT_URL: &'static str =
|
||||
"http://static.rust-lang.org/doc/master/complement-bugreport.html";
|
||||
"http://doc.rust-lang.org/complement-bugreport.html";
|
||||
|
||||
fn run_compiler(args: &[StrBuf]) {
|
||||
let matches = match handle_options(Vec::from_slice(args)) {
|
||||
|
@ -25,7 +25,7 @@ This API is completely unstable and subject to change.
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![allow(deprecated)]
|
||||
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote,
|
||||
|
@ -220,10 +220,10 @@ pub enum AutoRef {
|
||||
/// Convert from T to &T
|
||||
AutoPtr(Region, ast::Mutability),
|
||||
|
||||
/// Convert from ~[]/&[] to &[] (or str)
|
||||
/// Convert from ~[]/&[] to &[] or str
|
||||
AutoBorrowVec(Region, ast::Mutability),
|
||||
|
||||
/// Convert from ~[]/&[] to &&[] (or str)
|
||||
/// Convert from ~[]/&[] to &&[] or str
|
||||
AutoBorrowVecRef(Region, ast::Mutability),
|
||||
|
||||
/// Convert from T to *T
|
||||
|
@ -34,7 +34,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
||||
use std::char;
|
||||
|
@ -20,7 +20,7 @@ Core encoding and decoding interfaces.
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(macro_rules, managed_boxes, default_type_params, phase)]
|
||||
|
||||
// test harness access
|
||||
|
@ -32,7 +32,7 @@
|
||||
//!
|
||||
//! ## Pervasive types
|
||||
//!
|
||||
//! The [`option`](option/index.html) and [`result`](result/index.html)
|
||||
//! The [`option`](option/index.html) and [`result`](../core/result/index.html)
|
||||
//! modules define optional and error-handling types, `Option` and `Result`.
|
||||
//! [`iter`](../core/iter/index.html) defines Rust's iterator protocol
|
||||
//! along with a wide variety of iterators.
|
||||
@ -102,7 +102,7 @@
|
||||
#![crate_type = "dylib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
|
||||
simd, linkage, default_type_params, phase, concat_idents, quad_precision_float)]
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(phase)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
||||
|
@ -350,7 +350,7 @@ pub fn test_cfg<AM: AttrMetaMethods, It: Iterator<AM>>
|
||||
no_cfgs || some_cfg_matches
|
||||
}
|
||||
|
||||
/// Represents the #[deprecated="foo"] (etc) attributes.
|
||||
/// Represents the #[deprecated="foo"] and friends attributes.
|
||||
pub struct Stability {
|
||||
pub level: StabilityLevel,
|
||||
pub text: Option<InternedString>
|
||||
|
@ -22,7 +22,7 @@ pub fn expand_syntax_ext(ecx: &mut base::ExtCtxt,
|
||||
-> Box<base::MacResult> {
|
||||
ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead");
|
||||
ecx.parse_sess.span_diagnostic.span_note(sp,
|
||||
"see http://static.rust-lang.org/doc/master/std/fmt/index.html \
|
||||
"see http://doc.rust-lang.org/std/fmt/ \
|
||||
for documentation");
|
||||
|
||||
base::MacExpr::new(ecx.expr_uint(sp, 2))
|
||||
|
@ -24,7 +24,7 @@ This API is completely unstable and subject to change.
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules, globs, managed_boxes, default_type_params, phase,
|
||||
quote)]
|
||||
|
@ -45,7 +45,7 @@
|
||||
#![crate_type = "dylib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(macro_rules, phase)]
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#![crate_type = "dylib"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(asm, macro_rules, phase)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
@ -17,7 +17,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(phase)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(default_type_params)]
|
||||
|
||||
extern crate collections;
|
||||
|
@ -60,7 +60,7 @@ Examples of string representations:
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
|
||||
#![feature(default_type_params)]
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")]
|
||||
html_root_url = "http://doc.rust-lang.org/")]
|
||||
#![feature(phase)]
|
||||
#![allow(visible_private_types)]
|
||||
#![deny(deprecated_owned_vector)]
|
||||
|
Loading…
Reference in New Issue
Block a user