mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Stabilize string_drain_as_str
This commit is contained in:
parent
1540711946
commit
ab86df0ce9
@ -2769,33 +2769,31 @@ impl<'a> Drain<'a> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(string_drain_as_str)]
|
|
||||||
/// let mut s = String::from("abc");
|
/// let mut s = String::from("abc");
|
||||||
/// let mut drain = s.drain(..);
|
/// let mut drain = s.drain(..);
|
||||||
/// assert_eq!(drain.as_str(), "abc");
|
/// assert_eq!(drain.as_str(), "abc");
|
||||||
/// let _ = drain.next().unwrap();
|
/// let _ = drain.next().unwrap();
|
||||||
/// assert_eq!(drain.as_str(), "bc");
|
/// assert_eq!(drain.as_str(), "bc");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "string_drain_as_str", issue = "76905")] // Note: uncomment AsRef impls below when stabilizing.
|
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
|
||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
self.iter.as_str()
|
self.iter.as_str()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncomment when stabilizing `string_drain_as_str`.
|
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
|
||||||
// #[unstable(feature = "string_drain_as_str", issue = "76905")]
|
impl<'a> AsRef<str> for Drain<'a> {
|
||||||
// impl<'a> AsRef<str> for Drain<'a> {
|
fn as_ref(&self) -> &str {
|
||||||
// fn as_ref(&self) -> &str {
|
self.as_str()
|
||||||
// self.as_str()
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
|
||||||
// #[unstable(feature = "string_drain_as_str", issue = "76905")]
|
impl<'a> AsRef<[u8]> for Drain<'a> {
|
||||||
// impl<'a> AsRef<[u8]> for Drain<'a> {
|
fn as_ref(&self) -> &[u8] {
|
||||||
// fn as_ref(&self) -> &[u8] {
|
self.as_str().as_bytes()
|
||||||
// self.as_str().as_bytes()
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
#[stable(feature = "drain", since = "1.6.0")]
|
#[stable(feature = "drain", since = "1.6.0")]
|
||||||
impl Iterator for Drain<'_> {
|
impl Iterator for Drain<'_> {
|
||||||
|
Loading…
Reference in New Issue
Block a user