You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there is a type T for which FromStr and FromIterator are implemented and is used in an option as Vec<T> or Option<Vec<T>>, the build will fail by the following error.
error[E0282]: type annotations needed
--> tests/issues.rs:140:18
|
140 | opt_vec: Vec<u16>,
| ---------^^^^^^^^
| | |
| | cannot infer type for type parameter `B` declared on the associated function `map`
| this method call resolves to `T`
This map has two possible types, thus the type inference needs an annotation and the build fails.
// u16
opt_vec: matches.values_of("opt_vec").map_or_else(Vec::new, |v| {
v.map::<u16,_>(|s| ::std::str::FromStr::from_str(s).unwrap()).collect()}),// Or, U16ish is also possible
opt_vec: matches.values_of("opt_vec").map_or_else(Vec::new, |v| {
v.map::<U16ish,_>(|s| ::std::str::FromStr::from_str(s).unwrap()).collect()}),
This situation may sound unlikely at first, but it actually happens when you use Structopt with Indicatif crate on Windows. Indicatif defines Utf16Char on Windows and it causes this error.
I've also submitted a PR #491 to fix this. Thanks!
The text was updated successfully, but these errors were encountered:
If there is a type
T
for whichFromStr
andFromIterator
are implemented and is used in an option asVec<T>
orOption<Vec<T>>
, the build will fail by the following error.The whole example code is
The reason of this build failure is the type of the
map
in the expanded code becomes ambiguous due toU16ish
.This
map
has two possible types, thus the type inference needs an annotation and the build fails.This situation may sound unlikely at first, but it actually happens when you use Structopt with Indicatif crate on Windows. Indicatif defines
Utf16Char
on Windows and it causes this error.I've also submitted a PR #491 to fix this. Thanks!
The text was updated successfully, but these errors were encountered: