Skip to content

Commit 829019d

Browse files
committed
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).
1 parent f2a3290 commit 829019d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

library/alloc/src/string.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -2475,25 +2475,26 @@ impl<'a> Drain<'a> {
24752475
/// let _ = drain.next().unwrap();
24762476
/// assert_eq!(drain.as_str(), "bc");
24772477
/// ```
2478-
#[unstable(feature = "string_drain_as_str", issue = "none")]
2478+
#[unstable(feature = "string_drain_as_str", issue = "none")] // Note: uncomment AsRef impls below when stabilizing.
24792479
pub fn as_str(&self) -> &str {
24802480
self.iter.as_str()
24812481
}
24822482
}
24832483

2484-
#[stable(feature = "string_drain_as_ref", since = "1.48.0")]
2485-
impl<'a> AsRef<str> for Drain<'a> {
2486-
fn as_ref(&self) -> &str {
2487-
self.as_str()
2488-
}
2489-
}
2490-
2491-
#[stable(feature = "string_drain_as_ref", since = "1.48.0")]
2492-
impl<'a> AsRef<[u8]> for Drain<'a> {
2493-
fn as_ref(&self) -> &[u8] {
2494-
self.as_str().as_bytes()
2495-
}
2496-
}
2484+
// Uncomment when stabilizing `string_drain_as_str`.
2485+
// #[unstable(feature = "string_drain_as_str", issue = "none")]
2486+
// impl<'a> AsRef<str> for Drain<'a> {
2487+
// fn as_ref(&self) -> &str {
2488+
// self.as_str()
2489+
// }
2490+
// }
2491+
//
2492+
// #[unstable(feature = "string_drain_as_str", issue = "none")]
2493+
// impl<'a> AsRef<[u8]> for Drain<'a> {
2494+
// fn as_ref(&self) -> &[u8] {
2495+
// self.as_str().as_bytes()
2496+
// }
2497+
// }
24972498

24982499
#[stable(feature = "drain", since = "1.6.0")]
24992500
impl Iterator for Drain<'_> {

0 commit comments

Comments
 (0)