Use Result::ok. Types added for clarity:
let res: Result<u8, ()> = Ok(42);
let opt: Option<u8> = res.ok();
println!("{:?}", opt);
For symmetry’s sake, there’s also Option::ok_or and Option::ok_or_else to go from an Option to a Result.
In your case, you have an iterator.
If you’d like to ignore failures, use Iterator::flat_map. Since Result (and Option) implement IntoIterator, this works:
let parsed_value: Vec<usize> = val
.iter()
.flat_map(|e| e.parse())
.collect();
If you’d like to stop on the first failure, you can collect into one big Result. This is less obvious, but you can check out the implementors of FromIterator for the full list of collect-able items.
let parsed_value: Result<Vec<usize>, _> = val
.iter()
.map(|e| e.parse())
.collect();
Of course, you can then convert the one big Result into an Option, as the first example shows.