It is waste of resources to go for full 2..integer as if we know that if n divides integer then integer / n divides it as well as a / b = c <=> a / c = b. So instead of going for full range we can go up to sqrt(integer).
Another thing is that turbofish operator in collect is completely unneeded as it can be deduced by the compilator from return type.
This is awesome! I love how you used the filter and collect functions, but you could have gotten away with limiting the size of the range to (2..(integer/2)+1).
Correction:
I believe turbofish (or type annotation) is necessary because the type of
divs
needs to be known at point ofdivs.len()
call.Tested with
1.50.0
.It is waste of resources to go for full
2..integer
as if we know that ifn
dividesinteger
theninteger / n
divides it as well asa / b = c <=> a / c = b
. So instead of going for full range we can go up tosqrt(integer)
.Another thing is that turbofish operator in
collect
is completely unneeded as it can be deduced by the compilator from return type.This is awesome! I love how you used the filter and collect functions, but you could have gotten away with limiting the size of the range to (2..(integer/2)+1).