pub fn string_to_u64_vec(
strings: Vec<String>,
) -> Vec<Result<u64, ParseIntError>>
Expand description
§string_to_u64_vec(strings)
Converts a vector of strings into a vector of u64
values.
This function attempts to parse each string in the input vector. If a string fails to parse,
the corresponding entry in the output vector will be an Err
containing the parsing error.
§Parameters
strings
: A vector of strings to be converted intou64
values.
§Returns
A Vec<Result<u64, std::num::ParseIntError>>
where each element is a Result
.
An Ok
value represents a successful conversion to u64
, while an Err
value indicates a failure.
§Examples
use mathlab::math::string_to_u64_vec;
fn main() {
let string_numbers = vec![
"42".to_string(),
"100".to_string(),
"not_a_number".to_string(),
"300".to_string(),
];
let results = string_to_u64_vec(string_numbers);
for (i, result) in results.iter().enumerate() {
match result {
Ok(num) => println!("String {} converted to u64: {}", i, num),
Err(e) => println!("Failed to convert string {}: {}", i, e),
}
}
}
End Fun Doc