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. #228

Merged
merged 3 commits into from Nov 1, 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

Add doc example for url::Url::port_or_known_default.

  • Loading branch information
frewsxcv committed Sep 30, 2016
commit 4c8aca6540c061eee566fecccee55491bc11cebb
@@ -584,6 +584,21 @@ impl Url {
///
/// For URLs in these schemes, this method always returns `Some(_)`.
/// For other schemes, it is the same as `Url::port()`.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("foo://example.com").unwrap();
/// assert_eq!(url.port_or_known_default(), None);
///
/// let url = Url::parse("foo://example.com:1456").unwrap();
/// assert_eq!(url.port_or_known_default(), Some(1456));
///
/// let url = Url::parse("https://example.com").unwrap();
/// assert_eq!(url.port_or_known_default(), Some(443));
/// ```
#[inline]
pub fn port_or_known_default(&self) -> Option<u16> {
self.port.or_else(|| parser::default_port(self.scheme()))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.