diff --git a/src/methods-and-traits/exercise.md b/src/methods-and-traits/exercise.md index c11faad6..d7d8830c 100644 --- a/src/methods-and-traits/exercise.md +++ b/src/methods-and-traits/exercise.md @@ -2,7 +2,7 @@ minutes: 20 --- -# Exercise: Generic Logger +# Exercise: Logger Trait Let's design a simple logging utility, using a trait `Logger` with a `log` method. Code which might log its progress can then take an `&impl Logger`. In diff --git a/src/methods-and-traits/exercise.rs b/src/methods-and-traits/exercise.rs index f432c98b..d9c66086 100644 --- a/src/methods-and-traits/exercise.rs +++ b/src/methods-and-traits/exercise.rs @@ -36,12 +36,12 @@ fn do_things(logger: &impl Logger) { // ANCHOR_END: setup /// Only log messages up to the given verbosity level. -struct VerbosityFilter { +struct VerbosityFilter { max_verbosity: u8, - inner: L, + inner: StderrLogger, } -impl Logger for VerbosityFilter { +impl Logger for VerbosityFilter { fn log(&self, verbosity: u8, message: impl Display) { if verbosity <= self.max_verbosity { self.inner.log(verbosity, message);