diff --git a/src/doc/reference.md b/src/doc/reference.md index 7c9cca90edda7..cec58d618efcc 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -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: ``` diff --git a/src/doc/trpl/hello-cargo.md b/src/doc/trpl/hello-cargo.md index 6967532a44735..d547451fccec2 100644 --- a/src/doc/trpl/hello-cargo.md +++ b/src/doc/trpl/hello-cargo.md @@ -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 diff --git a/src/doc/trpl/vectors.md b/src/doc/trpl/vectors.md index 28d815c4eb735..6170bdb86eaa3 100644 --- a/src/doc/trpl/vectors.md +++ b/src/doc/trpl/vectors.md @@ -1,8 +1,9 @@ % Vectors A ‘vector’ is a dynamic or ‘growable’ array, implemented as the standard -library type [`Vec`][vec]. That `` is a [generic][generic], meaning we -can have vectors of any type. Vectors always allocate their data on the heap. +library type [`Vec`][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 diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index a37a26ef22ac3..be6405dc85a14 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -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> { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index c8a8498d2f929..b033c2d90e178 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -536,7 +536,7 @@ impl Vec { /// /// # 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` reference. +/// +/// # Examples +/// +/// ``` +/// # #![feature(collections)] +/// use std::vec::as_vec; +/// +/// // Let's pretend we have a function that requires `&Vec` +/// fn vec_consumer(s: &Vec) { +/// assert_eq!(s, &[1, 2, 3]); +/// } +/// +/// // Provide a `&Vec` 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 { diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index d9cda58d9ebed..d3de77a9241e3 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -83,10 +83,8 @@ pub trait Into: 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); /// ``` diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 1993f03efd1fa..a2cfb533c1a00 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1460,7 +1460,7 @@ impl<'a> fmt::Display for Item<'a> { try!(write!(fmt, "")); try!(write!(fmt, r##" - [-] + [−] "##)); // Write `src` tag diff --git a/src/librustdoc/html/static/main.css b/src/librustdoc/html/static/main.css index c94dbc1510332..b907e9e20b698 100644 --- a/src/librustdoc/html/static/main.css +++ b/src/librustdoc/html/static/main.css @@ -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; } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 56cea50a50239..c2a59278a86dc 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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 = $("", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'}) - .html("[-]"); + .html("[]"); $(".method").each(function() { if ($(this).next().is(".docblock") || diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 9168a716d4380..383726b3e8370 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -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)]