Skip to content

Instantly share code, notes, and snippets.

@alicemaz
Created December 3, 2015 03:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alicemaz/cd21cc42b58b05c50b29 to your computer and use it in GitHub Desktop.
Save alicemaz/cd21cc42b58b05c50b29 to your computer and use it in GitHub Desktop.
let bytes = input.as_bytes();
let mut raw = Vec::<u8>::with_capacity(input.len());
for (offset, codepoint) in input.char_indices() {
let c = codepoint as u32;
if (c > 0x40 && c < 0x5b) || (c > 0x60 && c < 0x7b) ||
(c > 0x29 && c < 0x3a) || c == 0x2b || c == 0x2f {
raw.push(bytes[offset]);
} else if codepoint.is_whitespace() || c == 0x3d {
;
} else {
panic!("change this to error when I add return type");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment