From 4017a7ed7313cebf912ef3af1e3b280855b6f100 Mon Sep 17 00:00:00 2001 From: Joshua Megnauth <48846352+joshuamegnauth54@users.noreply.github.com> Date: Tue, 24 Mar 2026 04:35:05 -0400 Subject: [PATCH] feat: Allow getting inner PathBuf from SafePathBuf (#14908) * Allow getting inner PathBuf from SafePathBuf SafePathBuf implements AsRef which is ergonomic and useful. However, some APIs take owned PathBufs. This leads to clunky code where the caller has to get a &Path from the SafePathBuf then take ownership of that path. Ideally, if a user has a SafePathBuf and needs a PathBuf, they won't need to allocate again just to get the inner PathBuf back. * Apply suggestion from @Legend-Master --- .changes/safepathbuf_into_pathbuf.md | 5 +++++ crates/tauri/src/path/mod.rs | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changes/safepathbuf_into_pathbuf.md diff --git a/.changes/safepathbuf_into_pathbuf.md b/.changes/safepathbuf_into_pathbuf.md new file mode 100644 index 000000000..1a72fa205 --- /dev/null +++ b/.changes/safepathbuf_into_pathbuf.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:enhance +--- + +Implement retrieving inner PathBuf from SafePathBuf to ease using APIs that require an owned PathBuf diff --git a/crates/tauri/src/path/mod.rs b/crates/tauri/src/path/mod.rs index f504435c5..c00af5d8d 100644 --- a/crates/tauri/src/path/mod.rs +++ b/crates/tauri/src/path/mod.rs @@ -73,6 +73,12 @@ impl FromStr for SafePathBuf { } } +impl From for PathBuf { + fn from(path: SafePathBuf) -> Self { + path.0 + } +} + impl<'de> Deserialize<'de> for SafePathBuf { fn deserialize(deserializer: D) -> std::result::Result where