Bläddra i källkod

url: deprecate into_string for Into<String> (fixes #685)

Dmitry Tantsur 5 år sedan
förälder
incheckning
fc54ffd9f7
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10 2
      url/src/lib.rs

+ 10 - 2
url/src/lib.rs

@@ -417,14 +417,15 @@ impl Url {
     /// # fn run() -> Result<(), ParseError> {
     /// let url_str = "https://example.net/";
     /// let url = Url::parse(url_str)?;
-    /// assert_eq!(url.into_string(), url_str);
+    /// assert_eq!(String::from(url), url_str);
     /// # Ok(())
     /// # }
     /// # run().unwrap();
     /// ```
     #[inline]
+    #[deprecated(since = "2.3.0", note = "use Into<String>")]
     pub fn into_string(self) -> String {
-        self.serialization
+        self.into()
     }
 
     /// For internal testing, not part of the public API.
@@ -2375,6 +2376,13 @@ impl fmt::Display for Url {
     }
 }
 
+/// String converstion.
+impl From<Url> for String {
+    fn from(value: Url) -> String {
+        value.serialization
+    }
+}
+
 /// Debug the serialization of this URL.
 impl fmt::Debug for Url {
     #[inline]