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 view_utf8 method to StrChunk #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sphw
Copy link

@sphw sphw commented May 2, 2020

This adds a new method similar to extract_utf8, except it takes Bytes directly.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
/// let s1: &[u8] = b"\xd0\x97\xd0\xb4\xd1\x80\xd0\xb0\xd0";
/// let mut buf = Bytes::from(s1);
///
/// let chunk = StrChunk::view_utf8(buf.clone()).unwrap();
Copy link
Owner

Choose a reason for hiding this comment

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

What's the use case here? Should the caller be able to access the trailing bytes without extra operations? Something like:

let (s, tail) = StrChunk::split_utf8(buf).unwrap();

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