From 05cc2ff4805e5cfd97cbe97552201a3f108e723d Mon Sep 17 00:00:00 2001 From: Igor Petruk Date: Mon, 23 Jan 2023 13:18:34 +0000 Subject: [PATCH] Update from-into.md (#245) Explaining how those traits are used in practice and when you should use one over another. --- src/traits/from-into.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/traits/from-into.md b/src/traits/from-into.md index 9b1182ac..c25013c6 100644 --- a/src/traits/from-into.md +++ b/src/traits/from-into.md @@ -23,3 +23,11 @@ fn main() { println!("{s}, {addr}, {one}, {bigger}"); } ``` + +
+ +* That's why it is common to only implement `From`, as your type will get `Into` implementation too. +* When declaring a function argument input type like "anything that can be converted into a `String`", the rule is opposite, you should use `Into`. + Your function will accept types that implement `From` and those that _only_ implement `Into`. + +