From: taohua <4320960+datewu@users.noreply.github.com> Date: Sat, 18 May 2024 15:56:39 +0000 (+0800) Subject: misunderstand the implements verb (#18) X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=44f3260fbefad33fd639f4edc6baf043af785de4;p=rust_exercises.git misunderstand the implements verb (#18) * Update 08_from.md * test * Update exercises/04_traits/08_from/src/lib.rs --------- Co-authored-by: datewu Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> --- diff --git a/book/src/04_traits/08_from.md b/book/src/04_traits/08_from.md index 030e27f..7fef761 100644 --- a/book/src/04_traits/08_from.md +++ b/book/src/04_traits/08_from.md @@ -105,7 +105,7 @@ though the former bound is implicit. In [`std`'s documentation](https://doc.rust-lang.org/std/convert/trait.From.html#implementors) you can see which `std` types implement the `From` trait. -You'll find that `&str` implements `From<&str> for String`. Thus, we can write: +You'll find that `String` implements `From<&str> for String`. Thus, we can write: ```rust let title = String::from("A title"); @@ -129,7 +129,7 @@ where } ``` -If a type `T` implements `From`, then `Into for T` is automatically implemented. That's why +If a type `U` implements `From`, then `Into for T` is automatically implemented. That's why we can write `let title = "A title".into();`. ## `.into()` diff --git a/exercises/04_traits/08_from/src/lib.rs b/exercises/04_traits/08_from/src/lib.rs index 7f082ab..cc6f5b1 100644 --- a/exercises/04_traits/08_from/src/lib.rs +++ b/exercises/04_traits/08_from/src/lib.rs @@ -1,4 +1,4 @@ -// TODO: Implement the `From` trait for the `u32` type to make `example` compile. +// TODO: Implement the `From` trait for the `WrappingU32` type to make `example` compile. pub struct WrappingU32 { value: u32,