Skip to content

Commit 7bf2614

Browse files
committed
Auto merge of rust-lang#86875 - JohnTitor:rollup-fuefamw, r=JohnTitor
Rollup of 8 pull requests Successful merges: - rust-lang#86477 (E0716: clarify that equivalent code example is erroneous) - rust-lang#86623 (Add check to ensure error code explanations are not removed anymore even if not emitted) - rust-lang#86856 (Make x.py less verbose on failures) - rust-lang#86858 (Stabilize `string_drain_as_str`) - rust-lang#86859 (Add a regression test for issue-69323) - rust-lang#86862 (re-export SwitchIntEdgeEffects) - rust-lang#86864 (Add missing code example for Write::write_vectored) - rust-lang#86874 (Bump deps) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 96e8f98 + 2320c07 commit 7bf2614

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

alloc/src/string.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,33 +2769,31 @@ impl<'a> Drain<'a> {
27692769
/// # Examples
27702770
///
27712771
/// ```
2772-
/// #![feature(string_drain_as_str)]
27732772
/// let mut s = String::from("abc");
27742773
/// let mut drain = s.drain(..);
27752774
/// assert_eq!(drain.as_str(), "abc");
27762775
/// let _ = drain.next().unwrap();
27772776
/// assert_eq!(drain.as_str(), "bc");
27782777
/// ```
2779-
#[unstable(feature = "string_drain_as_str", issue = "76905")] // Note: uncomment AsRef impls below when stabilizing.
2778+
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
27802779
pub fn as_str(&self) -> &str {
27812780
self.iter.as_str()
27822781
}
27832782
}
27842783

2785-
// Uncomment when stabilizing `string_drain_as_str`.
2786-
// #[unstable(feature = "string_drain_as_str", issue = "76905")]
2787-
// impl<'a> AsRef<str> for Drain<'a> {
2788-
// fn as_ref(&self) -> &str {
2789-
// self.as_str()
2790-
// }
2791-
// }
2792-
//
2793-
// #[unstable(feature = "string_drain_as_str", issue = "76905")]
2794-
// impl<'a> AsRef<[u8]> for Drain<'a> {
2795-
// fn as_ref(&self) -> &[u8] {
2796-
// self.as_str().as_bytes()
2797-
// }
2798-
// }
2784+
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
2785+
impl<'a> AsRef<str> for Drain<'a> {
2786+
fn as_ref(&self) -> &str {
2787+
self.as_str()
2788+
}
2789+
}
2790+
2791+
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
2792+
impl<'a> AsRef<[u8]> for Drain<'a> {
2793+
fn as_ref(&self) -> &[u8] {
2794+
self.as_str().as_bytes()
2795+
}
2796+
}
27992797

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

std/src/io/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,27 @@ pub trait Write {
14181418
/// The default implementation calls [`write`] with either the first nonempty
14191419
/// buffer provided, or an empty one if none exists.
14201420
///
1421+
/// # Examples
1422+
///
1423+
/// ```no_run
1424+
/// use std::io::IoSlice;
1425+
/// use std::io::prelude::*;
1426+
/// use std::fs::File;
1427+
///
1428+
/// fn main() -> std::io::Result<()> {
1429+
/// let mut data1 = [1; 8];
1430+
/// let mut data2 = [15; 8];
1431+
/// let io_slice1 = IoSlice::new(&mut data1);
1432+
/// let io_slice2 = IoSlice::new(&mut data2);
1433+
///
1434+
/// let mut buffer = File::create("foo.txt")?;
1435+
///
1436+
/// // Writes some prefix of the byte string, not necessarily all of it.
1437+
/// buffer.write_vectored(&[io_slice1, io_slice2])?;
1438+
/// Ok(())
1439+
/// }
1440+
/// ```
1441+
///
14211442
/// [`write`]: Write::write
14221443
#[stable(feature = "iovec", since = "1.36.0")]
14231444
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize> {

0 commit comments

Comments
 (0)