|
|
@@ -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};
|
|
|
@@ -2324,6 +2326,14 @@ impl str::FromStr for Url {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl<'a> TryFrom<&'a str> for Url {
|
|
|
+ type Error = ParseError;
|
|
|
+
|
|
|
+ fn try_from(s: &'a str) -> Result<Self, Self::Error> {
|
|
|
+ Url::parse(s)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/// Display the serialization of this URL.
|
|
|
impl fmt::Display for Url {
|
|
|
#[inline]
|