average icon indicating copy to clipboard operation
average copied to clipboard

Return `Option` instead of `NaN`

Open Shatur opened this issue 1 year ago • 2 comments

When the number of samples is less then required, methods from this crate usually returns NaN. It's correct, but requires user to check the result or verify the number of samples.

Maybe return Option instead? This will be consistent with other methods on Iterator.

Shatur avatar May 13 '24 10:05 Shatur

We could add a try_* API returning an Option or Result, but I'm not sure it's possible to guarantee no NaN is returned due to other reasons.

vks avatar May 13 '24 17:05 vks

but I'm not sure it's possible to guarantee no NaN is returned due to other reasons

Sure, but at least it won't return NaN for an empty iterator. I would make this default behavior, without additional try_* method.

Shatur avatar May 20 '24 08:05 Shatur