Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc examples for `url::Url::origin`. #209

Merged
merged 1 commit into from Jul 4, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add doc examples for `url::Url::origin`.

  • Loading branch information
frewsxcv committed Jul 4, 2016
commit 7b4608b8ab7219199c8ecf6ed96dc7f04f2ffe29
@@ -366,6 +366,53 @@ impl Url {
///
/// Note: this return an opaque origin for `file:` URLs, which causes
/// `url.origin() != url.origin()`.
///
/// # Examples
///
/// URL with `ftp` scheme:
///
/// ```rust
/// use url::{Host, Origin, Url};
///
/// let url = Url::parse("ftp://example.com/foo").unwrap();
/// assert_eq!(url.origin(),
/// Origin::Tuple("ftp".into(),
/// Host::Domain("example.com".into()),
/// 21));
/// ```
///
/// URL with `blob` scheme:
///
/// ```rust
/// use url::{Host, Origin, Url};
///
/// let url = Url::parse("blob:https://example.com/foo").unwrap();
/// assert_eq!(url.origin(),
/// Origin::Tuple("https".into(),
/// Host::Domain("example.com".into()),
/// 443));
/// ```
///
/// URL with `file` scheme:
///
/// ```rust
/// use url::{Host, Origin, Url};
///
/// let url = Url::parse("file:///tmp/foo").unwrap();
/// assert!(!url.origin().is_tuple());
///
/// let other_url = Url::parse("file:///tmp/foo").unwrap();
/// assert!(url.origin() != other_url.origin());
/// ```
///
/// URL with other scheme:
///
/// ```rust
/// use url::{Host, Origin, Url};
///
/// let url = Url::parse("foo:bar").unwrap();
/// assert!(!url.origin().is_tuple());
/// ```
#[inline]
pub fn origin(&self) -> Origin {
origin::url_origin(self)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.