fn insert_within(
    _ctx: &mut Context,
    rng: &mut RngType,
    buf: &mut Vec<u8>,
    r: RangeInclusive<u64>,
) -> bool {
    let max_len = min(buf.len(), (*r.end() as usize).saturating_sub(buf.len()));
    if max_len < 2 {
        return false;
    }
    let op_len = rand_op_len(rng, max_len);
    let src = rng.gen_range(0..=(buf.len() - op_len));
    let dst = rng.gen_range(0..=buf.len());

    let src_backup = buf[src..(src + op_len)].to_vec();
    buf.splice(dst..dst, src_backup);
    true
}
/// Duplicates a block and inserts it at random position.
Duplicates a block and inserts it at random position.
Duplicates a block and inserts it at random position .
fn insert_within(
    _ctx: &mut Context,
    rng: &mut RngType,
    buf: &mut Vec<u8>,
    r: RangeInclusive<u64>,
) -> bool {
    let max_len = min(buf.len(), (*r.end() as usize).saturating_sub(buf.len()));
    if max_len < 2 {
        return false;
    }
    let op_len = rand_op_len(rng, max_len);
    let src = rng.gen_range(0..=(buf.len() - op_len));
    let dst = rng.gen_range(0..=buf.len());
    let src_backup = buf[src..(src + op_len)].to_vec();
    buf.splice(dst..dst, src_backup);
    true
}
fn insert_within ( _ctx : & mut Context , rng : & mut RngType , buf : & mut Vec < u8 > , r : RangeInclusive < u64 > , ) -> bool { let max_len = min ( buf . len ( ) , ( * r . end ( ) as usize ) . saturating_sub ( buf . len ( ) ) ) ; if max_len < 2 { return false ; } let op_len = rand_op_len ( rng , max_len ) ; let src = rng . gen_range ( 0 ..= ( buf . len ( ) - op_len ) ) ; let dst = rng . gen_range ( 0 ..= buf . len ( ) ) ; let src_backup = buf [ src .. ( src + op_len ) ] . to_vec ( ) ; buf . splice ( dst .. dst , src_backup ) ; true }
Duplicates a block and inserts it at random position.
Duplicates a block and inserts it at random position .
_ctx
&mut Context
rng
&mut RngType
buf
&mut Vec<u8>
r
RangeInclusive<u64>
_ctx
&mut Context
rng
&mut RngType
buf
&mut Vec<u8>
r
RangeInclusive<u64>