mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat: Allow getting inner PathBuf from SafePathBuf (#14908)
* Allow getting inner PathBuf from SafePathBuf SafePathBuf implements AsRef<Path> 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
This commit is contained in:
5
.changes/safepathbuf_into_pathbuf.md
Normal file
5
.changes/safepathbuf_into_pathbuf.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch:enhance
|
||||
---
|
||||
|
||||
Implement retrieving inner PathBuf from SafePathBuf to ease using APIs that require an owned PathBuf
|
||||
@@ -73,6 +73,12 @@ impl FromStr for SafePathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SafePathBuf> for PathBuf {
|
||||
fn from(path: SafePathBuf) -> Self {
|
||||
path.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for SafePathBuf {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user