pub fn check_invariants<H: SizedHeap>(heap: H) {
    // The maximum value that can still be stored inline. Integers on the heap
    // should be larger than this, otherwise they should have been stored
    // inline. Consequently, integers smaller than this will be length prefixes.
    let max_inline_u64 = 0x4000_0000_0000_0000 - 1;

    let mut off = 0;
    loop {
        if off >= heap.len() {
            assert_eq!(off, heap.len(), "Heap size must be a multiple of 8.");
            break
        }

        let value = heap.get_u64(CidInt(off));
        if value > max_inline_u64 {
            // The value must have been an 8-byte unsigned int, move on.
            off += 8;
        } else {
            // The value was a length prefix. Skip over the data (aligned to 8
            // bytes).
            let data_len = value;
            let data_len_aligned = (data_len + 7) / 8 * 8;
            assert!(
                off + 8 + data_len_aligned <= heap.len(),
                "Byte string of length {} at offset {} does not fit heap of size {}.",
                off + 8, data_len, heap.len()
            );
            off += data_len_aligned + 8;
        }
    }
}
/// Assert that the heap is well-formed, that all invariants hold.
///
/// This function panics if the heap is not well-formed. This function is used
/// in tests and during fuzzing.
Assert that the heap is well-formed, that all invariants hold.
This function panics if the heap is not well-formed. This function is used
in tests and during fuzzing.
Assert that the heap is well - formed that all invariants hold . This function panics if the heap is not well - formed . This function is used in tests and during fuzzing .
pub fn check_invariants<H: SizedHeap>(heap: H) {
    // The maximum value that can still be stored inline. Integers on the heap
    // should be larger than this, otherwise they should have been stored
    // inline. Consequently, integers smaller than this will be length prefixes.
    let max_inline_u64 = 0x4000_0000_0000_0000 - 1;
    let mut off = 0;
    loop {
        if off >= heap.len() {
            assert_eq!(off, heap.len(), "Heap size must be a multiple of 8.");
            break
        }
        let value = heap.get_u64(CidInt(off));
        if value > max_inline_u64 {
            // The value must have been an 8-byte unsigned int, move on.
            off += 8;
        } else {
            // The value was a length prefix. Skip over the data (aligned to 8
            // bytes).
            let data_len = value;
            let data_len_aligned = (data_len + 7) / 8 * 8;
            assert!(
                off + 8 + data_len_aligned <= heap.len(),
                "Byte string of length {} at offset {} does not fit heap of size {}.",
                off + 8, data_len, heap.len()
            );
            off += data_len_aligned + 8;
        }
    }
}
pub fn check_invariants < H : SizedHeap > ( heap : H ) { // The maximum value that can still be stored inline. Integers on the heap // should be larger than this, otherwise they should have been stored // inline. Consequently, integers smaller than this will be length prefixes. let max_inline_u64 = 0x4000_0000_0000_0000 - 1 ; let mut off = 0 ; loop { if off >= heap . len ( ) { assert_eq ! ( off heap len ( ) " " ) ; break } let value = heap . get_u64 ( CidInt ( off ) ) ; if value > max_inline_u64 { // The value must have been an 8-byte unsigned int, move on. off += 8 ; } else { // The value was a length prefix. Skip over the data (aligned to 8 // bytes). let data_len = value ; let data_len_aligned = ( data_len + 7 ) / 8 * 8 ; assert ! ( off 8 data_len_aligned heap len ( ) " " off 8 data_len heap len ( ) ) ; off += data_len_aligned + 8 ; } } }
Assert that the heap is well-formed, that all invariants hold.
Assert that the heap is well - formed that all invariants hold .
heap
H
heap
H