Skip to content

Commit

Permalink
Use .to_string() instead of String::from_utf8_lossy
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmusgo committed May 19, 2024
1 parent 8f5b67e commit 547deb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,10 @@ impl Parser {
bytes => {
let cstr = CStr::from_bytes_with_nul(bytes)
.expect("extension names should be null terminated strings");
let string = String::from_utf8_lossy(cstr.to_bytes()).to_string();
let string = cstr
.to_str()
.expect("extension names should be valid UTF-8")
.to_string();
out.other.push(string);
}
}
Expand Down
5 changes: 4 additions & 1 deletion openxr/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,10 @@ impl ExtensionSet {
bytes => {
let cstr = CStr::from_bytes_with_nul(bytes)
.expect("extension names should be null terminated strings");
let string = String::from_utf8_lossy(cstr.to_bytes()).to_string();
let string = cstr
.to_str()
.expect("extension names should be valid UTF-8")
.to_string();
out.other.push(string);
}
}
Expand Down

0 comments on commit 547deb1

Please sign in to comment.