diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-07 14:46:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-07 14:46:53 +0200 |
| commit | 795bc2ccff5672389c1e9d2481f25bdcdfee299b (patch) | |
| tree | 102f79b2bf4261484fb3354568a648c92c2fc2ae /src/libstd/sys_common | |
| parent | 39b62533c7f9d0581a6ea9b9fc2cc51f21c3b5b0 (diff) | |
| parent | f854070bb820501d88d1b029660bfde663595530 (diff) | |
| download | rust-795bc2ccff5672389c1e9d2481f25bdcdfee299b.tar.gz rust-795bc2ccff5672389c1e9d2481f25bdcdfee299b.zip | |
Rollup merge of #70201 - cuviper:clone_into, r=dtolnay
Small tweaks in ToOwned::clone_into - `<[T]>::clone_into` is slightly more optimized. - `CStr::clone_into` is new, letting it reuse its allocation. - `OsStr::clone_into` now forwards to the underlying slice/`Vec`.
Diffstat (limited to 'src/libstd/sys_common')
| -rw-r--r-- | src/libstd/sys_common/os_str_bytes.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys_common/wtf8.rs | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/sys_common/os_str_bytes.rs b/src/libstd/sys_common/os_str_bytes.rs index aa6cc33d831..984c032e2a3 100644 --- a/src/libstd/sys_common/os_str_bytes.rs +++ b/src/libstd/sys_common/os_str_bytes.rs @@ -173,6 +173,10 @@ impl Slice { Buf { inner: self.inner.to_vec() } } + pub fn clone_into(&self, buf: &mut Buf) { + self.inner.clone_into(&mut buf.inner) + } + #[inline] pub fn into_box(&self) -> Box<Slice> { let boxed: Box<[u8]> = self.inner.into(); diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index fc6614552a9..a98407da448 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -613,6 +613,10 @@ impl Wtf8 { } } + pub fn clone_into(&self, buf: &mut Wtf8Buf) { + self.bytes.clone_into(&mut buf.bytes) + } + /// Boxes this `Wtf8`. #[inline] pub fn into_box(&self) -> Box<Wtf8> { |
