diff options
| author | Alona Enraght-Moony <code@alona.page> | 2024-11-08 20:29:07 +0000 |
|---|---|---|
| committer | Alona Enraght-Moony <code@alona.page> | 2024-11-09 18:52:29 +0000 |
| commit | c496af64edf92e9e77f02fa552cd69019f7b2c35 (patch) | |
| tree | 8cb63a76d002ccf9badf4c05e2fd42b7e3dcead0 /library/std/src/io/tests.rs | |
| parent | b27f33a4d9c42ee6b5347a75a8a990a883437da9 (diff) | |
| download | rust-c496af64edf92e9e77f02fa552cd69019f7b2c35.tar.gz rust-c496af64edf92e9e77f02fa552cd69019f7b2c35.zip | |
Add as_slice/into_slice for IoSlice/IoSliceMut.
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk> Co-authored-by: Nathan West <Lucretiel@gmail.com>
Diffstat (limited to 'library/std/src/io/tests.rs')
| -rw-r--r-- | library/std/src/io/tests.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index 56b71c47dc7..89e806c0891 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -531,6 +531,20 @@ fn io_slice_advance_slices_beyond_total_length() { assert!(bufs.is_empty()); } +#[test] +fn io_slice_as_slice() { + let buf = [1; 8]; + let slice = IoSlice::new(&buf).as_slice(); + assert_eq!(slice, buf); +} + +#[test] +fn io_slice_into_slice() { + let mut buf = [1; 8]; + let slice = IoSliceMut::new(&mut buf).into_slice(); + assert_eq!(slice, [1; 8]); +} + /// Creates a new writer that reads from at most `n_bufs` and reads /// `per_call` bytes (in total) per call to write. fn test_writer(n_bufs: usize, per_call: usize) -> TestWriter { |
