Rollup merge of #24812 - jest:master, r=steveklabnik
Conflicts: src/doc/trpl/variable-bindings.md
This commit is contained in:
commit
9316b0382b
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
`<head>...</head>` section.
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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?
|
||||
|
||||
|
@ -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.
|
||||
|
@ -1,6 +1,6 @@
|
||||
% Variable Bindings
|
||||
|
||||
Virtually 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user