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

ThreadPoolBuilder::pool_size accepts NonZeroUsize #1803

Closed
wants to merge 1 commit into from
Closed

ThreadPoolBuilder::pool_size accepts NonZeroUsize #1803

wants to merge 1 commit into from

Conversation

vorot93
Copy link
Contributor

@vorot93 vorot93 commented Aug 14, 2019

Let's put more invariants into the type system, shall we?

@cramertj
Copy link
Member

What's the goal here? IMO this reads kind of annoyingly and I can't really imagine a client doing anything interesting here.

@vorot93
Copy link
Contributor Author

vorot93 commented Aug 29, 2019

Please do remember that your average Joe programmer may assume zero to be an 'auto' (num of CPU threads) and not an invalid value and get the panic. To avoid stepping on this mine, he must read the documentation carefully. This PR moves this semi-unwritten contract into the type system which will lead to less unwanted panics among downstream users.

@cramertj
Copy link
Member

Thanks for the PR-- I appreciate efforts to express more invariants with the typesystem in order to prevent runtime failures. However, I'm going to close this PR because I think it's a pretty significant ergonomic hit for the majority of users, and I don't think it's going to benefit the typical usage. Users who accidentally misuse the function and provide 0 should immediately get an appropriate panic and be able to easily fix the error.

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

Successfully merging this pull request may close these issues.

None yet

2 participants