Auto merge of #24869 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24797, #24804, #24848, #24854, #24855, #24860, #24863, #24866, #24867, #24868 - Failed merges:
This commit is contained in:
commit
32f9f42762
@ -84,7 +84,7 @@ that does _not_ occur in the set of [keywords](#keywords).
|
||||
## Comments
|
||||
|
||||
Comments in Rust code follow the general C++ style of line (`//`) and
|
||||
block-comment (`/* ... */`) forms. Nested block comments are supported.
|
||||
block (`/* ... */`) comment forms. Nested block comments are supported.
|
||||
|
||||
Line comments beginning with exactly _three_ slashes (`///`), and block
|
||||
comments beginning with exactly one repeated asterisk in the block-open
|
||||
@ -192,13 +192,13 @@ which must be _escaped_ by a preceding `U+005C` character (`\`).
|
||||
|
||||
A _string literal_ is a sequence of any Unicode characters enclosed within two
|
||||
`U+0022` (double-quote) characters, with the exception of `U+0022` itself,
|
||||
which must be _escaped_ by a preceding `U+005C` character (`\`), or a _raw
|
||||
string literal_.
|
||||
which must be _escaped_ by a preceding `U+005C` character (`\`).
|
||||
|
||||
A multi-line string literal may be defined by terminating each line with a
|
||||
`U+005C` character (`\`) immediately before the newline. This causes the
|
||||
`U+005C` character, the newline, and all whitespace at the beginning of the
|
||||
next line to be ignored.
|
||||
Line-break characters are allowed in string literals. Normally they represent
|
||||
themselves (i.e. no translation), but as a special exception, when a `U+005C`
|
||||
character (`\`) occurs immediately before the newline, the `U+005C` character,
|
||||
the newline, and all whitespace at the beginning of the next line are ignored.
|
||||
Thus `a` and `b` are equal:
|
||||
|
||||
```rust
|
||||
let a = "foobar";
|
||||
@ -366,11 +366,19 @@ A _floating-point literal_ has one of two forms:
|
||||
optionally followed by another decimal literal, with an optional _exponent_.
|
||||
* A single _decimal literal_ followed by an _exponent_.
|
||||
|
||||
By default, a floating-point literal has a generic type, and, like integer
|
||||
literals, the type must be uniquely determined from the context. There are two valid
|
||||
Like integer literals, a floating-point literal may be followed by a
|
||||
suffix, so long as the pre-suffix part does not end with `U+002E` (`.`).
|
||||
The suffix forcibly sets the type of the literal. There are two valid
|
||||
_floating-point suffixes_, `f32` and `f64` (the 32-bit and 64-bit floating point
|
||||
types), which explicitly determine the type of the literal.
|
||||
|
||||
The type of an _unsuffixed_ floating-point literal is determined by type
|
||||
inference. If a floating-point type can be _uniquely_ determined from the
|
||||
surrounding program context, the unsuffixed floating-point literal has that type.
|
||||
If the program context underconstrains the type, it defaults to double-precision `f64`;
|
||||
if the program context overconstrains the type, it is considered a static type
|
||||
error.
|
||||
|
||||
Examples of floating-point literals of various forms:
|
||||
|
||||
```
|
||||
|
@ -32,6 +32,13 @@ $ mkdir src
|
||||
$ mv main.rs src/main.rs
|
||||
```
|
||||
|
||||
Note that since we're creating an executable, we used `main.rs`. If we
|
||||
want to make a library instead, we should use `lib.rs`.
|
||||
Custom file locations for the entry point can be specified
|
||||
with a [`[[lib]]` or `[[bin]]`][crates-custom] key in the TOML file described below.
|
||||
|
||||
[crates-custom]: http://doc.crates.io/manifest.html#configuring-a-target
|
||||
|
||||
Cargo expects your source files to live inside a `src` directory. That leaves
|
||||
the top level for other things, like READMEs, license information, and anything
|
||||
not related to your code. Cargo helps us keep our projects nice and tidy. A
|
||||
|
@ -1,8 +1,9 @@
|
||||
% Vectors
|
||||
|
||||
A ‘vector’ is a dynamic or ‘growable’ array, implemented as the standard
|
||||
library type [`Vec<T>`][vec]. That `<T>` is a [generic][generic], meaning we
|
||||
can have vectors of any type. Vectors always allocate their data on the heap.
|
||||
library type [`Vec<T>`][vec]. The `T` means that we can have vectors
|
||||
of any type (see the chapter on [generics][generic] for more).
|
||||
Vectors always allocate their data on the heap.
|
||||
You can create them with the `vec!` macro:
|
||||
|
||||
```rust
|
||||
|
@ -951,12 +951,13 @@ impl<'a> Deref for DerefString<'a> {
|
||||
/// # #![feature(collections)]
|
||||
/// use std::string::as_string;
|
||||
///
|
||||
/// fn string_consumer(s: String) {
|
||||
/// assert_eq!(s, "foo".to_string());
|
||||
/// // Let's pretend we have a function that requires `&String`
|
||||
/// fn string_consumer(s: &String) {
|
||||
/// assert_eq!(s, "foo");
|
||||
/// }
|
||||
///
|
||||
/// let string = as_string("foo").clone();
|
||||
/// string_consumer(string);
|
||||
/// // Provide a `&String` from a `&str` without allocating
|
||||
/// string_consumer(&as_string("foo"));
|
||||
/// ```
|
||||
#[unstable(feature = "collections")]
|
||||
pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
|
||||
|
@ -536,7 +536,7 @@ impl<T> Vec<T> {
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `i` is out of bounds.
|
||||
/// Panics if `index` is out of bounds.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -1915,6 +1915,22 @@ impl<'a, T> Drop for DerefVec<'a, T> {
|
||||
}
|
||||
|
||||
/// Converts a slice to a wrapper type providing a `&Vec<T>` reference.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #![feature(collections)]
|
||||
/// use std::vec::as_vec;
|
||||
///
|
||||
/// // Let's pretend we have a function that requires `&Vec<i32>`
|
||||
/// fn vec_consumer(s: &Vec<i32>) {
|
||||
/// assert_eq!(s, &[1, 2, 3]);
|
||||
/// }
|
||||
///
|
||||
/// // Provide a `&Vec<i32>` from a `&[i32]` without allocating
|
||||
/// let values = [1, 2, 3];
|
||||
/// vec_consumer(&as_vec(&values));
|
||||
/// ```
|
||||
#[unstable(feature = "collections")]
|
||||
pub fn as_vec<'a, T>(x: &'a [T]) -> DerefVec<'a, T> {
|
||||
unsafe {
|
||||
|
@ -83,10 +83,8 @@ pub trait Into<T>: Sized {
|
||||
/// `String` implements `From<&str>`:
|
||||
///
|
||||
/// ```
|
||||
/// let s = "hello";
|
||||
/// let string = "hello".to_string();
|
||||
///
|
||||
/// let other_string: String = From::from(s);
|
||||
/// let other_string = String::from("hello");
|
||||
///
|
||||
/// assert_eq!(string, other_string);
|
||||
/// ```
|
||||
|
@ -1460,7 +1460,7 @@ impl<'a> fmt::Display for Item<'a> {
|
||||
try!(write!(fmt, "<span class='out-of-band'>"));
|
||||
try!(write!(fmt,
|
||||
r##"<span id='render-detail'>
|
||||
<a id="toggle-all-docs" href="#" title="collapse all docs">[-]</a>
|
||||
<a id="toggle-all-docs" href="#" title="collapse all docs">[−]</a>
|
||||
</span>"##));
|
||||
|
||||
// Write `src` tag
|
||||
|
@ -392,7 +392,7 @@ a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.content span.trait, .content a.trait, .block a.current.trait { color: #ed9603; }
|
||||
.content span.trait, .content a.trait, .block a.current.trait { color: #8866ff; }
|
||||
.content span.mod, .content a.mod, block a.current.mod { color: #4d76ae; }
|
||||
.content span.enum, .content a.enum, .block a.current.enum { color: #5e9766; }
|
||||
.content span.struct, .content a.struct, .block a.current.struct { color: #e53700; }
|
||||
|
@ -808,20 +808,20 @@
|
||||
|
||||
$("#toggle-all-docs").on("click", function() {
|
||||
var toggle = $("#toggle-all-docs");
|
||||
if (toggle.html() == "[-]") {
|
||||
toggle.html("[+]");
|
||||
if (toggle.html() == "[−]") {
|
||||
toggle.html("[+]");
|
||||
toggle.attr("title", "expand all docs");
|
||||
$(".docblock").hide();
|
||||
$(".toggle-label").show();
|
||||
$(".toggle-wrapper").addClass("collapsed");
|
||||
$(".collapse-toggle").children(".inner").html("+");
|
||||
$(".collapse-toggle").children(".inner").html("+");
|
||||
} else {
|
||||
toggle.html("[-]");
|
||||
toggle.html("[−]");
|
||||
toggle.attr("title", "collapse all docs");
|
||||
$(".docblock").show();
|
||||
$(".toggle-label").hide();
|
||||
$(".toggle-wrapper").removeClass("collapsed");
|
||||
$(".collapse-toggle").children(".inner").html("-");
|
||||
$(".collapse-toggle").children(".inner").html("−");
|
||||
}
|
||||
});
|
||||
|
||||
@ -835,12 +835,12 @@
|
||||
if (relatedDoc.is(":visible")) {
|
||||
relatedDoc.slideUp({duration:'fast', easing:'linear'});
|
||||
toggle.parent(".toggle-wrapper").addClass("collapsed");
|
||||
toggle.children(".inner").html("+");
|
||||
toggle.children(".inner").html("+");
|
||||
toggle.children(".toggle-label").fadeIn();
|
||||
} else {
|
||||
relatedDoc.slideDown({duration:'fast', easing:'linear'});
|
||||
toggle.parent(".toggle-wrapper").removeClass("collapsed");
|
||||
toggle.children(".inner").html("-");
|
||||
toggle.children(".inner").html("−");
|
||||
toggle.children(".toggle-label").hide();
|
||||
}
|
||||
}
|
||||
@ -848,7 +848,7 @@
|
||||
|
||||
$(function() {
|
||||
var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
|
||||
.html("[<span class='inner'>-</span>]");
|
||||
.html("[<span class='inner'>−</span>]");
|
||||
|
||||
$(".method").each(function() {
|
||||
if ($(this).next().is(".docblock") ||
|
||||
|
@ -115,8 +115,7 @@
|
||||
//! ## Configuring threads
|
||||
//!
|
||||
//! A new thread can be configured before it is spawned via the `Builder` type,
|
||||
//! which currently allows you to set the name, stack size, and writers for
|
||||
//! `println!` and `panic!` for the child thread:
|
||||
//! which currently allows you to set the name and stack size for the child thread:
|
||||
//!
|
||||
//! ```rust
|
||||
//! # #![allow(unused_must_use)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user