/// Writes the given eight byte value into the given memory region.
///
/// Arguments:
/// - operation.repeat: the number of operations.
/// - operation.address: optional start address of the memory region. It is
///   chosen randomly if not given.
/// - operation.size: the size of the memory region in bytes.
/// - operation.value: optional eight byte value. It is chosen randomly if not
///   given.
Writes the given eight byte value into the given memory region.
Arguments:
operation.repeat: the number of operations.
operation.address: optional start address of the memory region. It is
chosen randomly if not given.
operation.size: the size of the memory region in bytes.
operation.value: optional eight byte value. It is chosen randomly if not
given.
Writes the given eight byte value into the given memory region . Arguments : operation . repeat : the number of operations . operation . address : optional start address of the memory region . It is chosen randomly if not given . operation . size : the size of the memory region in bytes . operation . value : optional eight byte value . It is chosen randomly if not given .
fn write() {
    let operation = operation_from_args();
    MEMORY.with(|memory| {
        let mut memory_ref = memory.borrow_mut();
        let memory = memory_ref.as_mut_slice();
        let repeat = operation.repeat.unwrap_or(1);
        let value = operation
            .value
            .unwrap_or_else(|| rand(0, u8::MAX.into()) as u8);
        let len = (operation.size + ELEMENT_SIZE - 1) / ELEMENT_SIZE;
        assert!(len <= MEMORY_LEN);
        for _ in 0..repeat {
            let dst = operation
                .address
                .unwrap_or_else(|| rand(0, MEMORY_LEN - len + 1) * ELEMENT_SIZE)
                / ELEMENT_SIZE;
            #[allow(clippy::needless_range_loop)]
            for i in dst..dst + len {
                memory[i] = value as u64;
            }
        }
    });
    api::reply(&[]);
}
fn write ( ) { let operation = operation_from_args ( ) ; MEMORY . with ( | memory | { let mut memory_ref = memory . borrow_mut ( ) ; let memory = memory_ref . as_mut_slice ( ) ; let repeat = operation . repeat . unwrap_or ( 1 ) ; let value = operation . value . unwrap_or_else ( | | rand ( 0 , u8 :: MAX . into ( ) ) as u8 ) ; let len = ( operation . size + ELEMENT_SIZE - 1 ) / ELEMENT_SIZE ; assert ! ( len MEMORY_LEN ) ; for _ in 0 .. repeat { let dst = operation . address . unwrap_or_else ( | | rand ( 0 , MEMORY_LEN - len + 1 ) * ELEMENT_SIZE ) / ELEMENT_SIZE ; # [ allow ( clippy needless_range_loop ) ] for i in dst .. dst + len { memory [ i ] = value as u64 ; } } } ) ; api :: reply ( & [ ] ) ; }
Writes the given eight byte value into the given memory region.
Writes the given eight byte value into the given memory region .