Skip to content

Commit 5aafa12

Browse files
Merge pull request #454 from ehuss/split-types
Split Types Chapter
2 parents 8401995 + eb02dd5 commit 5aafa12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1051
-935
lines changed

src/SUMMARY.md

+18
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@
6767

6868
- [Type system](type-system.md)
6969
- [Types](types.md)
70+
- [Boolean type](types/boolean.md)
71+
- [Numeric types](types/numeric.md)
72+
- [Textual types](types/textual.md)
73+
- [Never type](types/never.md)
74+
- [Tuple types](types/tuple.md)
75+
- [Array types](types/array.md)
76+
- [Slice types](types/slice.md)
77+
- [Struct types](types/struct.md)
78+
- [Enumerated types](types/enum.md)
79+
- [Union types](types/union.md)
80+
- [Function item types](types/function-item.md)
81+
- [Closure types](types/closure.md)
82+
- [Pointer types](types/pointer.md)
83+
- [Function pointer types](types/function-pointer.md)
84+
- [Trait object types](types/trait-object.md)
85+
- [Impl trait type](types/impl-trait.md)
86+
- [Type parameters](types/parameters.md)
87+
- [Inferred type](types/inferred.md)
7088
- [Dynamically Sized Types](dynamically-sized-types.md)
7189
- [Type layout](type-layout.md)
7290
- [Interior mutability](interior-mutability.md)

src/const_eval.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ A _const context_ is one of the following:
5151
* [statics]
5252
* [enum discriminants]
5353

54-
[array type length expressions]: types.html#array-and-slice-types
54+
[array type length expressions]: types/array.html
5555
[enum discriminants]: items/enumerations.html#custom-discriminant-values-for-field-less-enumerations
5656
[constants]: items/constant-items.html
5757
[statics]: items/static-items.html
@@ -68,7 +68,7 @@ A _const context_ is one of the following:
6868
[block expressions]: expressions/block-expr.html
6969
[field]: expressions/field-expr.html
7070
[array indexing]: expressions/array-expr.html#array-and-slice-indexing-expressions
71-
[slice]: types.html#array-and-slice-types
71+
[slice]: types/slice.html
7272
[range expressions]: expressions/range-expr.html
7373
[closure expressions]: expressions/closure-expr.html
7474
[negation]: expressions/operator-expr.html#negation-operators

src/destructors.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ variable or field from being dropped automatically.
8282
[Assignment]: expressions/operator-expr.html#assignment-expressions
8383
[`std::ops::Drop::drop`]: ../std/ops/trait.Drop.html
8484
[RFC 1857]: https://github.com/rust-lang/rfcs/blob/master/text/1857-stabilize-drop-order.md
85-
[struct]: types.html#struct-types
86-
[tuple]: types.html#tuple-types
87-
[enum variant]: types.html#enumerated-types
88-
[array]: types.html#array-and-slice-types
89-
[closure]: types.html#closure-types
90-
[Trait objects]: types.html#trait-objects
85+
[struct]: types/struct.html
86+
[tuple]: types/tuple.html
87+
[enum variant]: types/enum.html
88+
[array]: types/array.html
89+
[closure]: types/closure.html
90+
[Trait objects]: types/trait-object.html
9191
[`std::ptr::drop_in_place`]: ../std/ptr/fn.drop_in_place.html
9292
[`std::mem::forget`]: ../std/mem/fn.forget.html
9393
[`std::mem::ManuallyDrop`]: ../std/mem/struct.ManuallyDrop.html

src/dynamically-sized-types.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Notably: [variables], function parameters, [const] and [static] items must be
2424
`Sized`.
2525

2626
[sized]: special-types-and-traits.html#sized
27-
[Slices]: types.html#array-and-slice-types
28-
[trait objects]: types.html#trait-objects
29-
[Pointer types]: types.html#pointer-types
27+
[Slices]: types/slice.html
28+
[trait objects]: types/trait-object.html
29+
[Pointer types]: types/pointer.html
3030
[variables]: variables.html
3131
[const]: items/constant-items.html
3232
[static]: items/static-items.html

src/expressions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ They are never allowed before:
316316
[let statement]: statements.html#let-statements
317317
[Mutable `static` items]: items/static-items.html#mutable-statics
318318
[const contexts]: const_eval.html
319-
[slice]: types.html#array-and-slice-types
319+
[slice]: types/slice.html
320320
[statement]: statements.html
321321
[static variables]: items/static-items.html
322322
[Temporary values]: #temporary-lifetimes

