How String::from accepts String type as parameter?

37 points zxaq15

I know that &String can be used as a parameter for &str type because of rust's deref coercion.

But the code below also works.

let s1 = String::from("Hello");
let s2 = String::from(s1);

The type of result of String::from is String.

The parameter type of String::from is &str.

What's the magic behind String::from??

please explain it in detail..