Skip to content

Commit a9316fa

Browse files
committed
---
yaml --- r: 24099 b: refs/heads/master c: 7937905 h: refs/heads/master i: 24097: eabb938 24095: d27837f v: v3
1 parent 0f1cb44 commit a9316fa

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 36602a1f7192db32420170415c037d96a0bc60f2
2+
refs/heads/master: 7937905dbf2a4578cc778370d1e1b0fed385024c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/doc/tutorial.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ of:
389389
`[mut T]` Mutable vector with unknown size
390390
------------------------- -----------------------------------------------
391391

392+
In function types, the return type is specified with an arrow, as in
393+
the type `fn() -> bool` or the function declaration `fn foo() -> bool
394+
{ }`. For functions that do not return a meaningful value, you can
395+
optionally write `-> ()`, but usually the return annotation is simply
396+
left off, as in `fn main() { ... }`.
397+
392398
Types can be given names with `type` declarations:
393399

394400
~~~~
@@ -402,28 +408,6 @@ error. Read about [single-variant enums](#single_variant_enum)
402408
further on if you need to create a type name that's not just a
403409
synonym.
404410

405-
## Using types
406-
407-
The `-> bool` in the `is_four` example is the way a function's return
408-
type is written. For functions that do not return a meaningful value,
409-
you can optionally say `-> ()`, but usually the return annotation is simply
410-
left off, as in the `fn main() { ... }` examples we've seen earlier.
411-
412-
Every argument to a function must have its type declared (for example,
413-
`x: int`). Inside the function, type inference will be able to
414-
automatically deduce the type of most locals (generic functions, which
415-
we'll come back to later, will occasionally need additional
416-
annotation). Locals can be written either with or without a type
417-
annotation:
418-
419-
~~~~
420-
// The type of this vector will be inferred based on its use.
421-
let x = [];
422-
# vec::map(x, fn&(_y: &int) -> int { *_y });
423-
// Explicitly say this is a vector of zero integers.
424-
let y: [int * 0] = [];
425-
~~~~
426-
427411
## Numeric literals
428412

429413
Integers can be written in decimal (`144`), hexadecimal (`0x90`), and

0 commit comments

Comments
 (0)