-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
I ran into a case using the csv crate in combination with structopt where I needed to parse a single char from an argument to use as a CSV delimiter. However, it appears that csv::StringBuilder only accepts u8 delimiters. I was surprised to see that there was no type-safe way to convert between char to u8 in the standard library. It would be nice if u8 implemented TryFrom<char>, where the conversion fails if the char value is outside of the U+0000 to U+00FF codepoint range (0-255).
An example use would look like this:
fn main() {
let success = u8::try_from('A').expect("Conversion should have succeeded");
let failure = u8::try_from('我').expect_err("Conversion should have failed");
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Type
Fields
Give feedbackNo fields configured for issues without a type.