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 a few doc examples. #239

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

Always

Just for now

Next

Add doc example for `url::Url::join`.

  • Loading branch information
frewsxcv committed Nov 14, 2016
commit d0ab24777bdd7b46969a05c7cd1bf26b4db6724d
@@ -234,6 +234,26 @@ impl Url {
}

/// Parse a string as an URL, with this URL as the base URL.
///
/// # Examples
///
/// ```rust
/// use url::Url;
///
/// let url = Url::parse("https://example.net").unwrap();
/// let url = url.join("foo").unwrap();
/// assert_eq!(url.as_str(), "https://example.net/foo");

This comment has been minimized.

@SimonSapin

SimonSapin Nov 14, 2016

Member

Please change this to showcase trailing slashes: https://example.net/foo joined with bar is https://example.net/bar, but https://example.net/foo/ joined with bar is https://example.net/foo/bar

r=me with this.

/// ```
///
/// Trailing slashes are not preserved:
///
/// ```rust
/// use url::Url;
///
/// let url = Url::parse("https://example.net/foo/").unwrap();
/// let url = url.join("bar").unwrap();
/// assert_eq!(url.as_str(), "https://example.net/foo/bar");
/// ```
#[inline]
pub fn join(&self, input: &str) -> Result<Url, ::ParseError> {
Url::options().base_url(Some(self)).parse(input)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.