6.1 Function declaration
fn name<Generics>(params) -> ReturnType effects where Constraints { body }
fn name(params) -> ReturnType effects => expression- Without
-> Tthe return type is()(for private functions with a body=> ethe type is inferred frome). - A parameter:
name: T, with a default valuename: T = e(evaluated on every call where the argument is omitted). - A variadic last parameter:
...xs: T— has type[T]inside the function. - Call: positional arguments, then named ones (
greet("Ann", loud: true)). A positional argument after a named one is forbidden. - Passing: by value (move or copy). A
&Tparameter is borrowed automatically; for&var Tthe call site MUST write&var x.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md