Skip to content

Commit 36602a1

Browse files
committed
tutorial: Convert the type list to a more compact table
1 parent 0cabd6f commit 36602a1

File tree

2 files changed

+37
-52
lines changed

2 files changed

+37
-52
lines changed

doc/rust.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,16 @@ blockquote {
8181
border-left: solid 1px silver;
8282
margin: 1em;
8383
padding: 0.5em 1em 0.5em 1em;
84-
}
84+
}
85+
86+
/* Make the table under the tutorial's 'Types' section look nicer */
87+
table {
88+
border-top: 1px solid silver;
89+
border-bottom: 1px solid silver;
90+
padding: 0.8em;
91+
font-size: smaller;
92+
}
93+
/* Also for the benefit of the type table
94+
td {
95+
padding-right: 1em;
96+
}

doc/tutorial.md

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -354,67 +354,40 @@ grow on you (hopefully).
354354

355355
## Types
356356

357-
The basic types are written like this:
358-
359-
`()`
360-
: Nil, the type that has only a single value.
361-
362-
`bool`
363-
: Boolean type, with values `true` and `false`.
364-
365-
`int`
366-
: A machine-pointer-sized integer.
367-
368-
`uint`
369-
: A machine-pointer-sized unsigned integer.
370-
371-
`i8`, `i16`, `i32`, `i64`
372-
: Signed integers with a specific size (in bits).
373-
374-
`u8`, `u16`, `u32`, `u64`
375-
: Unsigned integers with a specific size.
376-
377-
`float`
378-
: The largest floating-point type efficiently supported on the target
379-
machine.
380-
381-
`f32`, `f64`
382-
: Floating-point types with a specific size.
383-
384-
`char`
385-
: A Unicode character (32 bits).
357+
The basic types include the usual boolean, integral, and floating point types.
358+
359+
------------------------- -----------------------------------------------
360+
`()` Nil, the type that has only a single value
361+
`bool` Boolean type, with values `true` and `false`
362+
`int`, `uint` Machine-pointer-sized signed and unsigned integers
363+
`i8`, `i16`, `i32`, `i64` Signed integers with a specific size (in bits)
364+
`u8`, `u16`, `u32`, `u64` Unsigned integers with a specific size
365+
`float` The largest floating-point type efficiently supported on the target machine
366+
`f32`, `f64` Floating-point types with a specific size.
367+
`char` A Unicode character (32 bits).
368+
------------------------- -----------------------------------------------
386369

387370
These can be combined in composite types, which will be described in
388371
more detail later on (the `T`s here stand for any other type):
389372

390-
`[T * N]`
391-
: Vector (like an array in other languages) with N elements.
392-
393-
`[mut T * N]`
394-
: Mutable vector with N elements.
395-
396-
`(T1, T2)`
397-
: Tuple type. Any arity above 1 is supported.
398-
399-
`@T`, `~T`, `&T`
400-
: Pointer types. See [Boxes and pointers](#boxes-and-pointers) for an explanation of what `@`, `~`, and `&` mean.
373+
------------------------- -----------------------------------------------
374+
`[T * N]` Vector (like an array in other languages) with N elements
375+
`[mut T * N]` Mutable vector with N elements
376+
`(T1, T2)` Tuple type. Any arity above 1 is supported
377+
`@T`, `~T`, `&T` [Pointer types](#boxes-and-pointers)
378+
------------------------- -----------------------------------------------
401379

402380
Some types can only be manipulated by pointer, never directly. For instance,
403381
you cannot refer to a string (`str`); instead you refer to a pointer to a
404382
string (`@str`, `~str`, or `&str`). These *dynamically-sized* types consist
405383
of:
406384

407-
`fn(arg1: T1, arg2: T2) -> T3`
408-
: Function types.
409-
410-
`str`
411-
: String type (in UTF-8).
412-
413-
`[T]`
414-
: Vector with unknown size (also called a slice).
415-
416-
`[mut T]`
417-
: Mutable vector with unknown size.
385+
------------------------- -----------------------------------------------
386+
`fn(a: T1, b: T2) -> T3` Function types
387+
`str` String type (in UTF-8)
388+
`[T]` Vector with unknown size (also called a slice)
389+
`[mut T]` Mutable vector with unknown size
390+
------------------------- -----------------------------------------------
418391

419392
Types can be given names with `type` declarations:
420393

0 commit comments

Comments
 (0)