diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/camino/src/lib.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/camino/src/lib.rs')
-rw-r--r-- | vendor/camino/src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/camino/src/lib.rs b/vendor/camino/src/lib.rs index 44684b096..86a58ee51 100644 --- a/vendor/camino/src/lib.rs +++ b/vendor/camino/src/lib.rs @@ -484,6 +484,14 @@ impl Deref for Utf8PathBuf { } } +/// *Requires Rust 1.68 or newer.* +#[cfg(path_buf_deref_mut)] +impl std::ops::DerefMut for Utf8PathBuf { + fn deref_mut(&mut self) -> &mut Self::Target { + unsafe { Utf8Path::assume_utf8_mut(&mut self.0) } + } +} + impl fmt::Debug for Utf8PathBuf { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) @@ -1457,6 +1465,11 @@ impl Utf8Path { // *const Path to a *const Utf8Path is valid. &*(path as *const Path as *const Utf8Path) } + + #[cfg(path_buf_deref_mut)] + unsafe fn assume_utf8_mut(path: &mut Path) -> &mut Utf8Path { + &mut *(path as *mut Path as *mut Utf8Path) + } } impl Clone for Box<Utf8Path> { @@ -2220,6 +2233,17 @@ impl Utf8DirEntry { pub fn into_inner(self) -> fs::DirEntry { self.inner } + + /// Returns the full path to the file that this entry represents. + /// + /// This is analogous to [`path`], but moves ownership of the path. + /// + /// [`path`]: struct.Utf8DirEntry.html#method.path + #[inline] + #[must_use = "`self` will be dropped if the result is not used"] + pub fn into_path(self) -> Utf8PathBuf { + self.path + } } impl From<String> for Utf8PathBuf { |