src/expressions/array-expr.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
> &nbsp;&nbsp; &nbsp;&nbsp; [_Expression_] ( `,` [_Expression_] )<sup>\*</sup> `,`<sup>?</sup>\
1111
> &nbsp;&nbsp; | [_Expression_] `;` [_Expression_]
1212
13-
An _[array](types.html#array-and-slice-types) expression_ can be written by
13+
An _[array](types/array.html) expression_ can be written by
1414
enclosing zero or more comma-separated expressions of uniform type in square
1515
brackets. This produces and array containing each of these values in the
1616
order they are written.
@@ -44,7 +44,7 @@ expressions].
4444
> _IndexExpression_ :\
4545
> &nbsp;&nbsp; [_Expression_] `[` [_Expression_] `]`
4646
47-
[Array and slice](types.html#array-and-slice-types)-typed expressions can be
47+
[Array](types/array.html) and [slice](types/slice.html)-typed expressions can be
4848
indexed by writing a square-bracket-enclosed expression of type `usize` (the
4949
index) after them. When the array is mutable, the resulting [memory location]
5050
can be assigned to.

src/expressions/call-expr.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
A _call expression_ consists of an expression followed by a parenthesized
1111
expression-list. It invokes a function, providing zero or more input variables.
1212
If the function eventually returns, then the expression completes. For
13-
[non-function types](types.html#function-item-types), the expression f(...) uses
13+
[non-function types](types/function-item.html), the expression f(...) uses
1414
the method on one of the [`std::ops::Fn`], [`std::ops::FnMut`] or
1515
[`std::ops::FnOnce`] traits, which differ in whether they take the type by
1616
reference, mutable reference, or take ownership respectively. An automatic

src/expressions/closure-expr.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ functions, as an abbreviation for defining and capturing a separate function.
2525

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

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

6868
[_Expression_]: expressions.html
6969
[_BlockExpression_]: expressions/block-expr.html
70-
[_TypeNoBounds_]: types.html
70+
[_TypeNoBounds_]: types.html#type-expressions
7171
[_FunctionParameters_]: items/functions.html

src/expressions/loop-expr.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ A `loop` expression repeats execution of its body continuously:
3737
`loop { println!("I live."); }`.
3838

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

src/expressions/method-call-expr.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dot, an expression path segment, and a parenthesized expression-list. Method cal
99
resolved to associated [methods] on specific traits, either statically
1010
dispatching to a method if the exact `self`-type of the left-hand-side is known,
1111
or dynamically dispatching if the left-hand-side expression is an indirect
12-
[trait object](types.html#trait-objects).
12+
[trait object](types/trait-object.html).
1313

1414
```rust
1515
let pi: Result<f32, _> = "3.14".parse();
@@ -101,8 +101,8 @@ method and you'll be fine.
101101
[_Expression_]: expressions.html
102102
[_PathExprSegment_]: paths.html#paths-in-expressions
103103
[visible]: visibility-and-privacy.html
104-
[array]: types.html#array-and-slice-types
105-
[trait objects]: types.html#trait-objects
104+
[array]: types/array.html
105+
[trait objects]: types/trait-object.html
106106
[disambiguate call]: expressions/call-expr.html#disambiguating-function-calls
107107
[disambiguating function call syntax]: expressions/call-expr.html#disambiguating-function-calls
108108
[dereference]: expressions/operator-expr.html#the-dereference-operator

src/expressions/operator-expr.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let a = & & & & mut 10;
8585
> &nbsp;&nbsp; `*` [_Expression_]
8686
8787
The `*` (dereference) operator is also a unary prefix operator. When applied to
88-
a [pointer](types.html#pointer-types) it denotes the pointed-to location. If
88+
a [pointer](types/pointer.html) it denotes the pointed-to location. If
8989
the expression is of type `&mut T` and `*mut T`, and is either a local
9090
variable, a (nested) field of a local variable or is a mutable [place
9191
expression], then the resulting memory location can be assigned to.
@@ -345,7 +345,7 @@ well as the following additional casts. Here `*T` means either `*const T` or
345345
| `*T` where `T: Sized` | Numeric type | Pointer to address cast |
346346
| Integer type | `*V` where `V: Sized` | Address to pointer cast |
347347
| `&[T; n]` | `*const T` | Array to pointer cast |
348-
| [Function pointer](types.html#function-pointer-types) | `*V` where `V: Sized` | Function pointer to pointer cast |
348+
| [Function pointer](types/function-pointer.html) | `*V` where `V: Sized` | Function pointer to pointer cast |
349349
| Function pointer | Integer | Function pointer to address cast |
350350
| Closure \*\* | Function pointer | Closure to function pointer cast |
351351

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

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

462462
[_Expression_]: expressions.html
463-
[_TypeNoBounds_]: types.html
463+
[_TypeNoBounds_]: types.html#type-expressions

src/expressions/tuple-expr.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
> &nbsp;&nbsp; ( [_Expression_] `,` )<sup>+</sup> [_Expression_]<sup>?</sup>
1111
1212
Tuples are written by enclosing zero or more comma-separated expressions in
13-
parentheses. They are used to create [tuple-typed](types.html#tuple-types)
13+
parentheses. They are used to create [tuple-typed](types/tuple.html)
1414
values.
1515

1616
```rust
@@ -39,7 +39,7 @@ expressions].
3939
> _TupleIndexingExpression_ :\
4040
> &nbsp;&nbsp; [_Expression_] `.` [TUPLE_INDEX]
4141
42-
[Tuples](types.html#tuple-types) and [struct tuples](items/structs.html) can be
42+
[Tuples](types/tuple.html) and [struct tuples](items/structs.html) can be
4343
indexed using the number corresponding to the position of the field. The index
4444
must be written as a [decimal literal](tokens.html#integer-literals) with no
4545
underscores or suffix. Tuple indexing expressions also differ from field

src/glossary.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Generic functions and generic structs can use traits to constrain, or bound, the
134134
[enums]: items/enumerations.html
135135
[structs]: items/structs.html
136136
[unions]: items/unions.html
137-
[trait objects]: types.html#trait-objects
137+
[trait objects]: types/trait-object.html
138138
[implementations]: items/implementations.html
139139
[traits]: items/traits.html
140140
[object safety]: items/traits.html#object-safety

src/interior-mutability.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ borrow checks to ensure the usual rules around multiple references. The
2020
accessed with atomic operations, allowing the value to be shared and mutated
2121
across threads.
2222

23-
[shared reference]: types.html#shared-references-
23+
[shared reference]: types/pointer.html#shared-references-
2424
[ub]: behavior-considered-undefined.html
2525
[`std::mem::transmute`]: ../std/mem/fn.transmute.html
2626
[`std::cell::UnsafeCell<T>`]: ../std/cell/struct.UnsafeCell.html

src/items/associated-items.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,20 @@ fn main() {
292292
[_FunctionReturnType_]: items/functions.html
293293
[_Generics_]: items/generics.html
294294
[_Lifetime_]: trait-bounds.html
295-
[_Type_]: types.html
295+
[_Type_]: types.html#type-expressions
296296
[_WhereClause_]: items/generics.html#where-clauses
297297
[trait]: items/traits.html
298298
[traits]: items/traits.html
299299
[type aliases]: items/type-aliases.html
300300
[inherent implementations]: items/implementations.html#inherent-implementations
301301
[identifier]: identifiers.html
302-
[trait object]: types.html#trait-objects
302+
[trait object]: types/trait-object.html
303303
[implementations]: items/implementations.html
304-
[type]: types.html
304+
[type]: types.html#type-expressions
305305
[constants]: items/constant-items.html
306306
[constant item]: items/constant-items.html
307307
[functions]: items/functions.html
308-
[function item]: types.html#function-item-types
308+
[function item]: types/function-item.html
309309
[method call operator]: expressions/method-call-expr.html
310310
[block]: expressions/block-expr.html
311311
[path]: paths.html

src/items/constant-items.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ fn create_and_drop_zero_with_destructor() {
6464
[static lifetime elision]: lifetime-elision.html#static-lifetime-elision
6565
[`Drop`]: special-types-and-traits.html#drop
6666
[IDENTIFIER]: identifiers.html
67-
[_Type_]: types.html
67+
[_Type_]: types.html#type-expressions
6868
[_Expression_]: expressions.html

src/items/enumerations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ enum ZeroVariants {}
137137
[_Expression_]: expressions.html
138138
[_TupleFields_]: items/structs.html
139139
[_StructFields_]: items/structs.html
140-
[enumerated type]: types.html#enumerated-types
140+
[enumerated type]: types/enum.html
141141
[`mem::discriminant`]: ../std/mem/fn.discriminant.html
142142
[numeric cast]: expressions/operator-expr.html#semantics
143143
[`repr` attribute]: attributes.html#ffi-attributes

src/items/external-blocks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ block.
123123
[_Generics_]: items/generics.html
124124
[_InnerAttribute_]: attributes.html
125125
[_OuterAttribute_]: attributes.html
126-
[_Type_]: types.html
126+
[_Type_]: types.html#type-expressions
127127
[_Visibility_]: visibility-and-privacy.html
128128
[_WhereClause_]: items/generics.html#where-clauses
129129
[attributes]: attributes.html#ffi-attributes

src/items/functions.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@ attributes macros.
220220
[_InnerAttribute_]: attributes.html
221221
[_Pattern_]: patterns.html
222222
[_Statement_]: statements.html
223-
[_Type_]: types.html
223+
[_Type_]: types.html#type-expressions
224224
[_WhereClause_]: items/generics.html#where-clauses
225225
[const contexts]: const_eval.html
226226
[external blocks]: items/external-blocks.html
227227
[path]: paths.html
228228
[block]: expressions/block-expr.html
229229
[variables]: variables.html
230-
[type]: types.html
231-
[*function item type*]: types.html#function-item-types
230+
[type]: types.html#type-expressions
231+
[*function item type*]: types/function-item.html
232232
[Trait]: items/traits.html
233233
[attributes]: attributes.html
234234
[`cfg`]: conditional-compilation.html

src/items/generics.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ generic parameter.
106106
[_LifetimeBounds_]: trait-bounds.html
107107
[_Lifetime_]: trait-bounds.html
108108
[_OuterAttribute_]: attributes.html
109-
[_Type_]: types.html
109+
[_Type_]: types.html#type-expressions
110110
[_TypeParamBounds_]: trait-bounds.html
111111

112-
[arrays]: types.html#array-and-slice-types
113-
[function pointers]: types.html#function-pointer-types
114-
[references]: types.html#shared-references-
115-
[raw pointers]: types.html#raw-pointers-const-and-mut
112+
[arrays]: types/array.html
113+
[function pointers]: types/function-pointer.html
114+
[references]: types/pointer.html#shared-references-
115+
[raw pointers]: types/pointer.html#raw-pointers-const-and-mut
116116
[`Clone`]: special-types-and-traits.html#clone
117117
[`Copy`]: special-types-and-traits.html#copy
118118
[`Sized`]: special-types-and-traits.html#sized
119-
[tuples]: types.html#tuple-types
120-
[trait object]: types.html#trait-objects
119+
[tuples]: types/tuple.html
120+
[trait object]: types/trait-object.html
121121
[attributes]: attributes.html

src/items/implementations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ attributes].
187187
[_OuterAttribute_]: attributes.html
188188
[_TypeAlias_]: items/type-aliases.html
189189
[_TypePath_]: paths.html#paths-in-types
190-
[_Type_]: types.html
190+
[_Type_]: types.html#type-expressions
191191
[_Visibility_]: visibility-and-privacy.html
192192
[_WhereClause_]: items/generics.html#where-clauses
193193
[trait]: items/traits.html

src/items/static-items.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ following are true:
7373
[constant expression]: const_eval.html#constant-expressions
7474
[interior mutable]: interior-mutability.html
7575
[IDENTIFIER]: identifiers.html
76-
[_Type_]: types.html
76+
[_Type_]: types.html#type-expressions
7777
[_Expression_]: expressions.html

src/items/structs.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ let px: i32 = p.x;
4949
A _tuple struct_ is a nominal [tuple type], also defined with the keyword
5050
`struct`. For example:
5151

52-
[struct type]: types.html#struct-types
53-
[tuple type]: types.html#tuple-types
52+
[struct type]: types/struct.html
53+
[tuple type]: types/tuple.html
5454

5555
```rust
5656
struct Point(i32, i32);
@@ -85,4 +85,4 @@ particular layout using the [`repr` attribute].
8585
[_Generics_]: items/generics.html
8686
[_WhereClause_]: items/generics.html#where-clauses
8787
[_Visibility_]: visibility-and-privacy.html
88-
[_Type_]: types.html
88+
[_Type_]: types.html#type-expressions

src/items/traits.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ trait T {
216216
[_Pattern_]: patterns.html
217217
[_SelfParam_]: items/associated-items.html#methods
218218
[_TypeParamBounds_]: trait-bounds.html
219-
[_Type_]: types.html
219+
[_Type_]: types.html#type-expressions
220220
[_WhereClause_]: items/generics.html#where-clauses
221221
[bounds]: trait-bounds.html
222-
[trait object]: types.html#trait-objects
222+
[trait object]: types/trait-object.html
223223
[explicit]: expressions/operator-expr.html#type-cast-expressions
224224
[RFC 255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
225225
[associated items]: items/associated-items.html

src/items/type-aliases.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ let _: F = E::A; // OK
3232
[IDENTIFIER]: identifiers.html
3333
[_Generics_]: items/generics.html
3434
[_WhereClause_]: items/generics.html#where-clauses
35-
[_Type_]: types.html
35+
[_Type_]: types.html#type-expressions

src/keywords.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ is possible to declare a variable or method with the name `union`.
118118
119119
[items]: items.html
120120
[Variables]: variables.html
121-
[Type parameters]: types.html#type-parameters
121+
[Type parameters]: types/parameters.html
122122
[loop labels]: expressions/loop-expr.html#loop-labels
123123
[Macros]: macros.html
124124
[attributes]: attributes.html
125125
[Macro placeholders]: macros-by-example.html
126126
[Crates]: crates-and-source-files.html
127127
[union]: items/unions.html
128128
[variants]: items/enumerations.html
129-
[`dyn`]: types.html#trait-objects
129+
[`dyn`]: types/trait-object.html

0 commit comments

Comments
 (0)