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

Prev

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

  • Loading branch information
frewsxcv committed Nov 14, 2016
commit 2c726b6a1cffc9bae34f0d0b7efda7d7936dea4e
@@ -930,6 +930,20 @@ impl Url {
///
/// If this URL is cannot-be-a-base, does not have a host, or has the `file` scheme;
/// do nothing and return `Err`.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let mut url = Url::parse("ssh://example.net:2048/").unwrap();
///
/// url.set_port(Some(4096)).unwrap();
/// assert_eq!(url.as_str(), "ssh://example.net:4096/");
///
/// url.set_port(None).unwrap();
/// assert_eq!(url.as_str(), "ssh://example.net/");
/// ```
pub fn set_port(&mut self, mut port: Option<u16>) -> Result<(), ()> {
if !self.has_host() || self.scheme() == "file" {
return Err(())
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.