use url::Url;
pub trait IntoUrl {
fn into_url(self) -> crate::Result<Url>;
}
impl IntoUrl for Url {
fn into_url(self) -> crate::Result<Url> {
if self.has_host() {
Ok(self)
} else {
Err(crate::Error::BadScheme(self))
}
}
}
impl<'a> IntoUrl for &'a str {
fn into_url(self) -> crate::Result<Url> {
Ok(Url::parse(self)?)
}
}
impl<'a> IntoUrl for &'a String {
fn into_url(self) -> crate::Result<Url> {
(&**self).into_url()
}
}
impl IntoUrl for String {
fn into_url(self) -> crate::Result<Url> {
(&*self).into_url()
}
}