BurntSushi / rust-stats

Basic statistical functions on streams for Rust.
The Unlicense
87 stars 18 forks source link

Returns None when mode of iter has more than one #8

Closed milesgranger closed 6 years ago

milesgranger commented 6 years ago

Is this expected behavior?

let vec = vec![0, 0, 0, 1, 1, 1, 2];

assert_eq!(stats::mode(vec.into_iter()), None);

Seems to me it should return a Vec<T> rather than T

BurntSushi commented 6 years ago

I mean, the type signature says it either returns a single value or nothing, so it sounds like this is expected to me?

I don't have a problem adding another function that returns all possible modes, but I think the existing type signature, name and behavior is expected, yes.

milesgranger commented 6 years ago

Indeed it does as the signature promised..I'm sorry, I didn't mean functionally expected behavior, but, I guess logically expected...(for lack of better name).

No hurry on adding that functionality; I really appreciate all your work in the Rust area. Makes it a bit more accessible for noobies like me. :)

BurntSushi commented 6 years ago

No problem! PRs are welcome for this. I don't know when I'll add it.

milesgranger commented 6 years ago

I'll take a stab at it.