Intermediate
Rust
Q83 / 100
What is the From<&str> for String vs Into<String> pattern?
Correct! Well done.
Incorrect.
The correct answer is B) String::from("hello") uses From; "hello".to_string() and "hello".into() (when context is String) use Into. All are zero-overhead allocations
B
Correct Answer
String::from("hello") uses From; "hello".to_string() and "hello".into() (when context is String) use Into. All are zero-overhead allocations
Explanation
Because From<T> for U is implemented, U: Into<T> is auto-implemented. Function parameters using impl Into<String> accept both String and &str without explicit conversion.
Progress
83/100