Skip to content

Conversation

WuBingzheng
Copy link

Add len_u16 and len_u8 features to change the type of LenUint.

Using u8 as LenUint saves 3 bytes. This is useful for many really small strings.

@WuBingzheng WuBingzheng changed the title Add len_u16 and len_u8 features. Add len_u16 and len_u8 features to change the type of LenUint Sep 29, 2023
@GnomedDev
Copy link

This should not be a feature, as features should be entirely additive. I would recommend making it a generic, maybe?

@WuBingzheng
Copy link
Author

I do not know how to make it a generic. Use the num trait?

pub struct ArrayVec<T, L, const CAP: usize>
where L: num::Num
{
    xs: [MaybeUninit<T>; CAP],
    len: L,
}

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