fix(unstable): support importing files in npm packages as bytes and text (#30065)

This commit is contained in:
David Sherret 2025-07-10 15:06:33 -04:00 committed by GitHub
parent a046f2c1bf
commit cf441584a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 545 additions and 349 deletions

View file

@ -7,6 +7,7 @@ pub fn is_valid_utf8(bytes: &[u8]) -> bool {
matches!(String::from_utf8_lossy(bytes), Cow::Borrowed(_))
}
// todo(https://github.com/rust-lang/rust/issues/129436): remove once stabilized
#[inline(always)]
pub fn from_utf8_lossy_owned(bytes: Vec<u8>) -> String {
match String::from_utf8_lossy(&bytes) {