1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

fix: avoid usage of .unwrap in Rust solutions

This commit is contained in:
2023-08-21 22:45:05 +02:00
parent 5b3048f305
commit 2386ea012d
8 changed files with 38 additions and 15 deletions

View File

@ -4,8 +4,11 @@ fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
let line = line.expect("Failed to read `stdin` line.");
let number: i64 = line
.trim()
.parse()
.expect("Failed to convert `number` as an `i64`.");
numbers.push(number);
}
numbers.sort();