Split First Char
A small utility to split a string into the first character (type char
) and the rest (type &str
).
Usage
Function call
use split_first_char;
let = split_first_char.unwrap;
assert_eq!;
assert_eq!;
Method call
use SplitFirstChar;
let = "abc".split_first_char.unwrap;
assert_eq!;
assert_eq!;
Alternative
If you don't need the first character to be a char
, just use str.split_at(1)
, it will return a tuple of 2 strings.