impl AsyncWrite for std::io::Cursor (#1730)

Based on the implementation from the futures crate.
This commit is contained in:
Sebastian Dröge
2019-11-03 21:21:01 +09:00
committed by Taiki Endo
parent e19bd77ef0
commit 6b35a1e8b0
2 changed files with 83 additions and 0 deletions
+11
View File
@@ -44,3 +44,14 @@ async fn write() {
assert_eq!(n, 4);
assert_eq!(wr.buf, b"hell"[..]);
}
#[tokio::test]
async fn write_cursor() {
use std::io::Cursor;
let mut wr = Cursor::new(Vec::new());
let n = assert_ok!(wr.write(b"hello world").await);
assert_eq!(n, 11);
assert_eq!(wr.get_ref().as_slice(), &b"hello world"[..]);
}