From 4db9ecf1057d260a74bd90e381bfd3c358ace800 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 9 Dec 2016 08:15:14 -1000 Subject: [PATCH] Add doc examples for `Url::host`. --- src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 5dc8b7c1f..ffa27f635 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -656,6 +656,24 @@ impl Url { /// don’t have a host. /// /// See also the `host_str` method. + /// + /// # Examples + /// + /// ``` + /// use url::Url; + /// + /// let url = Url::parse("https://127.0.0.1/index.html").unwrap(); + /// assert!(url.host().is_some()); + /// + /// let url = Url::parse("ftp://rms@example.com").unwrap(); + /// assert!(url.host().is_some()); + /// + /// let url = Url::parse("unix:/run/foo.socket").unwrap(); + /// assert!(url.host().is_none()); + /// + /// let url = Url::parse("data:text/plain,Stuff").unwrap(); + /// assert!(url.host().is_none()); + /// ``` pub fn host(&self) -> Option> { match self.host { HostInternal::None => None,