Skip to content

Commit d6321e3

Browse files
committed
Auto merge of #156680 - bushrat011899:core_io_util_no_new_inline, r=<try>
perf(compilation): Directly construct `Take` and `Chain`
2 parents a31c27a + 217cc34 commit d6321e3

3 files changed

Lines changed: 2 additions & 23 deletions

File tree

library/core/src/io/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ pub use self::error::ErrorKind;
1515
pub use self::error::RawOsError;
1616
#[unstable(feature = "core_io", issue = "154046")]
1717
pub use self::util::{Chain, Empty, Repeat, Sink, Take, empty, repeat, sink};
18-
#[doc(hidden)]
19-
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
20-
pub use self::util::{chain, take};

library/core/src/io/util.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ pub const fn sink() -> Sink {
132132
/// [`chain`]: ../../std/io/trait.Read.html#method.chain
133133
#[stable(feature = "rust1", since = "1.0.0")]
134134
#[derive(Debug)]
135-
#[non_exhaustive]
136135
pub struct Chain<T, U> {
137136
#[doc(hidden)]
138137
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
@@ -224,14 +223,6 @@ impl<T, U> Chain<T, U> {
224223
}
225224
}
226225

227-
#[doc(hidden)]
228-
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
229-
#[must_use]
230-
#[inline]
231-
pub const fn chain<T, U>(first: T, second: U) -> Chain<T, U> {
232-
Chain { first, second, done_first: false }
233-
}
234-
235226
/// Reader adapter which limits the bytes read from an underlying reader.
236227
///
237228
/// This struct is generally created by calling [`take`] on a reader.
@@ -240,7 +231,6 @@ pub const fn chain<T, U>(first: T, second: U) -> Chain<T, U> {
240231
/// [`take`]: ../../std/io/trait.Read.html#method.take
241232
#[stable(feature = "rust1", since = "1.0.0")]
242233
#[derive(Debug)]
243-
#[non_exhaustive]
244234
pub struct Take<T> {
245235
#[doc(hidden)]
246236
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
@@ -405,11 +395,3 @@ impl<T> Take<T> {
405395
&mut self.inner
406396
}
407397
}
408-
409-
#[doc(hidden)]
410-
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
411-
#[must_use]
412-
#[inline]
413-
pub const fn take<T>(inner: T, limit: u64) -> Take<T> {
414-
Take { inner, limit, len: limit }
415-
}

library/std/src/io/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ pub trait Read {
11841184
where
11851185
Self: Sized,
11861186
{
1187-
core::io::chain(self, next)
1187+
Chain { first: self, second: next, done_first: false }
11881188
}
11891189

11901190
/// Creates an adapter which will read at most `limit` bytes from it.
@@ -1223,7 +1223,7 @@ pub trait Read {
12231223
where
12241224
Self: Sized,
12251225
{
1226-
core::io::take(self, limit)
1226+
Take { inner: self, len: limit, limit }
12271227
}
12281228

12291229
/// Read and return a fixed array of bytes from this source.

0 commit comments

Comments
 (0)