Last active
March 24, 2023 08:51
-
-
Save kivikakk/ea0861d78ecaeb3a93f38b86a583b037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn rtrim_slice_a(i: &[u8]) -> &[u8] { | |
let mut len = i.len(); | |
while len > 0 && isspace(i[len - 1]) { | |
len -= 1; | |
} | |
&i[..len] | |
} | |
pub fn rtrim_slice_b(mut i: &[u8]) -> &[u8] { | |
let mut len = i.len(); | |
while len > 0 && isspace(i[len - 1]) { | |
i = &i[..len - 1]; | |
len -= 1; | |
} | |
i | |
} | |
pub fn rtrim_slice_c(mut i: &[u8]) -> &[u8] { | |
let mut len = i.len(); | |
while len > 0 && isspace(i[len - 1]) { | |
len -= 1; | |
} | |
i = &i[..len]; | |
i | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment