Explorar el Código

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

Corey Farwell hace 10 años
padre
commit
b58ebab2de
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      src/lib.rs

+ 10 - 0
src/lib.rs

@@ -271,6 +271,16 @@ impl Url {
     /// Return the serialization of this URL.
     ///
     /// This is fast since that serialization is already stored in the `Url` struct.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// use url::Url;
+    ///
+    /// let url_str = "https://example.net/";
+    /// let url = Url::parse(url_str).unwrap();
+    /// assert_eq!(url.as_str(), url_str);
+    /// ```
     #[inline]
     pub fn as_str(&self) -> &str {
         &self.serialization