These are chat archives for rust-lang/rust
let x: String = ...what is the difference between
x.as_str()? Do I miss something or weren't these variants equivalent at some point of time?
From<_>for my types or
Into<_>? What is more idiomatic?
@Crazy-Owl From implies Into while backwards is not true, docs on Into recommend using From:
Library authors should not directly implement this trait, but should prefer implementing the From trait, which offers greater flexibility and provides an equivalent Into implementation for free, thanks to a blanket implementation in the standard library.
Fromis more useful in most situations. And if you define
Intowill be implemented by compiler
Intothen? I've never understood the purpose of that
X, I should use
Into<X>as my trait bound, but when implementing
X, I should provide implementations of
From<_>traits for types I want to be convertible?