mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-24 04:03:52 +03:00
enhance(core): add FromStr
impl for SafePathBuf
(#10870)
This commit is contained in:
parent
27d0183431
commit
431ca2c776
5
.changes/safe-path-buf-from-str.md
Normal file
5
.changes/safe-path-buf-from-str.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch:enhance
|
||||
---
|
||||
|
||||
Add `FromStr` impl for `SafePathBuf`
|
@ -2,7 +2,10 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use std::path::{Component, Display, Path, PathBuf};
|
||||
use std::{
|
||||
path::{Component, Display, Path, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use crate::Runtime;
|
||||
|
||||
@ -51,6 +54,14 @@ impl AsRef<Path> for SafePathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SafePathBuf {
|
||||
type Err = &'static str;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
Self::new(s.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for SafePathBuf {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user