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