From 829019d4043a6e9dd1305113f43b30fc8415893d Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 9 Sep 2020 19:38:51 +0200 Subject: [PATCH] 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). --- library/alloc/src/string.rs | 29 +++++++++++++++-------------- 1 file 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 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 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<'_> {