diff --git a/src/doc/reference.md b/src/doc/reference.md index 13f5e391e423..964ef7ca5200 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -68,12 +68,14 @@ explicit code point 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` @@ -90,8 +92,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` (`"`) @@ -1977,7 +1977,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 { @@ -3647,4 +3647,4 @@ that have since been removed): pattern syntax [ffi]: book/ffi.html -[plugin]: book/plugins.html +[plugin]: book/compiler-plugins.html diff --git a/src/doc/trpl/README.md b/src/doc/trpl/README.md index 01ef88dde227..a892f67d571a 100644 --- a/src/doc/trpl/README.md +++ b/src/doc/trpl/README.md @@ -8,7 +8,7 @@ good at: embedding in other languages, programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems. It improves on current languages targeting this space by having a number of compile-time safety checks that produce no runtime overhead, while -eliminating all data races. Rust also aims to achieve ‘zero-cost abstrations’ +eliminating all data races. Rust also aims to achieve ‘zero-cost abstractions’ even though some of these abstractions feel like those of a high-level language. Even then, Rust still allows precise control like a low-level language would. diff --git a/src/doc/trpl/closures.md b/src/doc/trpl/closures.md index 604dcb739df6..d7fa84761e52 100644 --- a/src/doc/trpl/closures.md +++ b/src/doc/trpl/closures.md @@ -294,7 +294,7 @@ is `Fn(i32) -> i32`. There’s one other key point here: because we’re bounding a generic with a trait, this will get monomorphized, and therefore, we’ll be doing static -dispatch into the closure. That’s pretty neat. In many langauges, closures are +dispatch into the closure. That’s pretty neat. In many languages, closures are inherently heap allocated, and will always involve dynamic dispatch. In Rust, we can stack allocate our closure environment, and statically dispatch the call. This happens quite often with iterators and their adapters, which often diff --git a/src/doc/trpl/documentation.md b/src/doc/trpl/documentation.md index 732521a0c606..b28343e7fb94 100644 --- a/src/doc/trpl/documentation.md +++ b/src/doc/trpl/documentation.md @@ -556,7 +556,7 @@ This sets a few different options, with a logo, favicon, and a root URL. ## Generation options -`rustdoc` also contains a few other options on the command line, for further customiziation: +`rustdoc` also contains a few other options on the command line, for further customization: - `--html-in-header FILE`: includes the contents of FILE at the end of the `...` section. diff --git a/src/doc/trpl/getting-started.md b/src/doc/trpl/getting-started.md index 555d40e65970..d0825e543f2c 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 97898324847e..9845fcbdcd17 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/mutability.md b/src/doc/trpl/mutability.md index e7506dfe4fd7..816bfb179706 100644 --- a/src/doc/trpl/mutability.md +++ b/src/doc/trpl/mutability.md @@ -129,7 +129,7 @@ about it first. ## Field-level mutability -Mutabilty is a property of either a borrow (`&mut`) or a binding (`let mut`). +Mutability is a property of either a borrow (`&mut`) or a binding (`let mut`). This means that, for example, you cannot have a [`struct`][struct] with some fields mutable and some immutable: diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index e4af03869d1d..aca6e327c3bc 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/trait-objects.md b/src/doc/trpl/trait-objects.md index 52f8cb335a93..c01129057418 100644 --- a/src/doc/trpl/trait-objects.md +++ b/src/doc/trpl/trait-objects.md @@ -155,7 +155,7 @@ A function that takes a trait object is not specialized to each of the types that implements `Foo`: only one copy is generated, often (but not always) resulting in less code bloat. However, this comes at the cost of requiring slower virtual function calls, and effectively inhibiting any chance of -inlining and related optimisations from occurring. +inlining and related optimizations from occurring. ### Why pointers? diff --git a/src/doc/trpl/traits.md b/src/doc/trpl/traits.md index 3e77d3c603ba..ea5d2ed711fe 100644 --- a/src/doc/trpl/traits.md +++ b/src/doc/trpl/traits.md @@ -184,7 +184,7 @@ won’t have its methods: ```rust,ignore let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt"); let result = f.write("whatever".as_bytes()); -# result.unwrap(); // ignore the erorr +# result.unwrap(); // ignore the error ``` Here’s the error: @@ -203,7 +203,7 @@ use std::io::Write; let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt"); let result = f.write("whatever".as_bytes()); -# result.unwrap(); // ignore the erorr +# result.unwrap(); // ignore the error ``` This will compile without error. diff --git a/src/doc/trpl/variable-bindings.md b/src/doc/trpl/variable-bindings.md index d971e557a9a2..2166c046897f 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 diff --git a/src/libstd/path.rs b/src/libstd/path.rs index e8052041aeb3..2ceb60cc3aa9 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1241,6 +1241,16 @@ fn as_u8_slice(&self) -> &[u8] { /// /// Path::new("foo.txt"); /// ``` + /// + /// 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); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new + ?Sized>(s: &S) -> &Path { unsafe { mem::transmute(s.as_ref()) }