file_storage/path/properties/extension.rs
1use crate::StoragePath;
2
3impl StoragePath {
4 //! Extension
5
6 /// Gets the path extension.
7 pub fn extension(&self) -> &str {
8 &self.path()[self.base_len()..]
9 }
10}
11
12#[cfg(test)]
13mod tests {
14 use crate::StoragePath;
15
16 #[test]
17 fn base_and_extension() {
18 let path: StoragePath = unsafe { StoragePath::new("/the/path", 1, '/') };
19 assert_eq!(path.extension(), "the/path");
20 }
21}