Sha256: e0fea787de8e2cbe4666fead62a4cb60f2e61a2cc964e6a3b41a90d2d0ce391b
Contents?: true
Size: 582 Bytes
Versions: 3
Compression:
Stored size: 582 Bytes
Contents
use std::str; use path_parsing::{SEP, find_last_non_sep_pos}; pub fn extname(path: &str) -> &str { let end = match find_last_non_sep_pos(path.as_bytes()) { Some(pos) => pos + 1, _ => return "", }; let bytes = &path.as_bytes()[..end]; for (pos, c) in bytes.iter().enumerate().rev() { match *c { b'.' => { let prev = bytes.get(pos - 1); if pos == end - 1 || prev == None || prev == Some(&SEP) { return ""; } else { return &path[pos..end] }; } SEP => return "", _ => {} } }; "" }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
faster_path-0.3.10 | src/extname.rs |
faster_path-0.3.9 | src/extname.rs |
faster_path-0.3.8 | src/extname.rs |