Skip to content

Commit f392917

Browse files
committed
---
yaml --- r: 32761 b: refs/heads/dist-snap c: 7937905 h: refs/heads/master i: 32759: bd2df74 v: v3
1 parent 5c1d80c commit f392917

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 36602a1f7192db32420170415c037d96a0bc60f2
10+
refs/heads/dist-snap: 7937905dbf2a4578cc778370d1e1b0fed385024c
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/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)