backblaze-b2 has a function list_buckets()
that returns Result<Vec<Bucket<InfoType>>,B2Error>
.
However, if I write
let buckets = auth.list_buckets(&client).unwrap();
I get
43 | let buckets = auth.list_buckets(&client).unwrap();
| ------- ^^^^^^^^^^^^ cannot infer type for type parameter `InfoType` declared on the associated function `list_buckets`
| |
| consider giving `buckets` the explicit type `std::vec::Vec<backblaze_b2::raw::buckets::Bucket<InfoType>>`, where the type parameter `InfoType` is specified
Instead I have to write
let buckets: Vec<Bucket> = auth.list_buckets(&client).unwrap();
The definition of Bucket
is:
pub struct Bucket<InfoType=JsonValue> {
...
pub bucket_info: InfoType,
...
}
The compiler already knows from the return type that buckets
is a Vec<Bucket>
. When I write let buckets: Vec<Bucket>
I'm just stating the obvious, aren't I?
Why does it use the default type only when I write the redundant <Bucket>
?