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

Strings? #26

Open
Rudxain opened this issue Oct 7, 2024 · 3 comments
Open

Strings? #26

Rudxain opened this issue Oct 7, 2024 · 3 comments

Comments

@Rudxain
Copy link

Rudxain commented Oct 7, 2024

Something like:

pub struct NEstr<'a>(char, &'a str);
pub struct NEString(char, String);
@fosskers
Copy link
Owner

fosskers commented Oct 7, 2024

This has occurred to me in the past. Can you think of any UTF-8 implications that might arise?

@Rudxain
Copy link
Author

Rudxain commented Oct 9, 2024

IIRC, Rust slices at bytes, not chars. And since char is always a 4octet code-point, while str uses a non-fixed-width encoding, it might be non-trivial to define how slicing should work here 🤔🙁

@scouten-adobe
Copy link

@Rudxain you might be interested in https://crates.io/crates/non-empty-string

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

3 participants