From 752423ae35672ffeea31e464273a0c2cacecf1d3 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sun, 21 May 2017 14:42:46 +0100 Subject: [PATCH] [WIP] Modify examples to not call `unwrap` --- src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f0b7f9742..097fed9e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -267,13 +267,17 @@ impl Url { /// ```rust /// use url::Url; /// - /// let base = Url::parse("https://example.net/a/b.html").unwrap(); - /// let url = base.join("c.png").unwrap(); + /// fn foo() -> Result<(), url::ParseError> { + /// let base = Url::parse("https://example.net/a/b.html")?; + /// let url = base.join("c.png")?; /// assert_eq!(url.as_str(), "https://example.net/a/c.png"); // Not /a/b.html/c.png /// - /// let base = Url::parse("https://example.net/a/b/").unwrap(); - /// let url = base.join("c.png").unwrap(); + /// let base = Url::parse("https://example.net/a/b/")?; + /// let url = base.join("c.png")?; /// assert_eq!(url.as_str(), "https://example.net/a/b/c.png"); + /// + /// Ok(()) + /// } /// ``` #[inline] pub fn join(&self, input: &str) -> Result {