@@ -19,17 +19,20 @@ use std::path::*;
19
19
/// use pathdiff::diff_paths;
20
20
/// use std::path::*;
21
21
///
22
- /// let baz = "/foo/bar/baz";
23
- /// let bar = "/foo/bar";
24
- /// let quux = "/foo/bar/quux";
25
- /// assert_eq!(diff_paths(bar, baz), Some("../".into()));
26
- /// assert_eq!(diff_paths(baz, bar), Some("baz".into()));
27
- /// assert_eq!(diff_paths(quux, baz), Some("../quux".into()));
28
- /// assert_eq!(diff_paths(baz, quux), Some("../baz".into()));
29
- /// assert_eq!(diff_paths(bar, quux), Some("../".into()));
22
+ /// assert_eq!(diff_paths("/foo/bar", "/foo/bar/baz"), Some("../".into()));
23
+ /// assert_eq!(diff_paths("/foo/bar/baz", "/foo/bar"), Some("baz".into()));
24
+ /// assert_eq!(diff_paths("/foo/bar/quux", "/foo/bar/baz"), Some("../quux".into()));
25
+ /// assert_eq!(diff_paths("/foo/bar/baz", "/foo/bar/quux"), Some("../baz".into()));
26
+ /// assert_eq!(diff_paths("/foo/bar", "/foo/bar/quux"), Some("../".into()));
30
27
///
31
- /// assert_eq!(diff_paths(&baz, &bar.to_string()), Some("baz".into()));
32
- /// assert_eq!(diff_paths(Path::new(baz), Path::new(bar).to_path_buf()), Some("baz".into()));
28
+ /// assert_eq!(
29
+ /// diff_paths(&"/foo/bar/baz", "/foo/bar".to_string()),
30
+ /// Some("baz".into())
31
+ /// );
32
+ /// assert_eq!(
33
+ /// diff_paths(Path::new("/foo/bar/baz"), Path::new("/foo/bar").to_path_buf()),
34
+ /// Some("baz".into())
35
+ /// );
33
36
/// ```
34
37
pub fn diff_paths < P , B > ( path : P , base : B ) -> Option < PathBuf >
35
38
where
@@ -89,17 +92,20 @@ mod utf8_paths {
89
92
/// use camino::*;
90
93
/// use pathdiff::diff_utf8_paths;
91
94
///
92
- /// let baz = "/foo/bar/baz";
93
- /// let bar = "/foo/bar";
94
- /// let quux = "/foo/bar/quux";
95
- /// assert_eq!(diff_utf8_paths(bar, baz), Some("../".into()));
96
- /// assert_eq!(diff_utf8_paths(baz, bar), Some("baz".into()));
97
- /// assert_eq!(diff_utf8_paths(quux, baz), Some("../quux".into()));
98
- /// assert_eq!(diff_utf8_paths(baz, quux), Some("../baz".into()));
99
- /// assert_eq!(diff_utf8_paths(bar, quux), Some("../".into()));
95
+ /// assert_eq!(diff_utf8_paths("/foo/bar", "/foo/bar/baz"), Some("../".into()));
96
+ /// assert_eq!(diff_utf8_paths("/foo/bar/baz", "/foo/bar"), Some("baz".into()));
97
+ /// assert_eq!(diff_utf8_paths("/foo/bar/quux", "/foo/bar/baz"), Some("../quux".into()));
98
+ /// assert_eq!(diff_utf8_paths("/foo/bar/baz", "/foo/bar/quux"), Some("../baz".into()));
99
+ /// assert_eq!(diff_utf8_paths("/foo/bar", "/foo/bar/quux"), Some("../".into()));
100
100
///
101
- /// assert_eq!(diff_utf8_paths(&baz, &bar.to_string()), Some("baz".into()));
102
- /// assert_eq!(diff_utf8_paths(Utf8Path::new(baz), Utf8Path::new(bar).to_path_buf()), Some("baz".into()));
101
+ /// assert_eq!(
102
+ /// diff_utf8_paths(&"/foo/bar/baz", "/foo/bar".to_string()),
103
+ /// Some("baz".into())
104
+ /// );
105
+ /// assert_eq!(
106
+ /// diff_utf8_paths(Utf8Path::new("/foo/bar/baz"), Utf8Path::new("/foo/bar").to_path_buf()),
107
+ /// Some("baz".into())
108
+ /// );
103
109
/// ```
104
110
#[ cfg_attr( docsrs, doc( cfg( feature = "camino" ) ) ) ]
105
111
pub fn diff_utf8_paths < P , B > ( path : P , base : B ) -> Option < Utf8PathBuf >
0 commit comments