luaur-cli-lib 0.1.3

Shared CLI helpers for the luaur tools.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub fn split_path(path: &str) -> alloc::vec::Vec<&str> {
    let mut components = alloc::vec::Vec::new();

    let mut pos = 0;
    let bytes = path.as_bytes();

    while let Some(next_pos_offset) = bytes[pos..].iter().position(|&b| b == b'\\' || b == b'/') {
        let next_pos = pos + next_pos_offset;
        components.push(&path[pos..next_pos]);
        pos = next_pos + 1;
    }

    components.push(&path[pos..]);

    components
}