Skip to main content

file_storage/path/core/
clone.rs

1use crate::{FilePath, FolderPath, StoragePath};
2
3impl StoragePath {
4    //! Clone
5
6    /// Clones the path with the extra capacity.
7    pub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self {
8        let mut path: String = String::with_capacity(self.len() + extra_capacity);
9        path.push_str(self.path());
10        unsafe { Self::new(path, self.base_len(), self.file_separator()) }
11    }
12}
13
14impl FilePath {
15    //! Clone
16
17    /// Clones the path with the extra capacity.
18    pub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self {
19        self.path()
20            .clone_with_extra_capacity(extra_capacity)
21            .to_file()
22            .unwrap()
23    }
24}
25
26impl FolderPath {
27    //! Clone
28
29    /// Clones the path with the extra capacity.
30    pub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self {
31        self.path()
32            .clone_with_extra_capacity(extra_capacity)
33            .to_folder()
34            .unwrap()
35    }
36}