Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Option instead of NaN #29

Open
Shatur opened this issue May 13, 2024 · 2 comments
Open

Return Option instead of NaN #29

Shatur opened this issue May 13, 2024 · 2 comments

Comments

@Shatur
Copy link

Shatur commented May 13, 2024

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.

@vks
Copy link
Owner

vks commented May 13, 2024

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.

@Shatur
Copy link
Author

Shatur commented May 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants