diff --git a/components/url/lib.rs b/components/url/lib.rs index b7d61273370..db09987d44f 100644 --- a/components/url/lib.rs +++ b/components/url/lib.rs @@ -3,13 +3,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] - #![crate_name = "servo_url"] #![crate_type = "rlib"] -#[macro_use] extern crate malloc_size_of; -#[macro_use] extern crate malloc_size_of_derive; -#[macro_use] extern crate serde; +#[macro_use] +extern crate malloc_size_of; +#[macro_use] +extern crate malloc_size_of_derive; +#[macro_use] +extern crate serde; extern crate servo_rand; extern crate url; extern crate url_serde; @@ -29,10 +31,7 @@ use url::{Url, Position}; pub use url::Host; #[derive(Clone, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)] -pub struct ServoUrl( - #[ignore_malloc_size_of = "Arc"] - Arc -); +pub struct ServoUrl(#[ignore_malloc_size_of = "Arc"] Arc); impl ServoUrl { pub fn from_url(url: Url) -> Self { @@ -40,11 +39,16 @@ impl ServoUrl { } pub fn parse_with_base(base: Option<&Self>, input: &str) -> Result { - Url::options().base_url(base.map(|b| &*b.0)).parse(input).map(Self::from_url) + Url::options() + .base_url(base.map(|b| &*b.0)) + .parse(input) + .map(Self::from_url) } pub fn into_string(self) -> String { - Arc::try_unwrap(self.0).unwrap_or_else(|s| (*s).clone()).into_string() + Arc::try_unwrap(self.0) + .unwrap_or_else(|s| (*s).clone()) + .into_string() } pub fn into_url(self) -> Url { @@ -209,7 +213,8 @@ impl From for ServoUrl { impl serde::Serialize for ServoUrl { fn serialize(&self, serializer: S) -> Result - where S: serde::Serializer, + where + S: serde::Serializer, { url_serde::serialize(&*self.0, serializer) } @@ -217,7 +222,8 @@ impl serde::Serialize for ServoUrl { impl<'de> serde::Deserialize<'de> for ServoUrl { fn deserialize(deserializer: D) -> Result - where D: serde::Deserializer<'de>, + where + D: serde::Deserializer<'de>, { url_serde::deserialize(deserializer).map(Self::from_url) } diff --git a/components/url/origin.rs b/components/url/origin.rs index 14a1cb921e6..414f03ec6a7 100644 --- a/components/url/origin.rs +++ b/components/url/origin.rs @@ -18,10 +18,13 @@ pub enum ImmutableOrigin { /// Consists of the URL's scheme, host and port Tuple( String, - #[serde(deserialize_with = "url_serde::deserialize", serialize_with = "url_serde::serialize")] + #[serde( + deserialize_with = "url_serde::deserialize", + serialize_with = "url_serde::serialize" + )] Host, u16, - ) + ), } impl ImmutableOrigin { @@ -160,7 +163,8 @@ impl MutableOrigin { } pub fn effective_domain(&self) -> Option { - self.immutable().host() + self.immutable() + .host() .map(|host| self.domain().unwrap_or_else(|| host.clone())) } }