From c253b3397709dec97c99d91bd579d70b8e6b3e3a Mon Sep 17 00:00:00 2001 From: Nicole L Date: Thu, 26 Jun 2025 12:09:38 -0700 Subject: [PATCH] Add note about trait bound in closures exercise (#2788) I've tried removing this trait bound thinking it's unnecessary only to then be surprised that it breaks type inference. I think that's worth calling out to students, so I think a speaker note here would be appropriate. --- src/closures/solution.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/closures/solution.md b/src/closures/solution.md index b4a4c92c..c99a554a 100644 --- a/src/closures/solution.md +++ b/src/closures/solution.md @@ -3,3 +3,12 @@ ```rust,editable {{#include exercise.rs:solution}} ``` + +
+ +- Note that the `P: Fn(u8, &str) -> bool` bound on the first `Filter` impl block + isn't strictly necessary, but it helps with type inference when calling `new`. + Demonstrate removing it and showing how the compiler now needs type + annotations for the closure passed to `new`. + +