You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//! let path: PathDSL = PathDSL::from("dir1") / "dir2" / other / filename; // Also works
128
110
//!
129
111
//! # use std::path::PathBuf;
130
112
//! # let mut path2 = PathBuf::new();
@@ -146,14 +128,14 @@
146
128
//! Both mutable and immutable borrows are supported, though they will never actually mutate anything.
147
129
//!
148
130
//! ```rust,compile_fail
149
-
//! use path_dsl::{path, PathDSL};
131
+
//! use path_dsl::path;
150
132
//! # use std::path::PathBuf;
151
133
//!
152
134
//! let value = PathBuf::from("some_dir");
153
135
//! let borrow: &str = "my_file.txt";
154
136
//!
155
137
//! let mac = path!(value | borrow);
156
-
//! let path = PathDSL::new() / value / borrow; // Will not compile because `value` was moved
138
+
//! let path = path!(value | borrow); // Will not compile because `value` was moved
157
139
//! ```
158
140
//!
159
141
//! You must manually borrow it:
@@ -177,6 +159,9 @@
177
159
//!
178
160
//! ### PathDSL <=> PathBuf
179
161
//!
162
+
//! **The PathDSL type is not meant to be used directly, but exists to allow the macro to work.
163
+
//! It was once intended to be directly used, so it ratains this functionality.**
164
+
//!
180
165
//! `PathDSL` is designed to be a drop-in replacement for `PathBuf`, including trivial conversions
181
166
//! between the two. In any situation where you would be able to use `PathBuf` you can use
182
167
//! `PathDSL`. `PathDSL` includes an implementation of `Deref` to a `PathBuf` (and by proxy `Path`) and re-implements all functions that take `self`, so is fully api compatable.
@@ -219,7 +204,7 @@
219
204
//! func(buf);
220
205
//! // Must convert into `PathBuf`
221
206
//! // Dereferencing doesn't work because `func` moves.
222
-
//! func(dsl.into_pathbuf());
207
+
//! func(dsl.to_path_buf());
223
208
//! # let dsl = path!("file.txt");
224
209
//! func(dsl.into()) // also works
225
210
//! ```
@@ -267,12 +252,6 @@
267
252
//! # assert_eq!(p, dup);
268
253
//! ```
269
254
//!
270
-
//! # Known Issues
271
-
//!
272
-
//! Due to my mitigation of a [rustc bug](https://github.com/rust-lang/rust/issues/63460) there may be
273
-
//! issues when renaming `path_dsl` crate and using the [`path!`](macro.path.html) macro. I currently have not have
274
-
//! experienced this, but if it happens, please report an issue and I'll add it to the documentation.
275
-
//!
276
255
//! # Why Use A Crate?
277
256
//!
278
257
//! You may be wondering why you should use a crate for this when you can easily wrap `PathBuf` and
@@ -305,6 +284,9 @@ use std::rc::Rc;
305
284
use std::str::FromStr;
306
285
use std::sync::Arc;
307
286
287
+
#[cfg(test)]
288
+
mod tests;
289
+
308
290
/// A PathBuf wrapper that has support for a Path DSL.
309
291
///
310
292
/// It is usable nearly identically to a PathBuf.
@@ -1077,6 +1059,13 @@ impl Into<PathDSL> for CopylessDSL {
1077
1059
}
1078
1060
}
1079
1061
1062
+
implInto<PathBuf>forCopylessDSL{
1063
+
#[inline(always)]
1064
+
fninto(self) -> PathBuf{
1065
+
PathBuf::new()
1066
+
}
1067
+
}
1068
+
1080
1069
implDiv<PathDSL>forCopylessDSL{
1081
1070
typeOutput = PathDSL;
1082
1071
@@ -1186,8 +1175,7 @@ macro_rules! separator {
1186
1175
#[macro_export]
1187
1176
macro_rules! concat_separator {
1188
1177
( $e:literal, $($other:literal),+ ) => {
1189
-
// Working around https://github.com/rust-lang/rust/issues/63460
0 commit comments