about summary refs log tree commit diff
path: root/src/test/mir-opt/lower_array_len.array_bound_mut.SimplifyLocals.diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-06-22 07:37:46 +0900
committerGitHub <noreply@github.com>2021-06-22 07:37:46 +0900
commit4463b08652110e96700f65bb584004e67da497e6 (patch)
treea94bcb5879806134172952bb4a7f006b3d57878b /src/test/mir-opt/lower_array_len.array_bound_mut.SimplifyLocals.diff
parent7f1a4a287f4aa39500aa4c45f60ad805047ad725 (diff)
parent664bde0770fcd898a6da97a117996de1366098dd (diff)
downloadrust-4463b08652110e96700f65bb584004e67da497e6.tar.gz
rust-4463b08652110e96700f65bb584004e67da497e6.zip
Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahc
Add `io::Cursor::{remaining, remaining_slice, is_empty}`

Tracking issue: #86369

I came across an inconvenience when answering the following [Stack Overflow](https://stackoverflow.com/questions/67831170) question.
To get the remaining slice you have to call `buff.fill_buf().unwrap()`. Which in my opinion doesn't really tell you what is returned (in the context of Cursor). To improve readability and convenience when using Cursor i propose adding the method `remaining`.

The next thing i found inconvenient (unnecessary long) was detecting if the cursor reached the end. There are a few ways this can be achieved right now:
- `buff.fill_buf().unwrap().is_empty()`
- `buff.position() >= buff.get_ref().len()`
- `buff.bytes().next().is_none()`

Which all seem a bit unintuitive, hidden in trait documentations or just a bit long for such a simple task.
Therefor i propose another method called `is_empty`, maybe with another name, since this one may leave room for interpretation on what really is empty (the underlying slice, the remaining slice or maybe the position).

Since it seemed easier to create this PR instead of an RFC i did that, if an RFC is wanted, i can close this PR and write an RFC first.
Diffstat (limited to 'src/test/mir-opt/lower_array_len.array_bound_mut.SimplifyLocals.diff')
0 files changed, 0 insertions, 0 deletions