/// Overwrites a block with a random block within the buffer.
Overwrites a block with a random block within the buffer.
Overwrites a block with a random block within the buffer .
fn overwrite_within(
    _ctx: &mut Context,
    rng: &mut RngType,
    buf: &mut Vec<u8>,
    _r: RangeInclusive<u64>,
) -> bool {
    let len = buf.len();
    if len < 2 {
        return false;
    }
    let op_len = rand_op_len(rng, len);
    let src = rng.gen_range(0..=(len - op_len));
    let dst = rng.gen_range(0..=(len - op_len));
    if op_len != len && src != dst {
        // SAFETY: `buf`, `src_start` and `dst_start` are valid, `op_len` won't exceed required range.
        unsafe { std::ptr::copy(&buf[src], &mut buf[dst], op_len) };
        return true;
    }
    false
}
fn overwrite_within ( _ctx : & mut Context , rng : & mut RngType , buf : & mut Vec < u8 > , _r : RangeInclusive < u64 > , ) -> bool { let len = buf . len ( ) ; if len < 2 { return false ; } let op_len = rand_op_len ( rng , len ) ; let src = rng . gen_range ( 0 ..= ( len - op_len ) ) ; let dst = rng . gen_range ( 0 ..= ( len - op_len ) ) ; if op_len != len && src != dst { // SAFETY: `buf`, `src_start` and `dst_start` are valid, `op_len` won't exceed required range. unsafe { std :: ptr :: copy ( & buf [ src ] , & mut buf [ dst ] , op_len ) } ; return true ; } false }
Overwrites a block with a random block within the buffer.
Overwrites a block with a random block within the buffer .
_ctx
&mut Context
rng
&mut RngType
buf
&mut Vec<u8>
_r
RangeInclusive<u64>