Functions
The fn
keyword is used to define new functions.
fn
キーワードは新しい関数を定義するために使用されます。
The double
and multiply
functions are defined
without the pub
keyword. This makes them private
functions, they can only be used within this module. If another module
attempted to use them it would result in a compiler error.
double
関数と multiply
関数は pub
キーワードを付けずに定義されています。このため、これらはプライベート関数となり、このモジュールのみで使用することができます。他のモジュールがこれらを使おうとすると、コンパイルエラーになります。
Like with assignments, type annotations are optional for function arguments and return values. It is considered good practice to use type annotations for functions, for clarity and to encourage intentional and thoughtful design.
代入と同様に、関数の引数や返値に対する型アノテーションは省略可能です。関数に型アノテーションを使用するのは、わかりやすく、意図的で思慮深い設計を促すためのグッドプラクティスと考えられています。