about summary refs log tree commit diff
path: root/library/alloc/src/string.rs
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-09-09 19:38:51 +0200
committerMara Bos <m-ou.se@m-ou.se>2020-09-09 19:57:57 +0200
commit829019d4043a6e9dd1305113f43b30fc8415893d (patch)
treec6cf9427739dca956393ddfbcc8195adab848539 /library/alloc/src/string.rs
parentf2a32909e0649eb589406ddac63597ba34273c95 (diff)
downloadrust-829019d4043a6e9dd1305113f43b30fc8415893d.tar.gz
rust-829019d4043a6e9dd1305113f43b30fc8415893d.zip
Disable AsRef implementations for String's Drain.
Since trait implementations cannot be unstable, we should only add them
when the as_str feature gets stabilized. Until then, only `.as_str()` is
available (behind a feature gate).
Diffstat (limited to 'library/alloc/src/string.rs')
-rw-r--r--library/alloc/src/string.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 047ae942cd9..b9506281ed6 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -2475,25 +2475,26 @@ impl<'a> Drain<'a> {
     /// let _ = drain.next().unwrap();
     /// assert_eq!(drain.as_str(), "bc");
     /// ```
-    #[unstable(feature = "string_drain_as_str", issue = "none")]
+    #[unstable(feature = "string_drain_as_str", issue = "none")] // Note: uncomment AsRef impls below when stabilizing.
     pub fn as_str(&self) -> &str {
         self.iter.as_str()
     }
 }
 
-#[stable(feature = "string_drain_as_ref", since = "1.48.0")]
-impl<'a> AsRef<str> for Drain<'a> {
-    fn as_ref(&self) -> &str {
-        self.as_str()
-    }
-}
-
-#[stable(feature = "string_drain_as_ref", since = "1.48.0")]
-impl<'a> AsRef<[u8]> for Drain<'a> {
-    fn as_ref(&self) -> &[u8] {
-        self.as_str().as_bytes()
-    }
-}
+// Uncomment when stabilizing `string_drain_as_str`.
+// #[unstable(feature = "string_drain_as_str", issue = "none")]
+// impl<'a> AsRef<str> for Drain<'a> {
+//     fn as_ref(&self) -> &str {
+//         self.as_str()
+//     }
+// }
+//
+// #[unstable(feature = "string_drain_as_str", issue = "none")]
+// impl<'a> AsRef<[u8]> for Drain<'a> {
+//     fn as_ref(&self) -> &[u8] {
+//         self.as_str().as_bytes()
+//     }
+// }
 
 #[stable(feature = "drain", since = "1.6.0")]
 impl Iterator for Drain<'_> {