Auto merge of #85815 - YuhanLiin:buf-read-data-left, r=m-ou-se
Add has_data_left() to BufRead This is a continuation of #40747 and also addresses #40745. The problem with the previous PR was that it had "eof" in its method name. This PR uses a more descriptive method name, but I'm open to changing it.
This commit is contained in:
@@ -71,6 +71,16 @@ fn lines() {
|
||||
assert!(s.next().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn buf_read_has_data_left() {
|
||||
let mut buf = Cursor::new(&b"abcd"[..]);
|
||||
assert!(buf.has_data_left().unwrap());
|
||||
buf.read_exact(&mut [0; 2]).unwrap();
|
||||
assert!(buf.has_data_left().unwrap());
|
||||
buf.read_exact(&mut [0; 2]).unwrap();
|
||||
assert!(!buf.has_data_left().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_to_end() {
|
||||
let mut c = Cursor::new(&b""[..]);
|
||||
|
||||
Reference in New Issue
Block a user