diff --git a/src/lib.rs b/src/lib.rs index d60935c29..43ba30f9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -130,6 +130,8 @@ use std::ops::{Range, RangeFrom, RangeTo}; use std::path::{Path, PathBuf}; use std::str; +use std::convert::TryFrom; + pub use host::Host; pub use origin::{OpaqueOrigin, Origin}; pub use parser::{ParseError, SyntaxViolation}; @@ -2228,6 +2230,14 @@ impl str::FromStr for Url { } } +impl<'a> TryFrom<&'a str> for Url { + type Error = ParseError; + + fn try_from(s: &'a str) -> Result { + Url::parse(s) + } +} + /// Display the serialization of this URL. impl fmt::Display for Url { #[inline]