mirror of
https://github.com/uuid-rs/uuid.git
synced 2025-09-28 13:31:58 +00:00
Merge pull request #819 from Nahuel-M/add-tryfrom-string
Added convenience implementation TryFrom<String> for std
This commit is contained in:
commit
cb19a46cf1
@ -19,6 +19,9 @@ use crate::{
|
||||
Uuid,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use crate::std::string::String;
|
||||
|
||||
impl str::FromStr for Uuid {
|
||||
type Err = Error;
|
||||
|
||||
@ -35,6 +38,15 @@ impl TryFrom<&'_ str> for Uuid {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl TryFrom<String> for Uuid {
|
||||
type Error = Error;
|
||||
|
||||
fn try_from(uuid_str: String) -> Result<Self, Self::Error> {
|
||||
Uuid::try_from(uuid_str.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl Uuid {
|
||||
/// Parses a `Uuid` from a string of hexadecimal digits with optional
|
||||
/// hyphens.
|
||||
|
Loading…
x
Reference in New Issue
Block a user