diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-09-09 17:59:43 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2020-09-09 18:07:27 +0200 |
| commit | f5bb523e94b431c35b495b6ad6ae94495b653a5f (patch) | |
| tree | 0bb025f2b7b7f9b3461a3626ee0830f66efa1e95 /library/alloc | |
| parent | 673284058b53992cfd66c04b9db8e551a0dc9996 (diff) | |
| download | rust-f5bb523e94b431c35b495b6ad6ae94495b653a5f.tar.gz rust-f5bb523e94b431c35b495b6ad6ae94495b653a5f.zip | |
Add AsRef<[u8]> for String's Drain.
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/string.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 14ffd06e9bd..a164de8b4d3 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2488,6 +2488,13 @@ impl<'a> AsRef<str> for Drain<'a> { } } +#[unstable(feature = "string_drain_as_str", issue = "none")] +impl<'a> AsRef<[u8]> for Drain<'a> { + fn as_ref(&self) -> &[u8] { + self.as_str().as_bytes() + } +} + #[stable(feature = "drain", since = "1.6.0")] impl Iterator for Drain<'_> { type Item = char; |
