Open mgabs opened 3 years ago
Yep, that's what the api is returning https://crates.io/api/v1/crates/error-chain/reverse_dependencies I thing that's strange field name for the name of the crate.
Sorry, I don't get your comment. What I am saying is the struct is storing the source crate as a member of ReverDep structs. Which is a faulty behaviour.
Further, I couldn't consume elements from the iter. same example:
for dep in ReverseDependencies::of("tokio")? {
// println!("reverse dependency: {:#?}", dep?);
println!("{:#?}", dep?.crate_id);
println!("{:#?}", dep?.req);
}
error[E0382]: use of moved value: `dep`
--> src/main.rs:109:27
|
106 | for dep in ReverseDependencies::of("tokio")? {
| --- move occurs because `dep` has type `std::result::Result<Dependencies, reqwest::Error>`, which does not implement the `Copy` trait
107 | // println!("reverse dependency: {:#?}", dep?);
108 | println!("{:#?}", dep?.crate_id);
| ---- `dep` moved due to this method call
109 | println!("{:#?}", dep?.req);
| ^^^ value used here after move
|
note: this function consumes the receiver `self` by taking ownership of it, which moves `dep`
What is the best way to address that ?
I mean if you go to the link I provided you will see this: {"dependencies":[{"id":987053,"version_id":188578,"crate_id":"error-chain","req":"^0.12","optional":false,"default_features":false,"features":[],"target":null,"kind":"normal","downloads":3135857}
The API returns crate_id = crate name
"crate_id":"error-chain"
error[E0382]: use of moved value: dep
When you follow dep by the ? you are performing an operation on it. You can do let depends=dep?;
and then println! it twice
When I run the program it doesn't return the value of the crate_id, instead it returns a copy of the calling argument that had been stored in the RD vector. (Duplicate value).
I tried that approach but the compiler complained about the clone trait not available for type iter.
Regards, Mohammed
On Dec 1, 2020, 5:37 PM, at 5:37 PM, Andrew Gauger notifications@github.com wrote:
I mean if you go to the link I provided you will see this: {"dependencies":[{"id":987053,"version_id":188578,"crate_id":"error-chain","req":"^0.12","optional":false,"default_features":false,"features":[],"target":null,"kind":"normal","downloads":3135857}
The API returns crate_id = crate name
"crate_id":"error-chain"
error[E0382]: use of moved value:
dep
When you follow dep by the ? you are performing an operation on it. You can dolet depends=dep?;
and then println! it twice-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/rust-lang-nursery/rust-cookbook/issues/620#issuecomment-736631875
Link - https://rust-lang-nursery.github.io/rust-cookbook/web/clients/apis.html#consume-a-paginated-restful-api
When i run the example at retrieves the dependencies however, the crate_id is populated with the source crate name.. example.