From db2f308a46fe4e66311ed7d05f2b4f7597c6a7b3 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Mon, 20 Apr 2015 20:45:02 -0500 Subject: [PATCH 1/8] Add two examples for Path::new --- src/libstd/path.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 1ad1508ae2d07..c5646e014eba4 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1248,6 +1248,13 @@ impl Path { /// use std::path::Path; /// /// Path::new("foo.txt"); + /// + /// // Strings work too + /// let s = String::from("bar.txt"); + /// let p = Path::new(&s); + /// + /// // As do other Paths + /// Path::new(&p); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new + ?Sized>(s: &S) -> &Path { From e178495a5e3db9b8dcafce1ec9bbac4906bb92ad Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Mon, 20 Apr 2015 21:01:13 -0500 Subject: [PATCH 2/8] Address some nits --- src/libstd/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index c5646e014eba4..b4a359080d786 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1249,11 +1249,11 @@ impl Path { /// /// Path::new("foo.txt"); /// - /// // Strings work too + /// // Strings work too: /// let s = String::from("bar.txt"); /// let p = Path::new(&s); /// - /// // As do other Paths + /// // As do other `Path`s: /// Path::new(&p); /// ``` #[stable(feature = "rust1", since = "1.0.0")] From ba4d55d130f9577eddf577b9bf99562a8c65857b Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Tue, 21 Apr 2015 01:15:51 -0500 Subject: [PATCH 3/8] Separate code into two code blocks --- src/libstd/path.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index b4a359080d786..0a13c77018f71 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1248,12 +1248,13 @@ impl Path { /// use std::path::Path; /// /// Path::new("foo.txt"); + /// ``` + /// + /// You can create `Path`s from `String`s, or even other `Path`s: /// - /// // Strings work too: + /// ``` /// let s = String::from("bar.txt"); /// let p = Path::new(&s); - /// - /// // As do other `Path`s: /// Path::new(&p); /// ``` #[stable(feature = "rust1", since = "1.0.0")] From b6dd0197f3f20c7fbd0301f2aba5a70d0fc9a68d Mon Sep 17 00:00:00 2001 From: Skyler Date: Fri, 24 Apr 2015 23:26:56 -0700 Subject: [PATCH 4/8] Reference manual 3.5.2.3.1 The description of the syntax for single byte literals is missing the preceding `b` distinction. --- src/doc/reference.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 059da89192576..13f5e391e4239 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -269,10 +269,11 @@ r##"foo #"# bar"##; // foo #"# bar ##### Byte literals A _byte literal_ is a single ASCII character (in the `U+0000` to `U+007F` -range) enclosed within two `U+0027` (single-quote) characters, with the -exception of `U+0027` itself, which must be _escaped_ by a preceding U+005C -character (`\`), or a single _escape_. It is equivalent to a `u8` unsigned -8-bit integer _number literal_. +range) or a single _escape_ preceded by the characters `U+0062` (`b`) and +`U+0027` (single-quote), and followed by the character `U+0027`. If the character +`U+0027` is present within the literal, it must be _escaped_ by a preceding +`U+005C` (`\`) character. It is equivalent to a `u8` unsigned 8-bit integer +_number literal_. ##### Byte string literals From 46462c7b5f33f33a338ee7ab40476be2234e2851 Mon Sep 17 00:00:00 2001 From: FuGangqiang Date: Fri, 24 Apr 2015 23:56:02 +0800 Subject: [PATCH 5/8] fix doc --- src/doc/trpl/getting-started.md | 2 +- src/doc/trpl/glossary.md | 2 +- src/doc/trpl/primitive-types.md | 14 +++++++------- src/doc/trpl/variable-bindings.md | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/doc/trpl/getting-started.md b/src/doc/trpl/getting-started.md index 555d40e659706..d0825e543f2c2 100644 --- a/src/doc/trpl/getting-started.md +++ b/src/doc/trpl/getting-started.md @@ -1,5 +1,5 @@ % Getting Started This first section of the book will get you going with Rust and its tooling. -First, we’ll install Rust. Then: the classic ‘Hello World’ program. Finally, +First, we’ll install Rust. Then, the classic ‘Hello World’ program. Finally, we’ll talk about Cargo, Rust’s build system and package manager. diff --git a/src/doc/trpl/glossary.md b/src/doc/trpl/glossary.md index 97898324847e4..9845fcbdcd173 100644 --- a/src/doc/trpl/glossary.md +++ b/src/doc/trpl/glossary.md @@ -19,7 +19,7 @@ In the example above `x` and `y` have arity 2. `z` has arity 3. When a compiler is compiling your program, it does a number of different things. One of the things that it does is turn the text of your program into an -'abstract syntax tree,' or 'AST.' This tree is a representation of the +‘abstract syntax tree’, or‘AST’. This tree is a representation of the structure of your program. For example, `2 + 3` can be turned into a tree: ```text diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index e4af03869d1d8..aca6e327c3bce 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -62,14 +62,14 @@ let y = 1.0; // y has type f64 Here’s a list of the different numeric types, with links to their documentation in the standard library: +* [i8](../std/primitive.i8.html) * [i16](../std/primitive.i16.html) * [i32](../std/primitive.i32.html) * [i64](../std/primitive.i64.html) -* [i8](../std/primitive.i8.html) +* [u8](../std/primitive.u8.html) * [u16](../std/primitive.u16.html) * [u32](../std/primitive.u32.html) * [u64](../std/primitive.u64.html) -* [u8](../std/primitive.u8.html) * [isize](../std/primitive.isize.html) * [usize](../std/primitive.usize.html) * [f32](../std/primitive.f32.html) @@ -82,12 +82,12 @@ Let’s go over them by category: Integer types come in two varieties: signed and unsigned. To understand the difference, let’s consider a number with four bits of size. A signed, four-bit number would let you store numbers from `-8` to `+7`. Signed numbers use -‘two’s compliment representation’. An unsigned four bit number, since it does +“two’s compliment representation”. An unsigned four bit number, since it does not need to store negatives, can store values from `0` to `+15`. Unsigned types use a `u` for their category, and signed types use `i`. The `i` is for ‘integer’. So `u8` is an eight-bit unsigned number, and `i8` is an -eight-bit signed number. +eight-bit signed number. ## Fixed size types @@ -103,7 +103,7 @@ and unsigned varieties. This makes for two types: `isize` and `usize`. ## Floating-point types -Rust also two floating point types: `f32` and `f64`. These correspond to +Rust also has two floating point types: `f32` and `f64`. These correspond to IEEE-754 single and double precision numbers. # Arrays @@ -241,8 +241,8 @@ println!("x is {}", x); Remember [before][let] when I said the left-hand side of a `let` statement was more powerful than just assigning a binding? Here we are. We can put a pattern on the left-hand side of the `let`, and if it matches up to the right-hand side, -we can assign multiple bindings at once. In this case, `let` "destructures," -or "breaks up," the tuple, and assigns the bits to three bindings. +we can assign multiple bindings at once. In this case, `let` “destructures” +or “breaks up” the tuple, and assigns the bits to three bindings. [let]: variable-bindings.html diff --git a/src/doc/trpl/variable-bindings.md b/src/doc/trpl/variable-bindings.md index d971e557a9a2e..0ee34d4b91d03 100644 --- a/src/doc/trpl/variable-bindings.md +++ b/src/doc/trpl/variable-bindings.md @@ -1,6 +1,6 @@ % Variable Bindings -Vitually every non-’Hello World’ Rust program uses *variable bindings*. They +Virtually every non-‘Hello World’Rust program uses *variable bindings*. They look like this: ```rust From b66f858e8f7902ff9e293b10ce9439cb25d4ad6e Mon Sep 17 00:00:00 2001 From: Conrad Kleinespel Date: Sat, 25 Apr 2015 13:43:26 +0200 Subject: [PATCH 6/8] fix compiler plugins path in doc/reference.md --- src/doc/reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 059da89192576..787f59948e230 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1976,7 +1976,7 @@ For any lint check `C`: The lint checks supported by the compiler can be found via `rustc -W help`, along with their default settings. [Compiler -plugins](book/plugins.html#lint-plugins) can provide additional lint checks. +plugins](book/compiler-plugins.html#lint-plugins) can provide additional lint checks. ```{.ignore} mod m1 { @@ -3646,4 +3646,4 @@ that have since been removed): pattern syntax [ffi]: book/ffi.html -[plugin]: book/plugins.html +[plugin]: book/compiler-plugins.html From 702f17566c7f4decdc9cfb4f67a03fe5b10f6454 Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Sat, 25 Apr 2015 14:37:18 +0200 Subject: [PATCH 7/8] Audit reference manual: 3.2 Special unicode productions Mention non_ascii_idents feature gate and remove unused productions --- src/doc/reference.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 2f7ec6a999e1d..73a817eded49e 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -103,12 +103,14 @@ explicit codepoint lists. [^inputformat] ## Special Unicode Productions The following productions in the Rust grammar are defined in terms of Unicode -properties: `ident`, `non_null`, `non_star`, `non_eol`, `non_slash_or_star`, -`non_single_quote` and `non_double_quote`. +properties: `ident`, `non_null`, `non_eol`, `non_single_quote` and `non_double_quote`. ### Identifiers -The `ident` production is any nonempty Unicode string of the following form: +The `ident` production is any nonempty Unicode[^non_ascii_idents] string of the following form: + +[^non_ascii_idents]: Non-ASCII characters in identifiers are currently feature + gated. This is expected to improve soon. - The first character has property `XID_start` - The remaining characters have property `XID_continue` @@ -125,8 +127,6 @@ Some productions are defined by exclusion of particular Unicode characters: - `non_null` is any single Unicode character aside from `U+0000` (null) - `non_eol` is `non_null` restricted to exclude `U+000A` (`'\n'`) -- `non_star` is `non_null` restricted to exclude `U+002A` (`*`) -- `non_slash_or_star` is `non_null` restricted to exclude `U+002F` (`/`) and `U+002A` (`*`) - `non_single_quote` is `non_null` restricted to exclude `U+0027` (`'`) - `non_double_quote` is `non_null` restricted to exclude `U+0022` (`"`) From 3e67b6bb6c5383674f58a637f93d6740bca6a7d7 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 25 Apr 2015 22:33:19 +0530 Subject: [PATCH 8/8] add import (fixup #24649) --- src/libstd/path.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index a52a3dbbef9a5..2ceb60cc3aa9f 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1245,6 +1245,8 @@ impl Path { /// You can create `Path`s from `String`s, or even other `Path`s: /// /// ``` + /// use std::path::Path; + /// /// let s = String::from("bar.txt"); /// let p = Path::new(&s); /// Path::new(&p);