In #rust #rustlang, in trait implementations, is there a reason to use the raw type instead of the Into type? Does the Into version just save me from having to type ".into()" or is there more to it?

For example:

impl<'a> From<&'a str> for Foo<'a>

versus

impl<'a, T: Into<&'a str>> From<T> for Foo<'a>

@livingcoder Working with Into instead of the raw type is sometimes unneeded complexity. Personally, I only use it when I want to save the into().

Defaulting to raw types is better to avoid conflicts. Let's say you implement From<T> where T: Into<U>. If V implements Into<U>, then you can not implement a specific From<V> anymore.

Rust Playground

A browser interface to the Rust compiler to experiment with the language

@mo8it That's interesting. Thank you. Hmm. I would hope that the impl block that fails wouldn't actually be necessary/needed given the existing impl block... but I guess you never know what someone may want functionality-wise for special cases.