From 451f4c675c417b5d4e267ff343312d66b70e6514 Mon Sep 17 00:00:00 2001 From: jfecher Date: Tue, 24 Oct 2023 10:21:36 -0500 Subject: [PATCH] Update docs/docs/language_concepts/01_functions.md --- docs/docs/language_concepts/01_functions.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/docs/language_concepts/01_functions.md b/docs/docs/language_concepts/01_functions.md index b47cdc4a1ee..a369d4a3cab 100644 --- a/docs/docs/language_concepts/01_functions.md +++ b/docs/docs/language_concepts/01_functions.md @@ -152,6 +152,14 @@ fn main() { } ``` +Also note that impls with the same method name defined in them cannot overlap. For example, if we already have `foo` defined for `Foo` and `Foo` like we do above, we cannot also define `foo` in an `impl Foo` since it would be ambiguous which version of `foo` to choose. + +```rs +// Including this impl in the same project as the above snippet would +// cause an overlapping impls error +impl Foo { + fn foo(self) -> Field { 3 } +} ## Lambdas Lambdas are anonymous functions. They follow the syntax of Rust - `|arg1, arg2, ..., argN| return_expression`.