-
Notifications
You must be signed in to change notification settings - Fork 26
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
Replacement for String::from_utf8
#73
Comments
That would be effectively the same as Note that there was some discussion in the past about putting it in the standard library directly: https://www.reddit.com/r/rust/comments/mvc6o5/incredibly_fast_utf8_validation/ |
Thanks for the answer! |
Ah I forgot the original problem. |
Looking into the implementation of from_utf8 this should be quite easy to add #[inline]
pub fn from_utf8(input: &[u8]) -> Result<&str, Utf8Error> {
unsafe {
validate_utf8_basic(input)?;
Ok(from_utf8_unchecked(input))
}
} and we just add pub mod string {
pub use super::*;
#[inline]
pub fn from_utf8(input: Vec<u8>) -> Result<String, Utf8Error> {
unsafe {
validate_utf8_basic(&input)?;
Ok(String::from_utf8_unchecked(input))
}
}
} |
Currently there is no safe relpacement for
String::from_utf8
in simdutf8. I think it is easy to add a function for this.The text was updated successfully, but these errors were encountered: