-
Notifications
You must be signed in to change notification settings - Fork 115
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
encode_engine_slice
should probably return a &str
instead of usize
#209
Comments
Unfortunately this isn't really viable as far as I can tell.
|
It seems that I wonder if I can build a crate around ASCII chars which exposes a safe API to construct ASCII strings, would you accept a PR making use of that to eliminate the checks? |
base64_simd::Base64::encode_as_str is exactly what you want. |
@Nugine That looks great. I'll give it a try. Thanks! |
I suggest that
encode_engine_slice
should have a signature likeApparently the encoded result is always a valid string, but the current API leaves a dilemma for some users:
encode_engine
: provides convenientstr
but allocates,encode_engine_slice
: doesn't allocate but doesn't providestr
unsafe
.If
encode_engine_slice
can return astr
, that dilemma would be resolved. The length can still be derived from.len()
of the returnedstr
.There is also a precedent in the Rust std:
char::encode_utf8
encodes into a buffer and returns astr
.This is a breaking change, though.
The text was updated successfully, but these errors were encountered: