From a2ff06e856d19dca5da4582c214c85238500a948 Mon Sep 17 00:00:00 2001
From: Steve Klabnik
You can separate multiple arguments with a comma:
-fn NAME(PATTERN, PATTERN, PATTERN, PATTERN...) {
+fn NAME(PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE...) {
Here’s a full example:
fn main() {
@@ -184,7 +184,7 @@ only its parameters are in scope, so we need to use those names. Bindings
passed as parameters don’t need to have the same name as the arguments.
Return values
Functions can also return values back to the function that called them:
-fn NAME(PATTERN, PATTERN, PATTERN, PATTERN...) -> TYPE {
+fn NAME(PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE...) -> TYPE {
We don’t name return values, but we do declare their type, after an arrow:
->. Here’s a sample program:
diff --git a/print.html b/print.html
index 7a7e8e8b3..4588bc8d7 100644
--- a/print.html
+++ b/print.html
@@ -966,7 +966,7 @@ fn another_function(x: i32) {
type. This is a deliberate decision; we find that requiring type annotations in
functions means that you almost never need them anywhere else.
You can separate multiple arguments with a comma:
-fn NAME(PATTERN, PATTERN, PATTERN, PATTERN...) {
+fn NAME(PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE...) {
Here’s a full example:
fn main() {
@@ -1011,7 +1011,7 @@ only its parameters are in scope, so we need to use those names. Bindings
passed as parameters don’t need to have the same name as the arguments.
Return values
Functions can also return values back to the function that called them:
-fn NAME(PATTERN, PATTERN, PATTERN, PATTERN...) -> TYPE {
+fn NAME(PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE, PATTERN: TYPE...) -> TYPE {
We don’t name return values, but we do declare their type, after an arrow:
->. Here’s a sample program: