Skip to content

Commit

Permalink
Merge pull request rust-lang#454 from ehuss/split-types
Browse files Browse the repository at this point in the history
Split Types Chapter
  • Loading branch information
matthewjasper authored Nov 5, 2018
2 parents 8401995 + eb02dd5 commit 5aafa12
Show file tree
Hide file tree
Showing 55 changed files with 1,051 additions and 935 deletions.
18 changes: 18 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@

- [Type system](type-system.md)
- [Types](types.md)
- [Boolean type](types/boolean.md)
- [Numeric types](types/numeric.md)
- [Textual types](types/textual.md)
- [Never type](types/never.md)
- [Tuple types](types/tuple.md)
- [Array types](types/array.md)
- [Slice types](types/slice.md)
- [Struct types](types/struct.md)
- [Enumerated types](types/enum.md)
- [Union types](types/union.md)
- [Function item types](types/function-item.md)
- [Closure types](types/closure.md)
- [Pointer types](types/pointer.md)
- [Function pointer types](types/function-pointer.md)
- [Trait object types](types/trait-object.md)
- [Impl trait type](types/impl-trait.md)
- [Type parameters](types/parameters.md)
- [Inferred type](types/inferred.md)
- [Dynamically Sized Types](dynamically-sized-types.md)
- [Type layout](type-layout.md)
- [Interior mutability](interior-mutability.md)
Expand Down
4 changes: 2 additions & 2 deletions src/const_eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ A _const context_ is one of the following:
* [statics]
* [enum discriminants]

[array type length expressions]: types.html#array-and-slice-types
[array type length expressions]: types/array.html
[enum discriminants]: items/enumerations.html#custom-discriminant-values-for-field-less-enumerations
[constants]: items/constant-items.html
[statics]: items/static-items.html
Expand All @@ -68,7 +68,7 @@ A _const context_ is one of the following:
[block expressions]: expressions/block-expr.html
[field]: expressions/field-expr.html
[array indexing]: expressions/array-expr.html#array-and-slice-indexing-expressions
[slice]: types.html#array-and-slice-types
[slice]: types/slice.html
[range expressions]: expressions/range-expr.html
[closure expressions]: expressions/closure-expr.html
[negation]: expressions/operator-expr.html#negation-operators
Expand Down
12 changes: 6 additions & 6 deletions src/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ variable or field from being dropped automatically.
[Assignment]: expressions/operator-expr.html#assignment-expressions
[`std::ops::Drop::drop`]: ../std/ops/trait.Drop.html
[RFC 1857]: https://github.com/rust-lang/rfcs/blob/master/text/1857-stabilize-drop-order.md
[struct]: types.html#struct-types
[tuple]: types.html#tuple-types
[enum variant]: types.html#enumerated-types
[array]: types.html#array-and-slice-types
[closure]: types.html#closure-types
[Trait objects]: types.html#trait-objects
[struct]: types/struct.html
[tuple]: types/tuple.html
[enum variant]: types/enum.html
[array]: types/array.html
[closure]: types/closure.html
[Trait objects]: types/trait-object.html
[`std::ptr::drop_in_place`]: ../std/ptr/fn.drop_in_place.html
[`std::mem::forget`]: ../std/mem/fn.forget.html
[`std::mem::ManuallyDrop`]: ../std/mem/struct.ManuallyDrop.html
6 changes: 3 additions & 3 deletions src/dynamically-sized-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Notably: [variables], function parameters, [const] and [static] items must be
`Sized`.

