1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::{FileSystemTree, MergeableFileSystemTree};
use std::{collections::BTreeMap, mem::transmute};
macro_rules! map_type {
($(#[$attribute:meta])* $name:ident = $tree:ident) => {
$(#[$attribute])*
pub type $name<Path, FileContent> = BTreeMap<Path, $tree<Path, FileContent>>;
};
}
map_type!(
DirectoryContent = FileSystemTree
);
map_type!(
MergeableDirectoryContent = MergeableFileSystemTree
);
macro_rules! function {
($(#[$attribute:meta])* $name:ident :: $input:ident -> $output:ident) => {
$(#[$attribute])*
pub fn $name<Path, FileContent>(map: $input<Path, FileContent>) -> $output<Path, FileContent>
where
Path: Ord,
{
unsafe { transmute(map) }
}
};
}
function!(
make_unmergeable_dir_content_mergeable :: DirectoryContent -> MergeableDirectoryContent
);
function!(
make_mergeable_dir_content_unmergeable :: MergeableDirectoryContent -> DirectoryContent
);