DEV Community

Discussion on: My Solutions for Perfect Number in Several Languages

Collapse
 
grayjack profile image
GrayJack • Edited

In rust, there 2 idiomatic way to do the main()

Your version is idiomatic, but there also this way:

fn main(){
  (1..10_000).filter(|x| is_perfect(*x)).for_each(|x| println!("{}", x));
}

For something simple like this, I would use this version

Collapse
 
chenge profile image
chenge

This is like Ruby, nice.