2
Почему это«тип этого значения должен быть известен в этом контексте» при вызове собирать
fn main() {
let test = "5% of foo".to_string();
let result: i32 = test.split('%').collect()[0].parse().unwrap_or(0);
}
причиной ошибки
error: the type of this value must be known in this context
let result = test.split('%').collect()[0].parse().unwrap_or(0i32);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Это не помогло:
let result: i32 = test.to_string().split('%').collect()[0].parse().unwrap_or(0i32);