Rust: change deprecated functions, use filter_map instead of for-loop