file_storage/path/properties/
base_and_extension.rs

1use crate::StoragePath;
2
3impl StoragePath {
4    //! Base & Extension
5
6    /// Gets the path base.
7    pub fn base(&self) -> &str {
8        &self.path()[..self.base_len()]
9    }
10
11    /// Gets the path extension.
12    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}