fix: remove ambiguous .into() example from strings4

The `"nice weather".into()` line could be solved with either
`string_slice` or `string`. The `string_slice` choice compiled and
passed the exercise while emitting a `clippy::useless_conversion`
warning, so the exercise could pass with a warning still present.

Understanding why `.into()` works for both targets requires the `From`
trait, which rustlings introduces later. Remove the example from the
exercise and solution.

Fixes #2190
This commit is contained in:
minsung.cho 2026-05-23 18:27:34 -07:00
parent 60b369a2fd
commit 939777825f
2 changed files with 0 additions and 11 deletions

View File

@ -21,8 +21,6 @@ fn main() {
placeholder("rust is fun!".to_owned()); placeholder("rust is fun!".to_owned());
placeholder("nice weather".into());
placeholder(format!("Interpolation {}", "Station")); placeholder(format!("Interpolation {}", "Station"));
// WARNING: This is byte indexing, not character indexing. // WARNING: This is byte indexing, not character indexing.

View File

@ -15,15 +15,6 @@ fn main() {
string("rust is fun!".to_owned()); string("rust is fun!".to_owned());
// Here, both answers work.
// `.into()` converts a type into an expected type.
// If it is called where `String` is expected, it will convert `&str` to `String`.
string("nice weather".into());
// But if it is called where `&str` is expected, then `&str` is kept as `&str` since no conversion is needed.
// If you remove the `#[allow(…)]` line, then Clippy will tell you to remove `.into()` below since it is a useless conversion.
#[allow(clippy::useless_conversion)]
string_slice("nice weather".into());
string(format!("Interpolation {}", "Station")); string(format!("Interpolation {}", "Station"));
// WARNING: This is byte indexing, not character indexing. // WARNING: This is byte indexing, not character indexing.