Implement the IntoUrl trait to url::Url struct

master
kirbylife 2021-03-21 01:33:56 -06:00
parent ded3cc4074
commit 4b7bd8e221
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,12 @@ pub trait IntoUrl {
fn into_url(self) -> Result<url::Url, url::ParseError>; fn into_url(self) -> Result<url::Url, url::ParseError>;
} }
impl IntoUrl for url::Url {
fn into_url(self) -> Result<url::Url, url::ParseError> {
Ok(self)
}
}
impl<'a> IntoUrl for &'a str { impl<'a> IntoUrl for &'a str {
fn into_url(self) -> Result<url::Url, url::ParseError> { fn into_url(self) -> Result<url::Url, url::ParseError> {
url::Url::parse(self) url::Url::parse(self)