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::username`. #211

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::username`.

  • Loading branch information
frewsxcv committed Jul 4, 2016
commit 2a7e0becfb207c166bd45f94471137c7b506c869
@@ -447,6 +447,18 @@ impl Url {

/// Return the username for this URL (typically the empty string)
/// as a percent-encoded ASCII string.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("ftp://rms@example.com").unwrap();
/// assert_eq!(url.username(), "rms");
///
/// let url = Url::parse("https://example.com").unwrap();
/// assert_eq!(url.username(), "");
/// ```
pub fn username(&self) -> &str {
if self.has_authority() {
self.slice(self.scheme_end + ("://".len() as u32)..self.username_end)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.