diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-29 07:11:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-29 07:11:13 +0200 |
| commit | 1a9f91a43e521bf0687a238a8f991ee85bd8dc99 (patch) | |
| tree | 400bfc1ad36e39f52cc1de39d5b76907ac01cdb2 /library/std/src/env.rs | |
| parent | 2e630267b2bce50af3258ce4817e377fa09c145b (diff) | |
| parent | 10da5553a8b4a166ea1f4c87a0058f971b13c5bc (diff) | |
| download | rust-1a9f91a43e521bf0687a238a8f991ee85bd8dc99.tar.gz rust-1a9f91a43e521bf0687a238a8f991ee85bd8dc99.zip | |
Rollup merge of #109174 - soerenmeier:cursor_fns, r=dtolnay
Replace `io::Cursor::{remaining_slice, is_empty}`
This is a late follow up to the concerns raised in https://github.com/rust-lang/rust/issues/86369.
https://github.com/rust-lang/rust/issues/86369#issuecomment-953096691
> This API seems focussed on the `Read` side of things. When `Seek`ing around and `Write`ing data, `is_empty` becomes confusing and `remaining_slice` is not very useful. When writing, the part of the slice before the cursor is much more interesting. Maybe we should have functions for both? Or a single function that returns both slices? (If we also have a `mut` version, a single function would be useful to allow mutable access to both sides at once.)
New feature name: `cursor_remaining` > `cursor_split`.
Added functions:
```rust
fn split(&self) -> (&[u8], &[u8]);
// fn before(&self) -> &[u8];
// fn after(&self) -> &[u8];
fn split_mut(&mut self) -> (&mut [u8], &mut [u8]);
// fn before_mut(&mut self) -> &mut [u8];
// fn after_mut(&mut self) -> &mut [u8];
```
A question was raised in https://github.com/rust-lang/rust/issues/86369#issuecomment-927124211 about whether to return a lifetime that would reflect the lifetime of the underlying bytes (`impl Cursor<&'a [u8]> { fn after(&self) -> &'a [u8] }`). The downside of doing this would be that it would not be possible to implement these functions generically over `T: AsRef<[u8]>`.
## Update
Based on the review, before* and after* methods where removed.
Diffstat (limited to 'library/std/src/env.rs')
0 files changed, 0 insertions, 0 deletions
