-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
I tried this code:
let errors = vec![&String::from("hi"), &String::from("world")];
let combined = errors.join(" ");
(This is a contrived example, of course, what I was really doing was borrowing from inside a parsed data structure, which led to the &Strings).
I expected to see this happen: the strings to join together, just as if they were &str or String
Instead, this happened: I received the following error
error[E0599]: the method `join` exists for struct `Vec<&std::string::String>`, but its trait bounds were not satisfied
--> src/main.rs:103:35
|
103 | let combined = errors.join(" ; ");
| ^^^^ method cannot be called on `Vec<&std::string::String>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`<[&std::string::String] as Join<_>>::Output = _`
(Which took me a good while to work out what I needed to do even looking at the source code for Join and such, as this was extremely opaque to someone fairly new to Rust).
Meta
rustc --version --verbose
:
rustc 1.52.0-nightly (35dbef235 2021-03-02)
binary: rustc
commit-hash: 35dbef235048f9a2939dc20effe083ca483c37ff
commit-date: 2021-03-02
host: x86_64-apple-darwin
release: 1.52.0-nightly
LLVM version: 11.0.1
Backtrace
error[E0599]: the method `join` exists for struct `Vec<&std::string::String>`, but its trait bounds were not satisfied
--> src/main.rs:103:35
|
103 | let combined = errors.join(" ; ");
| ^^^^ method cannot be called on `Vec<&std::string::String>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`<[&std::string::String] as Join<_>>::Output = _`
edmorley, NReilingh, GeeWee, xandkar, jpage-godaddy and 6 more
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.