Skip to content

Commit

Permalink
Add doc examples for Url::host.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Dec 9, 2016
1 parent fcc3a31 commit 4db9ecf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]").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<Host<&str>> {
match self.host {
HostInternal::None => None,
Expand Down

0 comments on commit 4db9ecf

Please sign in to comment.