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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! A super small crate which contains [AutoDeletePath](struct.AutoDeletePath.html),
//! a path which gets automatically deleted when it goes out of scope.
//!
//! # Examples
//! ```
//! {
//! let tmp_path = auto_delete_path::AutoDeletePath::temp(); // creates a new path at the default temp folder
//! std::fs::create_dir(&tmp_path); // AutoDeletePath implements AsRef<Path>
//! let subfile = tmp_path.as_ref().join("subfile"); // create a subfile
//! std::fs::File::create(&subfile).unwrap();
//! } // tmp_path dies here, so the directory and its contents will be deleted
//!```
//!
//! See [AutoDeletePath](struct.AutoDeletePath.html) and [include_to_auto_delete_path](macro.include_to_auto_delete_path.html)
//! for more examples.
use ;
/// Macro for including a source file, and writing it to a new `AutoDeletePath::temp`.
///
/// Useful for testing.
///
/// # Panics
///
/// Panics if writing to the tempfile fails.
///
/// # Example
///
/// ```
/// let tmp_path = auto_delete_path::include_to_auto_delete_path!("test-resources/test-include.txt");
/// assert_eq!(std::fs::read_to_string(&tmp_path).unwrap(), "Included file!\n");
/// ```
/// This struct simply holds an instance of `std::path::PathBuf`.
/// However, when such an instance goes out of scope and is destroyed, its destructor will be called,
/// which attempts to delete the owned path (either file or directory).
///
/// This works even if the program panics.
///
/// Useful for creating temporary files that you want to be deleted automatically.
/// Creates a random path at the default temp directory (usually /tmp).
/// Creates a random path at the specified directory.