From 44f3260fbefad33fd639f4edc6baf043af785de4 Mon Sep 17 00:00:00 2001 From: taohua <4320960+datewu@users.noreply.github.com> Date: Sat, 18 May 2024 23:56:39 +0800 Subject: [PATCH] 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> --- book/src/04_traits/08_from.md | 4 ++-- exercises/04_traits/08_from/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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, -- 2.45.2