file_storage/path/properties/
base_and_extension.rs1use crate::StoragePath;
2
3impl StoragePath {
4 pub fn base(&self) -> &str {
8 &self.path()[..self.base_len()]
9 }
10
11 pub fn extension(&self) -> &str {
13 &self.path()[self.base_len()..]
14 }
15}
16
17#[cfg(test)]
18mod tests {
19 use crate::StoragePath;
20
21 #[test]
22 fn base_and_extension() {
23 let path: StoragePath = unsafe { StoragePath::new("/the/path", 1, '/') };
24 assert_eq!(path.base(), "/");
25 assert_eq!(path.extension(), "the/path");
26 }
27}