error[E0271]: type mismatch resolving `<std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>> as IntoIterator>::Item == (fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)`
--> src/lib.rs:8:10
|
8 | .chain(
| ^^^^^ expected struct `std::string::String`, found fn item
|
= note: expected type `(std::string::String, Value)`
found tuple `(fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)`
error[E0599]: the method `collect` exists for struct `std::iter::Chain<std::iter::Once<(fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)>, std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>>>`, but its trait bounds were not satisfied
--> src/lib.rs:28:10
|
28 | .collect(),
| ^^^^^^^ method cannot be called on `std::iter::Chain<std::iter::Once<(fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)>, std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>>>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`<std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>> as Iterator>::Item = (fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)`
which is required by `std::iter::Chain<std::iter::Once<(fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)>, std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>>>: Iterator`
`std::iter::Chain<std::iter::Once<(fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)>, std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>>>: Iterator`
which is required by `&mut std::iter::Chain<std::iter::Once<(fn(_) -> std::string::String {<std::string::String as From<_>>::from}, Value)>, std::iter::Chain<std::iter::Once<(std::string::String, Value)>, std::iter::Chain<std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:18:26: 18:58]>, std::iter::Map<std::iter::Map<std::iter::Map<std::option::Iter<'_, &str>, fn(&&str) -> std::result::Result<Value, serde_json::Error> {to_value::<&&str>}>, fn(std::result::Result<Value, serde_json::Error>) -> Value {std::result::Result::<Value, serde_json::Error>::unwrap}>, [closure@src/lib.rs:24:34: 24:69]>>>>: Iterator`
I've accidentally used a function (
String::from) instead of a function call (String::from("...")) and the error was hard to read. Maybe it can be improved. (playground)Code
Error
(this error is from
1.51.0-nightly (2021-01-30 04caa632dd10c2bf64b6), previous compiler versions produce similar errors)