Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c03c22d0ff9f0d88bb0cacb6edb95501
fn foo(x: &str) -> bool {
x.starts_with("hi".to_string() + " you")
}
The current output is:
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): expected a `FnMut<(char,)>` closure, found `String`
--> src/lib.rs:2:19
|
2 | x.starts_with("hi".to_string() + " you")
| ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Pattern<'_>` is not implemented for `String`
| |
| required by a bound introduced by this call
|
= note: the trait bound `String: Pattern<'_>` is not satisfied
= note: required for `String` to implement `Pattern<'_>`
note: required by a bound in `core::str::<impl str>::starts_with`
help: consider borrowing here
|
2 | x.starts_with(&"hi".to_string() + " you")
| +
Ideally the output should look like:
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): expected a `FnMut<(char,)>` closure, found `String`
--> src/lib.rs:2:19
|
2 | x.starts_with("hi".to_string() + " you")
| ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Pattern<'_>` is not implemented for `String`
| |
| required by a bound introduced by this call
|
= note: the trait bound `String: Pattern<'_>` is not satisfied
= note: required for `String` to implement `Pattern<'_>`
note: required by a bound in `core::str::<impl str>::starts_with`
help: consider borrowing here
|
2 | x.starts_with(&("hi".to_string() + " you"))
| ++