[sized]: special-types-and-traits.html#sized
[Slices]: types.html#array-and-slice-types
[trait objects]: types.html#trait-objects
[Pointer types]: types.html#pointer-types
[Slices]: types/slice.html
[trait objects]: types/trait-object.html
[Pointer types]: types/pointer.html
[variables]: variables.html
[const]: items/constant-items.html
[static]: items/static-items.html
2 changes: 1 addition & 1 deletion src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ They are never allowed before:
[let statement]: statements.html#let-statements
[Mutable `static` items]: items/static-items.html#mutable-statics
[const contexts]: const_eval.html
[slice]: types.html#array-and-slice-types
[slice]: types/slice.html
[statement]: statements.html
[static variables]: items/static-items.html
[Temporary values]: #temporary-lifetimes
Expand Down
4 changes: 2 additions & 2 deletions src/expressions/array-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
> &nbsp;&nbsp; &nbsp;&nbsp; [_Expression_] ( `,` [_Expression_] )<sup>\*</sup> `,`<sup>?</sup>\
> &nbsp;&nbsp; | [_Expression_] `;` [_Expression_]
An _[array](types.html#array-and-slice-types) expression_ can be written by
An _[array](types/array.html) expression_ can be written by
enclosing zero or more comma-separated expressions of uniform type in square
brackets. This produces and array containing each of these values in the
order they are written.
Expand Down Expand Up @@ -44,7 +44,7 @@ expressions].
> _IndexExpression_ :\
> &nbsp;&nbsp; [_Expression_] `[` [_Expression_] `]`
[Array and slice](types.html#array-and-slice-types)-typed expressions can be
[Array](types/array.html) and [slice](types/slice.html)-typed expressions can be
indexed by writing a square-bracket-enclosed expression of type `usize` (the
index) after them. When the array is mutable, the resulting [memory location]
can be assigned to.
Expand Down
2 changes: 1 addition & 1 deletion src/expressions/call-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
A _call expression_ consists of an expression followed by a parenthesized
expression-list. It invokes a function, providing zero or more input variables.
If the function eventually returns, then the expression completes. For
[non-function types](types.html#function-item-types), the expression f(...) uses
[non-function types](types/function-item.html), the expression f(...) uses
the method on one of the [`std::ops::Fn`], [`std::ops::FnMut`] or
[`std::ops::FnOnce`] traits, which differ in whether they take the type by
reference, mutable reference, or take ownership respectively. An automatic
Expand Down
6 changes: 3 additions & 3 deletions src/expressions/closure-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ functions, as an abbreviation for defining and capturing a separate function.

Significantly, closure expressions _capture their environment_, which regular
[function definitions] do not. Without the `move` keyword, the closure expression
[infers how it captures each variable from its environment](types.html#capture-modes),
[infers how it captures each variable from its environment](types/closure.html#capture-modes),
preferring to capture by shared reference, effectively borrowing
all outer variables mentioned inside the closure's body. If needed the compiler
will infer that instead mutable references should be taken, or that the values
Expand All @@ -35,7 +35,7 @@ prefixing it with the `move` keyword. This is often used to ensure that the
closure's type is `'static`.

The compiler will determine which of the [closure
traits](types.html#call-traits-and-coercions) the closure's type will implement by how it
traits](types/closure.html#call-traits-and-coercions) the closure's type will implement by how it
acts on its captured variables. The closure will also implement
[`Send`](special-types-and-traits.html#send) and/or
[`Sync`](special-types-and-traits.html#sync) if all of its captured types do.
Expand Down Expand Up @@ -67,5 +67,5 @@ ten_times(move |j| println!("{}, {}", word, j));

[_Expression_]: expressions.html
[_BlockExpression_]: expressions/block-expr.html
[_TypeNoBounds_]: types.html
[_TypeNoBounds_]: types.html#type-expressions
[_FunctionParameters_]: items/functions.html
2 changes: 1 addition & 1 deletion src/expressions/loop-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ A `loop` expression repeats execution of its body continuously:
`loop { println!("I live."); }`.

A `loop` expression without an associated `break` expression is diverging and
has type [`!`](types.html#never-type). A `loop` expression containing
has type [`!`](types/never.html). A `loop` expression containing
associated [`break` expression(s)](#break-expressions) may terminate, and must
have type compatible with the value of the `break` expression(s).

Expand Down
6 changes: 3 additions & 3 deletions src/expressions/method-call-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dot, an expression path segment, and a parenthesized expression-list. Method cal
resolved to associated [methods] on specific traits, either statically
dispatching to a method if the exact `self`-type of the left-hand-side is known,
or dynamically dispatching if the left-hand-side expression is an indirect
[trait object](types.html#trait-objects).
[trait object](types/trait-object.html).

```rust
let pi: Result<f32, _> = "3.14".parse();
Expand Down Expand Up @@ -101,8 +101,8 @@ method and you'll be fine.
[_Expression_]: expressions.html
[_PathExprSegment_]: paths.html#paths-in-expressions
[visible]: visibility-and-privacy.html
[array]: types.html#array-and-slice-types
[trait objects]: types.html#trait-objects
[array]: types/array.html
[trait objects]: types/trait-object.html
[disambiguate call]: expressions/call-expr.html#disambiguating-function-calls
[disambiguating function call syntax]: expressions/call-expr.html#disambiguating-function-calls
[dereference]: expressions/operator-expr.html#the-dereference-operator
Expand Down
8 changes: 4 additions & 4 deletions src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ let a = & & & & mut 10;
> &nbsp;&nbsp; `*` [_Expression_]
The `*` (dereference) operator is also a unary prefix operator. When applied to
a [pointer](types.html#pointer-types) it denotes the pointed-to location. If
a [pointer](types/pointer.html) it denotes the pointed-to location. If
the expression is of type `&mut T` and `*mut T`, and is either a local
variable, a (nested) field of a local variable or is a mutable [place
expression], then the resulting memory location can be assigned to.
Expand Down Expand Up @@ -345,7 +345,7 @@ well as the following additional casts. Here `*T` means either `*const T` or
| `*T` where `T: Sized` | Numeric type | Pointer to address cast |
| Integer type | `*V` where `V: Sized` | Address to pointer cast |
| `&[T; n]` | `*const T` | Array to pointer cast |
| [Function pointer](types.html#function-pointer-types) | `*V` where `V: Sized` | Function pointer to pointer cast |
| [Function pointer](types/function-pointer.html) | `*V` where `V: Sized` | Function pointer to pointer cast |
| Function pointer | Integer | Function pointer to address cast |
| Closure \*\* | Function pointer | Closure to function pointer cast |

Expand Down Expand Up @@ -446,7 +446,7 @@ assert_eq!(x, 14);
[temporary value]: expressions.html#temporary-lifetimes
[float-int]: https://github.com/rust-lang/rust/issues/10184
[float-float]: https://github.com/rust-lang/rust/issues/15536
[`unit` type]: types.html#tuple-types
[`unit` type]: types/tuple.html

[_BorrowExpression_]: #borrow-operators
[_DereferenceExpression_]: #the-dereference-operator
Expand All @@ -460,4 +460,4 @@ assert_eq!(x, 14);
[_CompoundAssignmentExpression_]: #compound-assignment-expressions

[_Expression_]: expressions.html
[_TypeNoBounds_]: types.html
[_TypeNoBounds_]: types.html#type-expressions
4 changes: 2 additions & 2 deletions src/expressions/tuple-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
> &nbsp;&nbsp; ( [_Expression_] `,` )<sup>+</sup> [_Expression_]<sup>?</sup>
Tuples are written by enclosing zero or more comma-separated expressions in
parentheses. They are used to create [tuple-typed](types.html#tuple-types)
parentheses. They are used to create [tuple-typed](types/tuple.html)
values.

```rust
Expand Down Expand Up @@ -39,7 +39,7 @@ expressions].
> _TupleIndexingExpression_ :\
> &nbsp;&nbsp; [_Expression_] `.` [TUPLE_INDEX]
[Tuples](types.html#tuple-types) and [struct tuples](items/structs.html) can be
[Tuples](types/tuple.html) and [struct tuples](items/structs.html) can be
indexed using the number corresponding to the position of the field. The index
must be written as a [decimal literal](tokens.html#integer-literals) with no
underscores or suffix. Tuple indexing expressions also differ from field
Expand Down
2 changes: 1 addition & 1 deletion src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Generic functions and generic structs can use traits to constrain, or bound, the
[enums]: items/enumerations.html
[structs]: items/structs.html
[unions]: items/unions.html
[trait objects]: types.html#trait-objects
[trait objects]: types/trait-object.html
[implementations]: items/implementations.html
[traits]: items/traits.html
[object safety]: items/traits.html#object-safety
2 changes: 1 addition & 1 deletion src/interior-mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ borrow checks to ensure the usual rules around multiple references. The
accessed with atomic operations, allowing the value to be shared and mutated
across threads.

[shared reference]: types.html#shared-references-
[shared reference]: types/pointer.html#shared-references-
[ub]: behavior-considered-undefined.html
[`std::mem::transmute`]: ../std/mem/fn.transmute.html
[`std::cell::UnsafeCell<T>`]: ../std/cell/struct.UnsafeCell.html
Expand Down
8 changes: 4 additions & 4 deletions src/items/associated-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,20 @@ fn main() {
[_FunctionReturnType_]: items/functions.html
[_Generics_]: items/generics.html
[_Lifetime_]: trait-bounds.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_WhereClause_]: items/generics.html#where-clauses
[trait]: items/traits.html
[traits]: items/traits.html
[type aliases]: items/type-aliases.html
[inherent implementations]: items/implementations.html#inherent-implementations
[identifier]: identifiers.html
[trait object]: types.html#trait-objects
[trait object]: types/trait-object.html
[implementations]: items/implementations.html
[type]: types.html
[type]: types.html#type-expressions
[constants]: items/constant-items.html
[constant item]: items/constant-items.html
[functions]: items/functions.html
[function item]: types.html#function-item-types
[function item]: types/function-item.html
[method call operator]: expressions/method-call-expr.html
[block]: expressions/block-expr.html
[path]: paths.html
2 changes: 1 addition & 1 deletion src/items/constant-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ fn create_and_drop_zero_with_destructor() {
[static lifetime elision]: lifetime-elision.html#static-lifetime-elision
[`Drop`]: special-types-and-traits.html#drop
[IDENTIFIER]: identifiers.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_Expression_]: expressions.html
2 changes: 1 addition & 1 deletion src/items/enumerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ enum ZeroVariants {}
[_Expression_]: expressions.html
[_TupleFields_]: items/structs.html
[_StructFields_]: items/structs.html
[enumerated type]: types.html#enumerated-types
[enumerated type]: types/enum.html
[`mem::discriminant`]: ../std/mem/fn.discriminant.html
[numeric cast]: expressions/operator-expr.html#semantics
[`repr` attribute]: attributes.html#ffi-attributes
Expand Down
2 changes: 1 addition & 1 deletion src/items/external-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ block.
[_Generics_]: items/generics.html
[_InnerAttribute_]: attributes.html
[_OuterAttribute_]: attributes.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_Visibility_]: visibility-and-privacy.html
[_WhereClause_]: items/generics.html#where-clauses
[attributes]: attributes.html#ffi-attributes
6 changes: 3 additions & 3 deletions src/items/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ attributes macros.
[_InnerAttribute_]: attributes.html
[_Pattern_]: patterns.html
[_Statement_]: statements.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_WhereClause_]: items/generics.html#where-clauses
[const contexts]: const_eval.html
[external blocks]: items/external-blocks.html
[path]: paths.html
[block]: expressions/block-expr.html
[variables]: variables.html
[type]: types.html
[*function item type*]: types.html#function-item-types
[type]: types.html#type-expressions
[*function item type*]: types/function-item.html
[Trait]: items/traits.html
[attributes]: attributes.html
[`cfg`]: conditional-compilation.html
Expand Down
14 changes: 7 additions & 7 deletions src/items/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ generic parameter.
[_LifetimeBounds_]: trait-bounds.html
[_Lifetime_]: trait-bounds.html
[_OuterAttribute_]: attributes.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_TypeParamBounds_]: trait-bounds.html

[arrays]: types.html#array-and-slice-types
[function pointers]: types.html#function-pointer-types
[references]: types.html#shared-references-
[raw pointers]: types.html#raw-pointers-const-and-mut
[arrays]: types/array.html
[function pointers]: types/function-pointer.html
[references]: types/pointer.html#shared-references-
[raw pointers]: types/pointer.html#raw-pointers-const-and-mut
[`Clone`]: special-types-and-traits.html#clone
[`Copy`]: special-types-and-traits.html#copy
[`Sized`]: special-types-and-traits.html#sized
[tuples]: types.html#tuple-types
[trait object]: types.html#trait-objects
[tuples]: types/tuple.html
[trait object]: types/trait-object.html
[attributes]: attributes.html
2 changes: 1 addition & 1 deletion src/items/implementations.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ attributes].
[_OuterAttribute_]: attributes.html
[_TypeAlias_]: items/type-aliases.html
[_TypePath_]: paths.html#paths-in-types
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_Visibility_]: visibility-and-privacy.html
[_WhereClause_]: items/generics.html#where-clauses
[trait]: items/traits.html
Expand Down
2 changes: 1 addition & 1 deletion src/items/static-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ following are true:
[constant expression]: const_eval.html#constant-expressions
[interior mutable]: interior-mutability.html
[IDENTIFIER]: identifiers.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_Expression_]: expressions.html
6 changes: 3 additions & 3 deletions src/items/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ let px: i32 = p.x;
A _tuple struct_ is a nominal [tuple type], also defined with the keyword
`struct`. For example:

[struct type]: types.html#struct-types
[tuple type]: types.html#tuple-types
[struct type]: types/struct.html
[tuple type]: types/tuple.html

```rust
struct Point(i32, i32);
Expand Down Expand Up @@ -85,4 +85,4 @@ particular layout using the [`repr` attribute].
[_Generics_]: items/generics.html
[_WhereClause_]: items/generics.html#where-clauses
[_Visibility_]: visibility-and-privacy.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
4 changes: 2 additions & 2 deletions src/items/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ trait T {
[_Pattern_]: patterns.html
[_SelfParam_]: items/associated-items.html#methods
[_TypeParamBounds_]: trait-bounds.html
[_Type_]: types.html
[_Type_]: types.html#type-expressions
[_WhereClause_]: items/generics.html#where-clauses
[bounds]: trait-bounds.html
[trait object]: types.html#trait-objects
[trait object]: types/trait-object.html
[explicit]: expressions/operator-expr.html#type-cast-expressions
[RFC 255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
[associated items]: items/associated-items.html
Expand Down
2 changes: 1 addition & 1 deletion src/items/type-aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ let _: F = E::A; // OK
[IDENTIFIER]: identifiers.html
[_Generics_]: items/generics.html
[_WhereClause_]: items/generics.html#where-clauses
[_Type_]: types.html
[_Type_]: types.html#type-expressions
4 changes: 2 additions & 2 deletions src/keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ is possible to declare a variable or method with the name `union`.
[items]: items.html
[Variables]: variables.html
[Type parameters]: types.html#type-parameters
[Type parameters]: types/parameters.html
[loop labels]: expressions/loop-expr.html#loop-labels
[Macros]: macros.html
[attributes]: attributes.html
[Macro placeholders]: macros-by-example.html
[Crates]: crates-and-source-files.html
[union]: items/unions.html
[variants]: items/enumerations.html
[`dyn`]: types.html#trait-objects
[`dyn`]: types/trait-object.html
Loading

0 comments on commit 5aafa12

Please sign in to comment.