File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1818 implements ` Display ` .
1919- Added ` Handle::component_name() ` and ` Handle::device_path() ` to simplify the
2020 common use-case of querying more information about a handle.
21+ - Added ` fs::path::Path::join() ` .
2122
2223## Changed
2324- export all ` text::{input, output}::* ` types
Original file line number Diff line number Diff line change @@ -85,6 +85,14 @@ impl Path {
8585 pub const fn is_empty ( & self ) -> bool {
8686 self . to_cstr16 ( ) . is_empty ( )
8787 }
88+
89+ /// Creates an owned [`PathBuf`] with `path` adjoined to `self`.
90+ #[ must_use]
91+ pub fn join < P : AsRef < Self > > ( & self , path : P ) -> PathBuf {
92+ let mut buf = self . to_path_buf ( ) ;
93+ buf. push ( path) ;
94+ buf
95+ }
8896}
8997
9098impl Display for Path {
@@ -294,4 +302,19 @@ mod tests {
294302 assert_ne ! ( path1, path3) ;
295303 assert_ne ! ( path3, path1) ;
296304 }
305+
306+ #[ test]
307+ fn join ( ) {
308+ let path1 = Path :: new ( cstr16 ! ( r"a\b" ) ) ;
309+ let path2 = Path :: new ( cstr16 ! ( r"c\d" ) ) ;
310+ let path3 = Path :: new ( cstr16 ! ( r"a\b\c\d" ) ) ;
311+
312+ assert_eq ! ( path1. join( path2) , path3. to_path_buf( ) ) ;
313+
314+ let pathbuf1 = path1. to_path_buf ( ) ;
315+ let pathbuf2 = path2. to_path_buf ( ) ;
316+ let pathbuf3 = path3. to_path_buf ( ) ;
317+
318+ assert_eq ! ( pathbuf1. join( pathbuf2) , pathbuf3) ;
319+ }
297320}
You can’t perform that action at this time.
0 commit comments