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

Add ZeroVec::owned_capacity #3431

Merged
merged 2 commits into from
May 13, 2023
Merged

Add ZeroVec::owned_capacity #3431

merged 2 commits into from
May 13, 2023

Conversation

sffc
Copy link
Member

@sffc sffc commented May 12, 2023

Adding some code from a branch.

@sffc sffc requested a review from Manishearth as a code owner May 12, 2023 23:41
/// assert_eq!(zv.owned_capacity(), Some(8.try_into().unwrap()));
/// ```
#[inline]
pub fn owned_capacity(&self) -> Option<NonZeroUsize> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I think having the method be .capacity() and returning an integer is also fine, "Borrowed is zero capacity" is a consistent and sensical statement, and generally useful. (if most people are going to unwrap_or(0) this API, might as well)

but not opposed to this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be more type-safe and explicit.

@sffc sffc merged commit a4ba914 into unicode-org:main May 13, 2023
@sffc sffc deleted the zerovec_cap branch May 13, 2023 06:14
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.

2 participants