compio_io::util

Function repeat

Source
pub fn repeat(byte: u8) -> Repeat
Expand description

Creates a reader that infinitely repeats one byte.

All reads from this reader will succeed by filling the specified buffer with the given byte.

ยงExamples

use compio_io::{self, AsyncRead, AsyncReadExt};

let ((), buffer) = compio_io::repeat(42)
    .read_exact(Vec::with_capacity(3))
    .await
    .unwrap();

assert_eq!(buffer.as_slice(), [42, 42, 42]);