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

feat: add unsafe Utf8Bytes::from_bytes_unchecked #476

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

Totodore
Copy link
Contributor

@Totodore Totodore commented Dec 20, 2024

I'm in a case where I already have a Utf8Bytes equivalent in my own codebase (a simple Bytes wrapper), therefore I am sure that this [Bytes] is valid utf8 data and I want to convert it to a Utf8Bytes.

However there is currently now way to construct a Utf8Bytes without checking the encoding even if we are sure about it.

I propose to add the from_bytes_unchecked which is similar to String::from_utf8_unchecked.

@daniel-abramov daniel-abramov merged commit 7632848 into snapview:master Jan 8, 2025
7 checks passed
@Totodore Totodore deleted the feat-utf8bytes-unsafe branch January 8, 2025 22:46
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