Change impl of ObjectId::parse

It should be consistent with Url::parse
This commit is contained in:
Felix Ableitner 2023-11-20 16:40:46 +01:00
parent 33649b43b7
commit b80408d806
2 changed files with 4 additions and 10 deletions

View file

@ -20,12 +20,9 @@ where
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
{
/// Construct a new CollectionId instance
pub fn parse<T>(url: T) -> Result<Self, url::ParseError>
where
T: TryInto<Url>,
url::ParseError: From<<T as TryInto<Url>>::Error>,
pub fn parse(url: &str) -> Result<Self, url::ParseError>
{
Ok(Self(Box::new(url.try_into()?), PhantomData::<Kind>))
Ok(Self(Box::new(Url::parse(url)?), PhantomData::<Kind>))
}
/// Fetches collection over HTTP

View file

@ -65,12 +65,9 @@ where
for<'de2> <Kind as Object>::Kind: serde::Deserialize<'de2>,
{
/// Construct a new objectid instance
pub fn parse<T>(url: T) -> Result<Self, url::ParseError>
where
T: TryInto<Url>,
url::ParseError: From<<T as TryInto<Url>>::Error>,
pub fn parse(url: &str) -> Result<Self, url::ParseError>
{
Ok(ObjectId(Box::new(url.try_into()?), PhantomData::<Kind>))
Ok(Self(Box::new(Url::parse(url)?), PhantomData::<Kind>))
}
/// Returns a reference to the wrapped URL value