From 1162b3752c71515a01875e0c9cef67ec9d7aca46 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Tue, 13 Oct 2015 09:44:11 -0400 Subject: [PATCH 1/9] Correct spelling in docs --- COMPILER_TESTS.md | 2 +- src/doc/complement-lang-faq.md | 2 +- src/doc/nomicon/casts.md | 4 ++-- src/doc/nomicon/dropck.md | 2 +- src/doc/nomicon/exotic-sizes.md | 4 ++-- src/doc/nomicon/leaking.md | 4 ++-- src/doc/nomicon/meet-safe-and-unsafe.md | 14 +++++++------- src/doc/nomicon/races.md | 4 ++-- src/doc/nomicon/safe-unsafe-meaning.md | 6 +++--- src/doc/nomicon/send-and-sync.md | 2 +- src/doc/nomicon/transmutes.md | 4 ++-- src/doc/nomicon/unbounded-lifetimes.md | 4 ++-- src/doc/nomicon/unchecked-uninit.md | 2 +- src/doc/nomicon/uninitialized.md | 4 ++-- src/doc/nomicon/unwinding.md | 2 +- src/doc/nomicon/vec-layout.md | 2 +- src/doc/nomicon/vec-push-pop.md | 2 +- src/doc/nomicon/vec-zsts.md | 2 +- src/doc/reference.md | 4 ++-- src/doc/style/features/modules.md | 10 +++++----- src/doc/style/features/traits/reuse.md | 2 +- src/doc/trpl/dining-philosophers.md | 2 +- src/doc/trpl/syntax-index.md | 8 ++++---- src/doc/trpl/variable-bindings.md | 2 +- src/liballoc/raw_vec.rs | 10 +++++----- src/libcollections/btree/map.rs | 2 +- src/libcollections/btree/node.rs | 2 +- src/libcore/fmt/mod.rs | 8 ++++---- src/libcore/intrinsics.rs | 2 +- src/libcore/iter.rs | 2 +- src/libcore/macros.rs | 2 +- src/libcore/marker.rs | 4 ++-- src/libcore/mem.rs | 12 ++++++------ src/libcore/ptr.rs | 4 ++-- src/libcore/raw.rs | 2 +- src/libcore/str/mod.rs | 2 +- src/libfmt_macros/lib.rs | 2 +- src/libgraphviz/lib.rs | 4 ++-- src/librand/distributions/gamma.rs | 2 +- src/libstd/collections/hash/map.rs | 4 ++-- src/libstd/lib.rs | 2 +- src/libstd/net/tcp.rs | 2 +- src/libstd/process.rs | 2 +- 43 files changed, 82 insertions(+), 82 deletions(-) diff --git a/COMPILER_TESTS.md b/COMPILER_TESTS.md index 0606686fcfb10..e2a957e396191 100644 --- a/COMPILER_TESTS.md +++ b/COMPILER_TESTS.md @@ -1,6 +1,6 @@ # Compiler Test Documentation -In the Rust project, we use a special set of comands embedded in +In the Rust project, we use a special set of commands embedded in comments to test the Rust compiler. There are two groups of commands: 1. Header commands diff --git a/src/doc/complement-lang-faq.md b/src/doc/complement-lang-faq.md index 8b9467589c654..05c17606ce034 100644 --- a/src/doc/complement-lang-faq.md +++ b/src/doc/complement-lang-faq.md @@ -76,7 +76,7 @@ Cleanup through RAII-style destructors is more likely to work than in catch bloc ## Why aren't modules type-parametric? -We want to maintain the option to parametrize at runtime. We may eventually change this limitation, but initially this is how type parameters were implemented. +We want to maintain the option to parameterize at runtime. We may eventually change this limitation, but initially this is how type parameters were implemented. ## Why aren't values type-parametric? Why only items? diff --git a/src/doc/nomicon/casts.md b/src/doc/nomicon/casts.md index 5f07709cf4542..6cc41bd9533c7 100644 --- a/src/doc/nomicon/casts.md +++ b/src/doc/nomicon/casts.md @@ -52,7 +52,7 @@ For numeric casts, there are quite a few cases to consider: * zero-extend if the source is unsigned * sign-extend if the source is signed * casting from a float to an integer will round the float towards zero - * **[NOTE: currently this will cause Undefined Behaviour if the rounded + * **[NOTE: currently this will cause Undefined Behavior if the rounded value cannot be represented by the target integer type][float-int]**. This includes Inf and NaN. This is a bug and will be fixed. * casting from an integer to float will produce the floating point @@ -61,7 +61,7 @@ For numeric casts, there are quite a few cases to consider: * casting from an f32 to an f64 is perfect and lossless * casting from an f64 to an f32 will produce the closest possible value (rounding strategy unspecified) - * **[NOTE: currently this will cause Undefined Behaviour if the value + * **[NOTE: currently this will cause Undefined Behavior if the value is finite but larger or smaller than the largest or smallest finite value representable by f32][float-float]**. This is a bug and will be fixed. diff --git a/src/doc/nomicon/dropck.md b/src/doc/nomicon/dropck.md index 7c097c9126679..95bcdc02ba029 100644 --- a/src/doc/nomicon/dropck.md +++ b/src/doc/nomicon/dropck.md @@ -6,7 +6,7 @@ interacted with the *outlives* relationship in an inclusive manner. That is, when we talked about `'a: 'b`, it was ok for `'a` to live *exactly* as long as `'b`. At first glance, this seems to be a meaningless distinction. Nothing ever gets dropped at the same time as another, right? This is why we used the -following desugarring of `let` statements: +following desugaring of `let` statements: ```rust,ignore let x; diff --git a/src/doc/nomicon/exotic-sizes.md b/src/doc/nomicon/exotic-sizes.md index e8637e38ac7d5..052e3c5fddc55 100644 --- a/src/doc/nomicon/exotic-sizes.md +++ b/src/doc/nomicon/exotic-sizes.md @@ -20,7 +20,7 @@ information that "completes" them (more on this below). There are two major DSTs exposed by the language: trait objects, and slices. A trait object represents some type that implements the traits it specifies. -The exact original type is *erased* in favour of runtime reflection +The exact original type is *erased* in favor of runtime reflection with a vtable containing all the information necessary to use the type. This is the information that completes a trait object: a pointer to its vtable. @@ -128,7 +128,7 @@ But neither of these tricks work today, so all Void types get you is the ability to be confident that certain situations are statically impossible. One final subtle detail about empty types is that raw pointers to them are -actually valid to construct, but dereferencing them is Undefined Behaviour +actually valid to construct, but dereferencing them is Undefined Behavior because that doesn't actually make sense. That is, you could model C's `void *` type with `*const Void`, but this doesn't necessarily gain anything over using e.g. `*const ()`, which *is* safe to randomly dereference. diff --git a/src/doc/nomicon/leaking.md b/src/doc/nomicon/leaking.md index 445349b406593..1f72a4c172470 100644 --- a/src/doc/nomicon/leaking.md +++ b/src/doc/nomicon/leaking.md @@ -90,7 +90,7 @@ let mut vec = vec![Box::new(0); 4]; println!("{}", vec[0]); ``` -This is pretty clearly Not Good. Unfortunately, we're kind've stuck between a +This is pretty clearly Not Good. Unfortunately, we're kind of stuck between a rock and a hard place: maintaining consistent state at every step has an enormous cost (and would negate any benefits of the API). Failing to maintain consistent state gives us Undefined Behavior in safe code (making the API @@ -248,4 +248,4 @@ let mut data = Box::new(0); ``` Dang. Here the destructor running was pretty fundamental to the API, and it had -to be scrapped in favour of a completely different design. +to be scrapped in favor of a completely different design. diff --git a/src/doc/nomicon/meet-safe-and-unsafe.md b/src/doc/nomicon/meet-safe-and-unsafe.md index 52582e8750b46..978d0518729ea 100644 --- a/src/doc/nomicon/meet-safe-and-unsafe.md +++ b/src/doc/nomicon/meet-safe-and-unsafe.md @@ -26,7 +26,7 @@ do some really crazy unsafe things. Safe Rust is the *true* Rust programming language. If all you do is write Safe Rust, you will never have to worry about type-safety or memory-safety. You will -never endure a null or dangling pointer, or any of that Undefined Behaviour +never endure a null or dangling pointer, or any of that Undefined Behavior nonsense. *That's totally awesome.* @@ -52,11 +52,11 @@ The only things that are different in Unsafe Rust are that you can: * Mutate statics That's it. The reason these operations are relegated to Unsafe is that misusing -any of these things will cause the ever dreaded Undefined Behaviour. Invoking -Undefined Behaviour gives the compiler full rights to do arbitrarily bad things -to your program. You definitely *should not* invoke Undefined Behaviour. +any of these things will cause the ever dreaded Undefined Behavior. Invoking +Undefined Behavior gives the compiler full rights to do arbitrarily bad things +to your program. You definitely *should not* invoke Undefined Behavior. -Unlike C, Undefined Behaviour is pretty limited in scope in Rust. All the core +Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core language cares about is preventing the following things: * Dereferencing null or dangling pointers @@ -71,9 +71,9 @@ language cares about is preventing the following things: * Unwinding into another language * Causing a [data race][race] -That's it. That's all the causes of Undefined Behaviour baked into Rust. Of +That's it. That's all the causes of Undefined Behavior baked into Rust. Of course, unsafe functions and traits are free to declare arbitrary other -constraints that a program must maintain to avoid Undefined Behaviour. However, +constraints that a program must maintain to avoid Undefined Behavior. However, generally violations of these constraints will just transitively lead to one of the above problems. Some additional constraints may also derive from compiler intrinsics that make special assumptions about how code can be optimized. diff --git a/src/doc/nomicon/races.md b/src/doc/nomicon/races.md index 3b47502ebfe79..f0732cf26562c 100644 --- a/src/doc/nomicon/races.md +++ b/src/doc/nomicon/races.md @@ -6,7 +6,7 @@ Safe Rust guarantees an absence of data races, which are defined as: * one of them is a write * one of them is unsynchronized -A data race has Undefined Behaviour, and is therefore impossible to perform +A data race has Undefined Behavior, and is therefore impossible to perform in Safe Rust. Data races are *mostly* prevented through rust's ownership system: it's impossible to alias a mutable reference, so it's impossible to perform a data race. Interior mutability makes this more complicated, which is largely why @@ -53,7 +53,7 @@ thread::spawn(move || { // bounds checked, and there's no chance of the value getting changed // in the middle. However our program may panic if the thread we spawned // managed to increment before this ran. A race condition because correct -// program execution (panicing is rarely correct) depends on order of +// program execution (panicking is rarely correct) depends on order of // thread execution. println!("{}", data[idx.load(Ordering::SeqCst)]); ``` diff --git a/src/doc/nomicon/safe-unsafe-meaning.md b/src/doc/nomicon/safe-unsafe-meaning.md index 3cb02d31b175f..f5d7023fad5de 100644 --- a/src/doc/nomicon/safe-unsafe-meaning.md +++ b/src/doc/nomicon/safe-unsafe-meaning.md @@ -41,7 +41,7 @@ Some examples of unsafe functions: * `slice::get_unchecked` will perform unchecked indexing, allowing memory safety to be freely violated. -* `ptr::offset` is an intrinsic that invokes Undefined Behaviour if it is +* `ptr::offset` is an intrinsic that invokes Undefined Behavior if it is not "in bounds" as defined by LLVM. * `mem::transmute` reinterprets some value as having the given type, bypassing type safety in arbitrary ways. (see [conversions] for details) @@ -59,9 +59,9 @@ As of Rust 1.0 there are exactly two unsafe traits: The need for unsafe traits boils down to the fundamental property of safe code: **No matter how completely awful Safe code is, it can't cause Undefined -Behaviour.** +Behavior.** -This means that Unsafe Rust, **the royal vanguard of Undefined Behaviour**, has to be +This means that Unsafe Rust, **the royal vanguard of Undefined Behavior**, has to be *super paranoid* about generic safe code. To be clear, Unsafe Rust is totally free to trust specific safe code. Anything else would degenerate into infinite spirals of paranoid despair. In particular it's generally regarded as ok to trust the standard library diff --git a/src/doc/nomicon/send-and-sync.md b/src/doc/nomicon/send-and-sync.md index 9ab60d03fca7e..134e47f18dcf0 100644 --- a/src/doc/nomicon/send-and-sync.md +++ b/src/doc/nomicon/send-and-sync.md @@ -15,7 +15,7 @@ implement, and other unsafe code can assume that they are correctly implemented. Since they're *marker traits* (they have no associated items like methods), correctly implemented simply means that they have the intrinsic properties an implementor should have. Incorrectly implementing Send or Sync can -cause Undefined Behaviour. +cause Undefined Behavior. Send and Sync are also automatically derived traits. This means that, unlike every other trait, if a type is composed entirely of Send or Sync types, then it diff --git a/src/doc/nomicon/transmutes.md b/src/doc/nomicon/transmutes.md index 2b34ad0a9fad1..f1478b7f668d3 100644 --- a/src/doc/nomicon/transmutes.md +++ b/src/doc/nomicon/transmutes.md @@ -8,7 +8,7 @@ horribly unsafe thing you can do in Rust. The railguards here are dental floss. `mem::transmute` takes a value of type `T` and reinterprets it to have type `U`. The only restriction is that the `T` and `U` are verified to have the -same size. The ways to cause Undefined Behaviour with this are mind boggling. +same size. The ways to cause Undefined Behavior with this are mind boggling. * First and foremost, creating an instance of *any* type with an invalid state is going to cause arbitrary chaos that can't really be predicted. @@ -26,7 +26,7 @@ same size. The ways to cause Undefined Behaviour with this are mind boggling. `mem::transmute_copy` somehow manages to be *even more* wildly unsafe than this. It copies `size_of` bytes out of an `&T` and interprets them as a `U`. The size check that `mem::transmute` has is gone (as it may be valid to copy -out a prefix), though it is Undefined Behaviour for `U` to be larger than `T`. +out a prefix), though it is Undefined Behavior for `U` to be larger than `T`. Also of course you can get most of the functionality of these functions using pointer casts. diff --git a/src/doc/nomicon/unbounded-lifetimes.md b/src/doc/nomicon/unbounded-lifetimes.md index b540ab4ed5d99..2c5ba79a5078f 100644 --- a/src/doc/nomicon/unbounded-lifetimes.md +++ b/src/doc/nomicon/unbounded-lifetimes.md @@ -2,7 +2,7 @@ Unsafe code can often end up producing references or lifetimes out of thin air. Such lifetimes come into the world as *unbounded*. The most common source of this -is derefencing a raw pointer, which produces a reference with an unbounded lifetime. +is dereferencing a raw pointer, which produces a reference with an unbounded lifetime. Such a lifetime becomes as big as context demands. This is in fact more powerful than simply becoming `'static`, because for instance `&'static &'a T` will fail to typecheck, but the unbound lifetime will perfectly mold into @@ -10,7 +10,7 @@ will fail to typecheck, but the unbound lifetime will perfectly mold into lifetime can be regarded as `'static`. Almost no reference is `'static`, so this is probably wrong. `transmute` and -`transmute_copy` are the two other primary offenders. One should endeavour to +`transmute_copy` are the two other primary offenders. One should endeavor to bound an unbounded lifetime as quick as possible, especially across function boundaries. diff --git a/src/doc/nomicon/unchecked-uninit.md b/src/doc/nomicon/unchecked-uninit.md index 5ae1818dc6306..c72ed8a763299 100644 --- a/src/doc/nomicon/unchecked-uninit.md +++ b/src/doc/nomicon/unchecked-uninit.md @@ -38,7 +38,7 @@ dropping the old value: `write`, `copy`, and `copy_nonoverlapping`. (this is equivalent to memcpy -- note that the argument order is reversed!) It should go without saying that these functions, if misused, will cause serious -havoc or just straight up Undefined Behaviour. The only things that these +havoc or just straight up Undefined Behavior. The only things that these functions *themselves* require is that the locations you want to read and write are allocated. However the ways writing arbitrary bits to arbitrary locations of memory can break things are basically uncountable! diff --git a/src/doc/nomicon/uninitialized.md b/src/doc/nomicon/uninitialized.md index 915ea8602918e..05615d89bec77 100644 --- a/src/doc/nomicon/uninitialized.md +++ b/src/doc/nomicon/uninitialized.md @@ -4,7 +4,7 @@ All runtime-allocated memory in a Rust program begins its life as *uninitialized*. In this state the value of the memory is an indeterminate pile of bits that may or may not even reflect a valid state for the type that is supposed to inhabit that location of memory. Attempting to interpret this memory -as a value of *any* type will cause Undefined Behaviour. Do Not Do This. +as a value of *any* type will cause Undefined Behavior. Do Not Do This. Rust provides mechanisms to work with uninitialized memory in checked (safe) and -unchecked (unsafe) ways. \ No newline at end of file +unchecked (unsafe) ways. diff --git a/src/doc/nomicon/unwinding.md b/src/doc/nomicon/unwinding.md index 3ad95dde39ded..e81f06b83b249 100644 --- a/src/doc/nomicon/unwinding.md +++ b/src/doc/nomicon/unwinding.md @@ -42,7 +42,7 @@ should only panic for programming errors or *extreme* problems. Rust's unwinding strategy is not specified to be fundamentally compatible with any other language's unwinding. As such, unwinding into Rust from another -language, or unwinding into another language from Rust is Undefined Behaviour. +language, or unwinding into another language from Rust is Undefined Behavior. You must *absolutely* catch any panics at the FFI boundary! What you do at that point is up to you, but *something* must be done. If you fail to do this, at best, your application will crash and burn. At worst, your application *won't* diff --git a/src/doc/nomicon/vec-layout.md b/src/doc/nomicon/vec-layout.md index 3df63d5249c55..7ca369da0b886 100644 --- a/src/doc/nomicon/vec-layout.md +++ b/src/doc/nomicon/vec-layout.md @@ -93,7 +93,7 @@ pub struct Vec { If you don't care about the null-pointer optimization, then you can use the stable code. However we will be designing the rest of the code around enabling the optimization. In particular, `Unique::new` is unsafe to call, because -putting `null` inside of it is Undefined Behaviour. Our stable Unique doesn't +putting `null` inside of it is Undefined Behavior. Our stable Unique doesn't need `new` to be unsafe because it doesn't make any interesting guarantees about its contents. diff --git a/src/doc/nomicon/vec-push-pop.md b/src/doc/nomicon/vec-push-pop.md index b518e8aa48ffb..5e747a8c71d41 100644 --- a/src/doc/nomicon/vec-push-pop.md +++ b/src/doc/nomicon/vec-push-pop.md @@ -34,7 +34,7 @@ Easy! How about `pop`? Although this time the index we want to access is initialized, Rust won't just let us dereference the location of memory to move the value out, because that would leave the memory uninitialized! For this we need `ptr::read`, which just copies out the bits from the target address and -intrprets it as a value of type T. This will leave the memory at this address +interprets it as a value of type T. This will leave the memory at this address logically uninitialized, even though there is in fact a perfectly good instance of T there. diff --git a/src/doc/nomicon/vec-zsts.md b/src/doc/nomicon/vec-zsts.md index 9b1abf383f717..fb337a891a8d4 100644 --- a/src/doc/nomicon/vec-zsts.md +++ b/src/doc/nomicon/vec-zsts.md @@ -1,6 +1,6 @@ % Handling Zero-Sized Types -It's time. We're going to fight the spectre that is zero-sized types. Safe Rust +It's time. We're going to fight the specter that is zero-sized types. Safe Rust *never* needs to care about this, but Vec is very intensive on raw pointers and raw allocations, which are exactly the two things that care about zero-sized types. We need to be careful of two things: diff --git a/src/doc/reference.md b/src/doc/reference.md index 9ce191ee5897f..3032fa7116fe4 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3706,7 +3706,7 @@ repeated sub-expression is a coercion site for coercion to type `U`. Each sub-expression is a coercion site to the respective type, e.g. the zeroth sub-expression is a coercion site to type `U_0`. -* Parenthesised sub-expressions (`(e)`): if the expression has type `U`, then +* Parenthesized sub-expressions (`(e)`): if the expression has type `U`, then the sub-expression is a coercion site to `U`. * Blocks: if a block has type `U`, then the last expression in the block (if @@ -4072,7 +4072,7 @@ that have since been removed): * SML, OCaml: algebraic data types, pattern matching, type inference, semicolon statement separation -* C++: references, RAII, smart pointers, move semantics, monomorphisation, +* C++: references, RAII, smart pointers, move semantics, monomorphization, memory model * ML Kit, Cyclone: region based memory management * Haskell (GHC): typeclasses, type families diff --git a/src/doc/style/features/modules.md b/src/doc/style/features/modules.md index 23d8760f571f6..c55b38b915b3d 100644 --- a/src/doc/style/features/modules.md +++ b/src/doc/style/features/modules.md @@ -17,12 +17,12 @@ Organize module headers as follows: Avoid using `#[path="..."]` directives; make the file system and module hierarchy match, instead. -### Use the module hirearchy to organize APIs into coherent sections. [FIXME] +### Use the module hierarchy to organize APIs into coherent sections. [FIXME] > **[FIXME]** Flesh this out with examples; explain what a "coherent > section" is with examples. > -> The module hirearchy defines both the public and internal API of your module. +> The module hierarchy defines both the public and internal API of your module. > Breaking related functionality into submodules makes it understandable to both > users and contributors to the module. @@ -82,7 +82,7 @@ io/mod.rs ``` While it is possible to define all of `io` within a single directory, -mirroring the module hirearchy in the directory structure makes +mirroring the module hierarchy in the directory structure makes submodules of `io::net` easier to find. ### Consider top-level definitions or reexports. [FIXME: needs RFC] @@ -104,13 +104,13 @@ while [`TcpStream`](https://doc.rust-lang.org/std/io/net/tcp/struct.TcpStream.html) is defined in `io/net/tcp.rs` and reexported in the `io` module. -### Use internal module hirearchies for organization. [FIXME: needs RFC] +### Use internal module hierarchies for organization. [FIXME: needs RFC] > **[FIXME]** > - Referencing internal modules from the standard library is subject to > becoming outdated. -Internal module hirearchies (i.e., private submodules) may be used to +Internal module hierarchies (i.e., private submodules) may be used to hide implementation details that are not part of the module's API. For example, in [`std::io`](https://doc.rust-lang.org/std/io/), `mod mem` diff --git a/src/doc/style/features/traits/reuse.md b/src/doc/style/features/traits/reuse.md index 61f8db87cde89..feedd3937fc9d 100644 --- a/src/doc/style/features/traits/reuse.md +++ b/src/doc/style/features/traits/reuse.md @@ -5,7 +5,7 @@ > **[FIXME]** We probably want to discourage this, at least when used in a way > that is publicly exposed. -Traits that provide default implmentations for function can provide code reuse +Traits that provide default implementations for function can provide code reuse across types. For example, a `print` method can be defined across multiple types as follows: diff --git a/src/doc/trpl/dining-philosophers.md b/src/doc/trpl/dining-philosophers.md index 5c4e6c0b9dc2a..28702d95b60a7 100644 --- a/src/doc/trpl/dining-philosophers.md +++ b/src/doc/trpl/dining-philosophers.md @@ -13,7 +13,7 @@ Hoare in 1985. > dining room, furnished with a circular table, surrounded by five chairs, each > labelled by the name of the philosopher who was to sit in it. They sat > anticlockwise around the table. To the left of each philosopher there was -> laid a golden fork, and in the centre stood a large bowl of spaghetti, which +> laid a golden fork, and in the center stood a large bowl of spaghetti, which > was constantly replenished. A philosopher was expected to spend most of > their time thinking; but when they felt hungry, they went to the dining > room, sat down in their own chair, picked up their own fork on their left, diff --git a/src/doc/trpl/syntax-index.md b/src/doc/trpl/syntax-index.md index fd8086efde0ad..7e03bb72cad59 100644 --- a/src/doc/trpl/syntax-index.md +++ b/src/doc/trpl/syntax-index.md @@ -25,7 +25,7 @@ * `pub`: denotes public visibility in `struct` fields, `impl` blocks, and modules. See [Crates and Modules (Exporting a Public Interface)]. * `ref`: by-reference binding. See [Patterns (`ref` and `ref mut`)]. * `return`: return from function. See [Functions (Early Returns)]. -* `Self`: implementer type alias. See [Traits]. +* `Self`: implementor type alias. See [Traits]. * `self`: method subject. See [Method Syntax (Method Calls)]. * `static`: global variable. See [`const` and `static` (`static`)]. * `struct`: structure definition. See [Structs]. @@ -68,7 +68,7 @@ * `/` (`expr / expr`): arithmetic division. Overloadable (`Div`). * `/=` (`var /= expr`): arithmetic division & assignment. * `:` (`pat: type`, `ident: type`): constraints. See [Variable Bindings], [Functions], [Structs], [Traits]. -* `:` (`ident: expr`): struct field initialiser. See [Structs]. +* `:` (`ident: expr`): struct field initializer. See [Structs]. * `:` (`'a: loop {…}`): loop label. See [Loops (Loops Labels)]. * `;`: statement and item terminator. * `;` (`[…; len]`): part of fixed-size array syntax. See [Primitive Types (Arrays)]. @@ -153,12 +153,12 @@ * `()`: empty tuple (*a.k.a.* unit), both literal and type. -* `(expr)`: parenthesised expression. +* `(expr)`: parenthesized expression. * `(expr,)`: single-element tuple expression. See [Primitive Types (Tuples)]. * `(type,)`: single-element tuple type. See [Primitive Types (Tuples)]. * `(expr, …)`: tuple expression. See [Primitive Types (Tuples)]. * `(type, …)`: tuple type. See [Primitive Types (Tuples)]. -* `expr(expr, …)`: function call expression. Also used to initialise tuple `struct`s and tuple `enum` variants. See [Functions]. +* `expr(expr, …)`: function call expression. Also used to initialize tuple `struct`s and tuple `enum` variants. See [Functions]. * `ident!(…)`, `ident!{…}`, `ident![…]`: macro invocation. See [Macros]. * `expr.0`, `expr.1`, …: tuple indexing. See [Primitive Types (Tuple Indexing)]. diff --git a/src/doc/trpl/variable-bindings.md b/src/doc/trpl/variable-bindings.md index 3521c970e72c8..f3a5d1dd886c8 100644 --- a/src/doc/trpl/variable-bindings.md +++ b/src/doc/trpl/variable-bindings.md @@ -221,7 +221,7 @@ Could not compile `hello`. To learn more, run the command again with --verbose. ``` -Additionaly, variable bindings can be shadowed. This means that a later +Additionally, variable bindings can be shadowed. This means that a later variable binding with the same name as another binding, that's currently in scope, will override the previous binding. diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 4df3bacdcb6e6..996a590043a47 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -114,7 +114,7 @@ impl RawVec { /// Reconstitutes a RawVec from a pointer and capacity. /// - /// # Undefined Behaviour + /// # Undefined Behavior /// /// The ptr must be allocated, and with the given capacity. The /// capacity cannot exceed `isize::MAX` (only a concern on 32-bit systems). @@ -248,7 +248,7 @@ impl RawVec { /// /// If `used_cap` exceeds `self.cap()`, this may fail to actually allocate /// the requested space. This is not really unsafe, but the unsafe - /// code *you* write that relies on the behaviour of this function may break. + /// code *you* write that relies on the behavior of this function may break. /// /// # Panics /// @@ -302,12 +302,12 @@ impl RawVec { /// Ensures that the buffer contains at least enough space to hold /// `used_cap + needed_extra_cap` elements. If it doesn't already have /// enough capacity, will reallocate enough space plus comfortable slack - /// space to get amortized `O(1)` behaviour. Will limit this behaviour + /// space to get amortized `O(1)` behavior. Will limit this behavior /// if it would needlessly cause itself to panic. /// /// If `used_cap` exceeds `self.cap()`, this may fail to actually allocate /// the requested space. This is not really unsafe, but the unsafe - /// code *you* write that relies on the behaviour of this function may break. + /// code *you* write that relies on the behavior of this function may break. /// /// This is ideal for implementing a bulk-push operation like `extend`. /// @@ -430,7 +430,7 @@ impl RawVec { /// Converts the entire buffer into `Box<[T]>`. /// - /// While it is not *strictly* Undefined Behaviour to call + /// While it is not *strictly* Undefined Behavior to call /// this procedure while some of the RawVec is unintialized, /// it cetainly makes it trivial to trigger it. /// diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 96d29c7da4abe..59ffc1bd36f82 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -949,7 +949,7 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap } } -/// Genericises over how to get the correct type of iterator from the correct type +/// Genericizes over how to get the correct type of iterator from the correct type /// of Node ownership. trait Traverse { fn traverse(node: N) -> Self; diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index bde0d0e6b5f81..4380f315ee7f1 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -818,7 +818,7 @@ impl Handle where } } - /// Handle an underflow in this node's child. We favour handling "to the left" because we know + /// Handle an underflow in this node's child. We favor handling "to the left" because we know /// we're empty, but our neighbour can be full. Handling to the left means when we choose to /// steal, we pop off the end of our neighbour (always fast) and "unshift" ourselves /// (always slow, but at least faster since we know we're half-empty). diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index f6053a75f1f90..eea21988aa360 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -94,7 +94,7 @@ pub trait Write { self.write_str(unsafe { str::from_utf8_unchecked(&utf_8[..bytes_written]) }) } - /// Glue for usage of the `write!` macro with implementers of this trait. + /// Glue for usage of the `write!` macro with implementors of this trait. /// /// This method should generally not be invoked manually, but rather through /// the `write!` macro itself. @@ -523,7 +523,7 @@ pub trait Binary { /// Format trait for the `x` character. /// -/// The `LowerHex` trait should format its output as a number in hexidecimal, with `a` through `f` +/// The `LowerHex` trait should format its output as a number in hexadecimal, with `a` through `f` /// in lower case. /// /// The alternate flag, `#`, adds a `0x` in front of the output. @@ -571,7 +571,7 @@ pub trait LowerHex { /// Format trait for the `X` character. /// -/// The `UpperHex` trait should format its output as a number in hexidecimal, with `A` through `F` +/// The `UpperHex` trait should format its output as a number in hexadecimal, with `A` through `F` /// in upper case. /// /// The alternate flag, `#`, adds a `0x` in front of the output. @@ -620,7 +620,7 @@ pub trait UpperHex { /// Format trait for the `p` character. /// /// The `Pointer` trait should format its output as a memory location. This is commonly presented -/// as hexidecimal. +/// as hexadecimal. /// /// For more information on formatters, see [the module-level documentation][module]. /// diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 08c017841e3c8..45b1c8a3599ca 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -301,7 +301,7 @@ extern "rust-intrinsic" { /// # Safety /// /// Beyond requiring that the program must be allowed to access both regions - /// of memory, it is Undefined Behaviour for source and destination to + /// of memory, it is Undefined Behavior for source and destination to /// overlap. Care must also be taken with the ownership of `src` and /// `dst`. This method semantically moves the values of `src` into `dst`. /// However it does not drop the contents of `dst`, or prevent the contents diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2f12579d67411..5e888dce1ec6d 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1453,7 +1453,7 @@ pub trait Iterator { /// /// This is an idiosyncratic helper to try to factor out the /// commonalities of {max,min}{,_by}. In particular, this avoids -/// having to implement optimisations several times. +/// having to implement optimizations several times. #[inline] fn select_fold1(mut it: I, mut f_proj: FProj, diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 58e0bb37b0a97..bb112327abf4b 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -279,7 +279,7 @@ macro_rules! unreachable { }); } -/// A standardised placeholder for marking unfinished code. It panics with the +/// A standardized placeholder for marking unfinished code. It panics with the /// message `"not yet implemented"` when executed. /// /// This can be useful if you are prototyping and are just looking to have your diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index bf95ce868500b..f9480b4349d11 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -172,7 +172,7 @@ pub trait Copy : Clone { /// /// A somewhat surprising consequence of the definition is `&mut T` is /// `Sync` (if `T` is `Sync`) even though it seems that it might -/// provide unsynchronised mutation. The trick is a mutable reference +/// provide unsynchronized mutation. The trick is a mutable reference /// stored in an aliasable reference (that is, `& &mut T`) becomes /// read-only, as if it were a `& &T`, hence there is no risk of a data /// race. @@ -195,7 +195,7 @@ pub trait Copy : Clone { /// /// Any types with interior mutability must also use the `std::cell::UnsafeCell` /// wrapper around the value(s) which can be mutated when behind a `&` -/// reference; not doing this is undefined behaviour (for example, +/// reference; not doing this is undefined behavior (for example, /// `transmute`-ing from `&T` to `&mut T` is invalid). #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sync"] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 193b8d6d620de..a87d135e42592 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -37,7 +37,7 @@ pub use intrinsics::transmute; /// * You have two copies of a value (like when writing something like /// [`mem::swap`][swap]), but need the destructor to only run once to /// prevent a double `free`. -/// * Transferring resources across [FFI][ffi] boundries. +/// * Transferring resources across [FFI][ffi] boundaries. /// /// [swap]: fn.swap.html /// [ffi]: ../../book/ffi.html @@ -264,9 +264,9 @@ pub unsafe fn dropped() -> T { /// This is useful for FFI functions and initializing arrays sometimes, /// but should generally be avoided. /// -/// # Undefined Behaviour +/// # Undefined Behavior /// -/// It is Undefined Behaviour to read uninitialized memory. Even just an +/// It is Undefined Behavior to read uninitialized memory. Even just an /// uninitialized boolean. For instance, if you branch on the value of such /// a boolean your program may take one, both, or neither of the branches. /// @@ -303,7 +303,7 @@ pub unsafe fn dropped() -> T { /// /// // DANGER ZONE: if anything panics or otherwise /// // incorrectly reads the array here, we will have -/// // Undefined Behaviour. +/// // Undefined Behavior. /// /// // It's ok to mutably iterate the data, since this /// // doesn't involve reading it at all. @@ -340,7 +340,7 @@ pub unsafe fn uninitialized() -> T { intrinsics::uninit() } -/// Swap the values at two mutable locations of the same type, without deinitialising or copying +/// Swap the values at two mutable locations of the same type, without deinitializing or copying /// either one. /// /// # Examples @@ -376,7 +376,7 @@ pub fn swap(x: &mut T, y: &mut T) { } /// Replaces the value at a mutable location with a new one, returning the old value, without -/// deinitialising or copying either one. +/// deinitializing or copying either one. /// /// This is primarily used for transferring and swapping ownership of a value in a mutable /// location. diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 4ca32b5a366a6..960240d7f5fc8 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -69,7 +69,7 @@ pub const fn null() -> *const T { 0 as *const T } pub const fn null_mut() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without -/// deinitialising either. They may overlap, unlike `mem::swap` which is +/// deinitializing either. They may overlap, unlike `mem::swap` which is /// otherwise equivalent. /// /// # Safety @@ -247,7 +247,7 @@ impl *mut T { /// # Safety /// /// The offset must be in-bounds of the object, or one-byte-past-the-end. - /// Otherwise `offset` invokes Undefined Behaviour, regardless of whether + /// Otherwise `offset` invokes Undefined Behavior, regardless of whether /// the pointer is used. #[stable(feature = "rust1", since = "1.0.0")] #[inline] diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 382fd0f3788ce..84467be6eca56 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -94,7 +94,7 @@ impl Clone for Slice { /// Synthesizing a trait object with mismatched types—one where the /// vtable does not correspond to the type of the value to which the /// data pointer points—is highly likely to lead to undefined -/// behaviour. +/// behavior. /// /// # Examples /// diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 8039ac5e17b2e..c0a85e0df067c 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -965,7 +965,7 @@ impl<'a> DoubleEndedIterator for Lines<'a> { #[allow(deprecated)] pub struct LinesAny<'a>(Lines<'a>); -/// A nameable, clonable fn type +/// A nameable, cloneable fn type #[derive(Clone)] struct LinesAnyMap; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 9c02ccb08acd8..be9db89e3d797 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -135,7 +135,7 @@ pub enum Count<'a> { } /// The parser structure for interpreting the input format string. This is -/// modelled as an iterator over `Piece` structures to form a stream of tokens +/// modeled as an iterator over `Piece` structures to form a stream of tokens /// being output. /// /// This is a recursive-descent parser for the sake of simplicity, and if diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 7fafe97efc9ee..b82b7d122b3ce 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -456,7 +456,7 @@ pub trait Labeller<'a,N,E> { fn graph_id(&'a self) -> Id<'a>; /// Maps `n` to a unique identifier with respect to `self`. The - /// implementer is responsible for ensuring that the returned name + /// implementor is responsible for ensuring that the returned name /// is a valid DOT identifier. fn node_id(&'a self, n: &N) -> Id<'a>; @@ -594,7 +594,7 @@ pub type Edges<'a,E> = Cow<'a,[E]>; /// that is bound by the self lifetime `'a`. /// /// The `nodes` and `edges` method each return instantiations of -/// `Cow<[T]>` to leave implementers the freedom to create +/// `Cow<[T]>` to leave implementors the freedom to create /// entirely new vectors or to pass back slices into internally owned /// vectors. pub trait GraphWalk<'a, N: Clone, E: Clone> { diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs index 2a5d4bbd2ec9d..83d82e4330643 100644 --- a/src/librand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -168,7 +168,7 @@ impl IndependentSample for GammaLargeShape { /// /// For `k > 0` integral, this distribution is the sum of the squares /// of `k` independent standard normal random variables. For other -/// `k`, this uses the equivalent characterisation `χ²(k) = Gamma(k/2, +/// `k`, this uses the equivalent characterization `χ²(k) = Gamma(k/2, /// 2)`. pub struct ChiSquared { repr: ChiSquaredRepr, diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 4ad8fce8120aa..0b7c5b0d84022 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -207,7 +207,7 @@ fn test_resize_policy() { /// The hashes are all keyed by the thread-local random number generator /// on creation by default. This means that the ordering of the keys is /// randomized, but makes the tables more resistant to -/// denial-of-service attacks (Hash DoS). This behaviour can be +/// denial-of-service attacks (Hash DoS). This behavior can be /// overridden with one of the constructors. /// /// It is required that the keys implement the `Eq` and `Hash` traits, although @@ -324,7 +324,7 @@ fn search_hashed(table: M, F: FnMut(&K) -> bool, { // This is the only function where capacity can be zero. To avoid - // undefined behaviour when Bucket::new gets the raw bucket in this + // undefined behavior when Bucket::new gets the raw bucket in this // case, immediately return the appropriate search result. if table.capacity() == 0 { return TableRef(table); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9af766ad2af35..a624b3521267a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -137,7 +137,7 @@ //! not. //! //! Slices can only be handled through some kind of *pointer*, and as -//! such come in many flavours such as: +//! such come in many flavors such as: //! //! * `&[T]` - *shared slice* //! * `&mut [T]` - *mutable slice* diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 5c17ffb9c218a..c6499687304ec 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -235,7 +235,7 @@ impl TcpListener { /// to this listener. The port allocated can be queried via the /// `socket_addr` function. /// - /// The address type can be any implementer of `ToSocketAddrs` trait. See + /// The address type can be any implementor of `ToSocketAddrs` trait. See /// its documentation for concrete examples. #[stable(feature = "rust1", since = "1.0.0")] pub fn bind(addr: A) -> io::Result { diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 0be751be9504e..4e80fb2ceb09e 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -75,7 +75,7 @@ impl IntoInner for Child { fn into_inner(self) -> imp::Process { self.handle } } -/// A handle to a child procesess's stdin +/// A handle to a child process's stdin #[stable(feature = "process", since = "1.0.0")] pub struct ChildStdin { inner: AnonPipe From b6659f54c3333215f7683ed0448cd0ca2a185142 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Wed, 14 Oct 2015 17:31:27 +0300 Subject: [PATCH 2/9] Fix the link to `Default` trait in the prelude docs --- src/libstd/prelude/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/prelude/mod.rs b/src/libstd/prelude/mod.rs index f1c626cc16576..08227cfb35322 100644 --- a/src/libstd/prelude/mod.rs +++ b/src/libstd/prelude/mod.rs @@ -84,7 +84,7 @@ //! }. //! Generic conversions, used by savvy API authors to create //! overloaded methods. -//! * `std::default::`[`Default`](../default/trait.Default). +//! * `std::default::`[`Default`](../default/trait.Default.html). //! Types that have default values. //! * `std::iter::`{ //! [`Iterator`](../iter/trait.Iterator.html), From c8b6c125d4e13ec3f9b3d49ce17ca24b12b25ab9 Mon Sep 17 00:00:00 2001 From: Robert Gardner Date: Wed, 14 Oct 2015 17:38:56 -0400 Subject: [PATCH 3/9] Resolve unused_parens compilation warning Before this commit, the first "A Rust library" code sample produced the following compilation warning: ``` test.rs:7:22: 7:36 warning: unnecessary parentheses around `for` head expression, #[warn(unused_parens)] on by default test.rs:7 for _ in (0..5_000_000) { ``` This commit just removes the parens around the range 0..5_000_000. --- src/doc/trpl/rust-inside-other-languages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/rust-inside-other-languages.md b/src/doc/trpl/rust-inside-other-languages.md index 47e1df37dffb7..5c0bde02f9605 100644 --- a/src/doc/trpl/rust-inside-other-languages.md +++ b/src/doc/trpl/rust-inside-other-languages.md @@ -108,7 +108,7 @@ fn process() { let handles: Vec<_> = (0..10).map(|_| { thread::spawn(|| { let mut x = 0; - for _ in (0..5_000_000) { + for _ in 0..5_000_000 { x += 1 } x From 0dbc2ef8a158950c873cf7aeac2d7f757cf92d09 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 8 Oct 2015 07:41:16 +0200 Subject: [PATCH 4/9] reference: add link to the symbols --- src/doc/reference.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 9ce191ee5897f..0273c69548866 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -419,10 +419,13 @@ The two values of the boolean type are written `true` and `false`. ### Symbols Symbols are a general class of printable [tokens](#tokens) that play structural -roles in a variety of grammar productions. They are cataloged here for -completeness as the set of remaining miscellaneous printable tokens that do not +roles in a variety of grammar productions. They are a +set of remaining miscellaneous printable tokens that do not otherwise appear as [unary operators](#unary-operator-expressions), [binary operators](#binary-operator-expressions), or [keywords][keywords]. +They are catalogued in [the Symbols section][symbols] of the Grammar document. + +[symbols]: grammar.html#symbols ## Paths From ea37fadebb7a70421e1d922ed52f5219d4e9ddc1 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 15 Oct 2015 00:08:19 +0200 Subject: [PATCH 5/9] reference: 'struct' is more common that 'structure' Shoud have been part of commit 0b13ee0ced39 --- src/doc/reference.md | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 9ce191ee5897f..31650aec2df53 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1073,7 +1073,7 @@ let p: Point = (41, 68); ### Structs -A _structure_ is a nominal [structure type](#structure-types) defined with the +A _struct_ is a nominal [struct type](#struct-types) defined with the keyword `struct`. An example of a `struct` item and its use: @@ -1084,7 +1084,7 @@ let p = Point {x: 10, y: 11}; let px: i32 = p.x; ``` -A _tuple structure_ is a nominal [tuple type](#tuple-types), also defined with +A _tuple struct_ is a nominal [tuple type](#tuple-types), also defined with the keyword `struct`. For example: ``` @@ -1093,8 +1093,8 @@ let p = Point(10, 11); let px: i32 = match p { Point(x, _) => x }; ``` -A _unit-like struct_ is a structure without any fields, defined by leaving off -the list of fields entirely. Such a structure implicitly defines a constant of +A _unit-like struct_ is a struct without any fields, defined by leaving off +the list of fields entirely. Such a struct implicitly defines a constant of its type with the same name. For example: ``` @@ -1112,7 +1112,7 @@ const Cookie: Cookie = Cookie {}; let c = [Cookie, Cookie {}, Cookie, Cookie {}]; ``` -The precise memory layout of a structure is not specified. One can specify a +The precise memory layout of a struct is not specified. One can specify a particular layout using the [`repr` attribute](#ffi-attributes). ### Enumerations @@ -2401,7 +2401,7 @@ items. An _item declaration statement_ has a syntactic form identical to an [item](#items) declaration within a module. Declaring an item — a -function, enumeration, structure, type, static, trait, implementation or module +function, enumeration, struct, type, static, trait, implementation or module — locally within a statement block is simply a way of restricting its scope to a narrow region containing all of its uses; it is otherwise identical in meaning to declaring the item outside the statement block. @@ -2546,26 +2546,26 @@ comma: (0); // zero in parentheses ``` -### Structure expressions +### Struct expressions -There are several forms of structure expressions. A _structure expression_ -consists of the [path](#paths) of a [structure item](#structs), followed by +There are several forms of struct expressions. A _struct expression_ +consists of the [path](#paths) of a [struct item](#structs), followed by a brace-enclosed list of one or more comma-separated name-value pairs, -providing the field values of a new instance of the structure. A field name +providing the field values of a new instance of the struct. A field name can be any identifier, and is separated from its value expression by a colon. -The location denoted by a structure field is mutable if and only if the -enclosing structure is mutable. +The location denoted by a struct field is mutable if and only if the +enclosing struct is mutable. -A _tuple structure expression_ consists of the [path](#paths) of a [structure +A _tuple struct expression_ consists of the [path](#paths) of a [struct item](#structs), followed by a parenthesized list of one or more -comma-separated expressions (in other words, the path of a structure item -followed by a tuple expression). The structure item must be a tuple structure +comma-separated expressions (in other words, the path of a struct item +followed by a tuple expression). The struct item must be a tuple struct item. -A _unit-like structure expression_ consists only of the [path](#paths) of a -[structure item](#structs). +A _unit-like struct expression_ consists only of the [path](#paths) of a +[struct item](#structs). -The following are examples of structure expressions: +The following are examples of struct expressions: ``` # struct Point { x: f64, y: f64 } @@ -2578,14 +2578,14 @@ let u = game::User {name: "Joe", age: 35, score: 100_000}; some_fn::(Cookie); ``` -A structure expression forms a new value of the named structure type. Note -that for a given *unit-like* structure type, this will always be the same +A struct expression forms a new value of the named struct type. Note +that for a given *unit-like* struct type, this will always be the same value. -A structure expression can terminate with the syntax `..` followed by an +A struct expression can terminate with the syntax `..` followed by an expression to denote a functional update. The expression following `..` (the -base) must have the same structure type as the new structure type being formed. -The entire expression denotes the result of constructing a new structure (with +base) must have the same struct type as the new struct type being formed. +The entire expression denotes the result of constructing a new struct (with the same type as the base expression) with the given values for the fields that were explicitly specified and the values in the base expression for all other fields. @@ -2631,7 +2631,7 @@ the left-hand-side expression is an indirect [trait object](#trait-objects). A _field expression_ consists of an expression followed by a single dot and an identifier, when not immediately followed by a parenthesized expression-list (the latter is a [method call expression](#method-call-expressions)). A field -expression denotes a field of a [structure](#structure-types). +expression denotes a field of a [struct](#struct-types). ```{.ignore .field} mystruct.myfield; @@ -3350,17 +3350,17 @@ As you can see, the `vec!` macro allows you to create a `Vec` easily. The All in-bounds elements of arrays and slices are always initialized, and access to an array or slice is always bounds-checked. -### Structure types +### Struct types A `struct` *type* is a heterogeneous product of other types, called the *fields* of the type.[^structtype] [^structtype]: `struct` types are analogous to `struct` types in C, the *record* types of the ML family, - or the *structure* types of the Lisp family. + or the *struct* types of the Lisp family. New instances of a `struct` can be constructed with a [struct -expression](#structure-expressions). +expression](#struct-expressions). The memory layout of a `struct` is undefined by default to allow for compiler optimizations like field reordering, but it can be fixed with the @@ -3370,14 +3370,14 @@ have the same memory layout. The fields of a `struct` may be qualified by [visibility modifiers](#visibility-and-privacy), to allow access to data in a -structure outside a module. +struct outside a module. -A _tuple struct_ type is just like a structure type, except that the fields are +A _tuple struct_ type is just like a struct type, except that the fields are anonymous. -A _unit-like struct_ type is like a structure type, except that it has no -fields. The one value constructed by the associated [structure -expression](#structure-expressions) is the only value that inhabits such a +A _unit-like struct_ type is like a struct type, except that it has no +fields. The one value constructed by the associated [struct +expression](#struct-expressions) is the only value that inhabits such a type. ### Enumerated types @@ -3404,7 +3404,7 @@ named reference to an [`enum` item](#enumerations). ### Recursive types Nominal types — [enumerations](#enumerated-types) and -[structs](#structure-types) — may be recursive. That is, each `enum` +[structs](#struct-types) — may be recursive. That is, each `enum` constructor or `struct` field may refer, directly or indirectly, to the enclosing `enum` or `struct` type itself. Such recursion has restrictions: From 5d5e62d7d88a9c263ddcd5f942b151e066f3d27b Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 15 Oct 2015 00:16:13 +0200 Subject: [PATCH 6/9] book: fix typo --- src/doc/trpl/if-let.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/if-let.md b/src/doc/trpl/if-let.md index 4872ed6a77347..332498ce0f4d8 100644 --- a/src/doc/trpl/if-let.md +++ b/src/doc/trpl/if-let.md @@ -41,7 +41,7 @@ If a [pattern][patterns] matches successfully, it binds any appropriate parts of the value to the identifiers in the pattern, then evaluates the expression. If the pattern doesn’t match, nothing happens. -If you’d rather to do something else when the pattern does not match, you can +If you want to do something else when the pattern does not match, you can use `else`: ```rust From 18fa6d8dbcbb8ba46ecd95000727e11acb8a1eaa Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 15 Oct 2015 00:19:47 +0200 Subject: [PATCH 7/9] book: be consistent with preceding example --- src/doc/trpl/if-let.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/if-let.md b/src/doc/trpl/if-let.md index 4872ed6a77347..6f105b7c6c42e 100644 --- a/src/doc/trpl/if-let.md +++ b/src/doc/trpl/if-let.md @@ -65,7 +65,7 @@ loop as long as a value matches a certain pattern. It turns code like this: loop { match option { Some(x) => println!("{}", x), - _ => break, + None => break, } } ``` From 6bff154b57949cbb8ec22c1cc3ded856f0d3095d Mon Sep 17 00:00:00 2001 From: Daniel Carral Date: Thu, 15 Oct 2015 02:13:20 +0200 Subject: [PATCH 8/9] Replace 'adapters' to 'adaptors' in TRPL book Regarding #29063: Replace 'iterator adapters' appearances to 'iterator adaptors', thus embracing the terminology used along the API docs and achieving consistency between both sources. --- src/doc/trpl/iterators.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/trpl/iterators.md b/src/doc/trpl/iterators.md index b8bac76af0c57..c444f9f2fe53d 100644 --- a/src/doc/trpl/iterators.md +++ b/src/doc/trpl/iterators.md @@ -101,10 +101,10 @@ So, now that we've established that ranges are often not what you want, let's talk about what you do want instead. There are three broad classes of things that are relevant here: iterators, -*iterator adapters*, and *consumers*. Here's some definitions: +*iterator adaptors*, and *consumers*. Here's some definitions: * *iterators* give you a sequence of values. -* *iterator adapters* operate on an iterator, producing a new iterator with a +* *iterator adaptors* operate on an iterator, producing a new iterator with a different output sequence. * *consumers* operate on an iterator, producing some final set of values. @@ -246,12 +246,12 @@ for num in nums.iter() { These two basic iterators should serve you well. There are some more advanced iterators, including ones that are infinite. -That's enough about iterators. Iterator adapters are the last concept +That's enough about iterators. Iterator adaptors are the last concept we need to talk about with regards to iterators. Let's get to it! -## Iterator adapters +## Iterator adaptors -*Iterator adapters* take an iterator and modify it somehow, producing +*Iterator adaptors* take an iterator and modify it somehow, producing a new iterator. The simplest one is called `map`: ```rust,ignore @@ -280,7 +280,7 @@ doesn't print any numbers: If you are trying to execute a closure on an iterator for its side effects, just use `for` instead. -There are tons of interesting iterator adapters. `take(n)` will return an +There are tons of interesting iterator adaptors. `take(n)` will return an iterator over the next `n` elements of the original iterator. Let's try it out with an infinite iterator: @@ -329,7 +329,7 @@ a few times, and then consume the result. Check it out: This will give you a vector containing `6`, `12`, `18`, `24`, and `30`. -This is just a small taste of what iterators, iterator adapters, and consumers +This is just a small taste of what iterators, iterator adaptors, and consumers can help you with. There are a number of really useful iterators, and you can write your own as well. Iterators provide a safe, efficient way to manipulate all kinds of lists. They're a little unusual at first, but if you play with From 094f23e1081a754ebfa0875881d2d931bcef3a22 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Wed, 14 Oct 2015 21:43:05 -0400 Subject: [PATCH 9/9] Remove unnecessary parentheses around range expressions --- src/libstd/io/impls.rs | 8 ++++---- src/libstd/sys/unix/os.rs | 2 +- src/test/bench/shootout-nbody.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index 79013000fe3b5..5b587dd921bb7 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -238,7 +238,7 @@ mod tests { b.iter(|| { let mut rd = &buf[..]; - for _ in (0 .. 8) { + for _ in 0..8 { let _ = rd.read(&mut dst); test::black_box(&dst); } @@ -252,7 +252,7 @@ mod tests { b.iter(|| { let mut wr = &mut buf[..]; - for _ in (0 .. 8) { + for _ in 0..8 { let _ = wr.write_all(&src); test::black_box(&wr); } @@ -266,7 +266,7 @@ mod tests { b.iter(|| { let mut rd = &buf[..]; - for _ in (0 .. 8) { + for _ in 0..8 { let _ = rd.read(&mut dst); test::black_box(&dst); } @@ -280,7 +280,7 @@ mod tests { b.iter(|| { let mut wr = &mut buf[..]; - for _ in (0 .. 8) { + for _ in 0..8 { let _ = wr.write_all(&src); test::black_box(&wr); } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 6bda4e1e0e600..59b385b94810b 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -343,7 +343,7 @@ pub fn args() -> Args { let args = objc_msgSend(info, arguments_sel); let cnt: usize = mem::transmute(objc_msgSend(args, count_sel)); - for i in (0..cnt) { + for i in 0..cnt { let tmp = objc_msgSend(args, object_at_sel, i); let utf_c_str: *const libc::c_char = mem::transmute(objc_msgSend(tmp, utf8_sel)); diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 64d6a8109888e..1a9ea8bff08b3 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -225,7 +225,7 @@ fn main() { offset_momentum(&mut bodies); println!("{:.9}", energy(&bodies)); - for _ in (0..n) { + for _ in 0..n { advance(&mut bodies, 0.01, &mut diff, &mut mag); }