Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #24869

Merged
merged 24 commits into from
Apr 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
31c3e7e
rustdoc: change color of trait types
liigo Apr 24, 2015
4ade708
In [-] doc buttons, change hyphen ‘-’ to minus ‘−’
roryokane Apr 25, 2015
e90408e
std: Fix process spawn for arguments ending in backslashes on Windows
bradking Apr 25, 2015
84ef3b5
collections: Improve example for as_string and as_vec
Apr 26, 2015
57284e6
Make From::from example more idiomatic / simpler
frewsxcv Apr 27, 2015
5ed3ac9
thread: right now you can't actually set those printers
richo Apr 27, 2015
02428df
Change hyphen to minus in HTML template too
roryokane Apr 27, 2015
72e8f7b
Change literal minus ‘−’ to HTML entity ‘−’
roryokane Apr 27, 2015
709f3c5
Update reference.md: string literals section
dhardy Apr 27, 2015
5c60145
Auto merge of #24820 - bradking:fix-windows-process-spawn-command-lin…
bors Apr 27, 2015
cf650a2
Update reference.md: floating-point section
dhardy Apr 27, 2015
7335c9f
book: improve Vec intro
tshepang Apr 27, 2015
38042d1
trpl: clarify lib.rs vs main.rs
Manishearth Apr 27, 2015
14a6a9f
reference: block-comment -> block comment
tshepang Apr 27, 2015
08c0299
Rollup merge of #24797 - roryokane:patch-1, r=nikomatsakis
steveklabnik Apr 27, 2015
130240a
Rollup merge of #24804 - liigo:new-trait-color, r=steveklabnik
steveklabnik Apr 27, 2015
72ee472
Rollup merge of #24848 - bluss:deref-string, r=alexcrichton
steveklabnik Apr 27, 2015
5a6d9cc
Rollup merge of #24854 - frewsxcv:patch-19, r=alexcrichton
steveklabnik Apr 27, 2015
30f41b1
Rollup merge of #24855 - richo:thread-doc, r=alexcrichton
steveklabnik Apr 27, 2015
be569bc
Rollup merge of #24860 - Manishearth:cargo-doc, r=steveklabnik
steveklabnik Apr 27, 2015
188f3eb
Rollup merge of #24863 - dhardy:patch-1, r=steveklabnik
steveklabnik Apr 27, 2015
0c35142
Rollup merge of #24866 - tshepang:vec-intro, r=steveklabnik
steveklabnik Apr 27, 2015
1b18da4
Rollup merge of #24867 - tshepang:patch-3, r=steveklabnik
steveklabnik Apr 27, 2015
03f3b45
Rollup merge of #24868 - tshepang:fix-vec-remove-doc, r=steveklabnik
steveklabnik Apr 27, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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:

```
Expand Down
7 changes: 7 additions & 0 deletions src/doc/trpl/hello-cargo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/doc/trpl/vectors.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
16 changes: 16 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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">[&minus;]</a>
</span>"##));

// Write `src` tag
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
16 changes: 8 additions & 8 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -808,20 +808,20 @@

$("#toggle-all-docs").on("click", function() {
var toggle = $("#toggle-all-docs");
if (toggle.html() == "[-]") {
toggle.html("[+]");
if (toggle.html() == "[&minus;]") {
toggle.html("[&plus;]");
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("&plus;");
} else {
toggle.html("[-]");
toggle.html("[&minus;]");
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("&minus;");
}
});

Expand All @@ -835,20 +835,20 @@
if (relatedDoc.is(":visible")) {
relatedDoc.slideUp({duration:'fast', easing:'linear'});
toggle.parent(".toggle-wrapper").addClass("collapsed");
toggle.children(".inner").html("+");
toggle.children(".inner").html("&plus;");
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("&minus;");
toggle.children(".toggle-label").hide();
}
}
});

$(function() {
var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
.html("[<span class='inner'>-</span>]");
.html("[<span class='inner'>&minus;</span>]");

$(".method").each(function() {
if ($(this).next().is(".docblock") ||
Expand Down
39 changes: 21 additions & 18 deletions src/libstd/sys/windows/process2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMA

// Produces a wide string *without terminating null*
fn make_command_line(prog: &OsStr, args: &[OsString]) -> Vec<u16> {
// Encode the command and arguments in a command line string such
// that the spawned process may recover them using CommandLineToArgvW.
let mut cmd: Vec<u16> = Vec::new();
append_arg(&mut cmd, prog);
for arg in args {
Expand All @@ -387,30 +389,27 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> Vec<u16> {
}

let mut iter = arg.encode_wide();
let mut backslashes: usize = 0;
while let Some(x) = iter.next() {
if x == '"' as u16 {
// escape quotes
cmd.push('\\' as u16);
cmd.push('"' as u16);
} else if x == '\\' as u16 {
// is this a run of backslashes followed by a " ?
if iter.clone().skip_while(|y| *y == '\\' as u16).next() == Some('"' as u16) {
// Double it ... NOTE: this behavior is being
// preserved as it's been part of Rust for a long
// time, but no one seems to know exactly why this
// is the right thing to do.
cmd.push('\\' as u16);
cmd.push('\\' as u16);
} else {
// Push it through unescaped
cmd.push('\\' as u16);
}
if x == '\\' as u16 {
backslashes += 1;
} else {
cmd.push(x)
if x == '"' as u16 {
// Add n+1 backslashes to total 2n+1 before internal '"'.
for _ in 0..(backslashes+1) {
cmd.push('\\' as u16);
}
}
backslashes = 0;
}
cmd.push(x);
}

if quote {
// Add n backslashes to total 2n before ending '"'.
for _ in 0..backslashes {
cmd.push('\\' as u16);
}
cmd.push('"' as u16);
}
}
Expand Down Expand Up @@ -486,6 +485,10 @@ mod tests {
test_wrapper("echo", &["a b c"]),
"echo \"a b c\""
);
assert_eq!(
test_wrapper("echo", &["\" \\\" \\", "\\"]),
"echo \"\\\" \\\\\\\" \\\\\" \\"
);
assert_eq!(
test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[]),
"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}"
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down