Skip to main content

file_storage/path/properties/
relative_path.rs

1use crate::StoragePath;
2
3impl StoragePath {
4    //! Relative Path
5
6    /// Gets the relative path (the portion after the base).
7    pub fn relative_path(&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 relative_path() {
18        let path: StoragePath = unsafe { StoragePath::new("/the/path", 1, '/') };
19        assert_eq!(path.relative_path(), "the/path");
20    }
21}