https://atcoder.jp/contests/abc245/tasks/abc245_b
read_setを書いてみましたが、たくさんTraitが要りますね。
// Mex #![allow(non_snake_case)] use std::collections::HashSet; fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } fn read_set<T: std::str::FromStr + std::cmp::Eq + std::hash::Hash>() -> HashSet<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } fn main() { let _N: usize = read(); let s: HashSet<usize> = read_set(); for i in 0usize.. { if !s.contains(&i) { println!("{}", i); break } } }