The doc-comment for IndexedRandom::choose_weighted says:
Returns None if and only if self.is_empty()
but the function doesn't return an Option; it returns a Result. In particular it seems to return WeightError::InvalidInput if the sequence is empty.
I notice that choose_weighted_iter also is documented to return None in this case despite not returning an Option, but haven't tested the actual behavior. (Probably the same error? Maybe an empty iterator?)
The doc-comment for IndexedRandom::choose_weighted says:
but the function doesn't return an
Option; it returns aResult. In particular it seems to returnWeightError::InvalidInputif the sequence is empty.I notice that
choose_weighted_iteralso is documented to returnNonein this case despite not returning anOption, but haven't tested the actual behavior. (Probably the same error? Maybe an empty iterator?)