Эх сурвалжийг харах

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

Corey Farwell 10 жил өмнө
parent
commit
b58ebab2de
1 өөрчлөгдсөн 10 нэмэгдсэн , 0 устгасан
  1. 10 0
      src/lib.rs

+ 10 - 0
src/lib.rs

@@ -271,6 +271,16 @@ impl Url {
     /// Return the serialization of this URL.
     /// Return the serialization of this URL.
     ///
     ///
     /// This is fast since that serialization is already stored in the `Url` struct.
     /// 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]
     #[inline]
     pub fn as_str(&self) -> &str {
     pub fn as_str(&self) -> &str {
         &self.serialization
         &self.serialization