Merge pull request #819 from Nahuel-M/add-tryfrom-string

Added convenience implementation TryFrom<String> for std
This commit is contained in:
Ashley Mannix 2025-03-19 08:52:36 +10:00 committed by GitHub
commit cb19a46cf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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.