The above compiles but I'm wondering if there's a way to make one of the functions, d8_dice(), a single expression function? (i.e. one line instead of two)
In the last thing you tried, did you happen to leave the semicolon at the end of the line? What you wrote should work
Your first attempt is probably that you were trying to use a method from the itertools crate which would require use itertools::Itertools to be able to use the methods from that trait.
Note:
In the future include the full error message and not just a snippet. It makes it much easier for people on this forum to understand the issue that you’re running into.
And since d8 is already a fn() -> u8, you can even skip the closure:
std::iter::repeat_with(d8).take(num).collect()
Also @rwat unless I'm mistaken you want an inclusive range in the definition of d8, so 1..=8 instead of 1..8—the latter doesn't include the right endpoint 8, so it would give you a d7 instead!