File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1724,6 +1724,14 @@ impl ops::Deref for PathBuf {
17241724 }
17251725}
17261726
1727+ #[ stable( feature = "path_buf_deref_mut" , since = "CURRENT_RUSTC_VERSION" ) ]
1728+ impl ops:: DerefMut for PathBuf {
1729+ #[ inline]
1730+ fn deref_mut ( & mut self ) -> & mut Path {
1731+ Path :: from_inner_mut ( & mut self . inner )
1732+ }
1733+ }
1734+
17271735#[ stable( feature = "rust1" , since = "1.0.0" ) ]
17281736impl Borrow < Path > for PathBuf {
17291737 #[ inline]
@@ -1976,6 +1984,12 @@ impl Path {
19761984 unsafe { & * ( s. as_ref ( ) as * const OsStr as * const Path ) }
19771985 }
19781986
1987+ fn from_inner_mut ( inner : & mut OsStr ) -> & mut Path {
1988+ // SAFETY: Path is just a wrapper around OsStr,
1989+ // therefore converting &mut OsStr to &mut Path is safe.
1990+ unsafe { & mut * ( inner as * mut OsStr as * mut Path ) }
1991+ }
1992+
19791993 /// Yields the underlying [`OsStr`] slice.
19801994 ///
19811995 /// # Examples
You can’t perform that action at this time.
0 commit comments