unsafe fn update_counts<T>(raw_rc: *const T, update: i32, is_alias: bool) {
    let mut remaining = update;
    while remaining != 0 {
        let rc = Rc::from_raw(raw_rc);
        if remaining > 0 {
            // Create and leak new instances to increment the count on the contained item.
            if is_alias {
                let _ = Weak::into_raw(Rc::downgrade(&rc));
            } else {
                let _ = Rc::into_raw(Rc::clone(&rc));
            }

            remaining -= 1;
        } else {
            // Create and drop instances to decrement the count on contained item.
            if is_alias {
                let w = Weak::into_raw(Rc::downgrade(&rc));

                // Need to drop two for a net decrement, since above line increments.
                drop(Weak::from_raw(w));
                drop(Weak::from_raw(w));
            } else {
                drop(Rc::from_raw(raw_rc));
            }

            remaining += 1;
        }

        let _ = Rc::into_raw(rc);
    }
}
// Rust Implementation for Quantum Intermediate Representation
Rust Implementation for Quantum Intermediate Representation
Rust Implementation for Quantum Intermediate Representation
unsafe fn update_counts<T>(raw_rc: *const T, update: i32, is_alias: bool) {
    let mut remaining = update;
    while remaining != 0 {
        let rc = Rc::from_raw(raw_rc);
        if remaining > 0 {
            // Create and leak new instances to increment the count on the contained item.
            if is_alias {
                let _ = Weak::into_raw(Rc::downgrade(&rc));
            } else {
                let _ = Rc::into_raw(Rc::clone(&rc));
            }
            remaining -= 1;
        } else {
            // Create and drop instances to decrement the count on contained item.
            if is_alias {
                let w = Weak::into_raw(Rc::downgrade(&rc));
                // Need to drop two for a net decrement, since above line increments.
                drop(Weak::from_raw(w));
                drop(Weak::from_raw(w));
            } else {
                drop(Rc::from_raw(raw_rc));
            }
            remaining += 1;
        }
        let _ = Rc::into_raw(rc);
    }
}
unsafe fn update_counts < T > ( raw_rc : * const T , update : i32 , is_alias : bool ) { let mut remaining = update ; while remaining != 0 { let rc = Rc :: from_raw ( raw_rc ) ; if remaining > 0 { // Create and leak new instances to increment the count on the contained item. if is_alias { let _ = Weak :: into_raw ( Rc :: downgrade ( & rc ) ) ; } else { let _ = Rc :: into_raw ( Rc :: clone ( & rc ) ) ; } remaining -= 1 ; } else { // Create and drop instances to decrement the count on contained item. if is_alias { let w = Weak :: into_raw ( Rc :: downgrade ( & rc ) ) ; // Need to drop two for a net decrement, since above line increments. drop ( Weak :: from_raw ( w ) ) ; drop ( Weak :: from_raw ( w ) ) ; } else { drop ( Rc :: from_raw ( raw_rc ) ) ; } remaining += 1 ; } let _ = Rc :: into_raw ( rc ) ; } }
Rust Implementation for Quantum Intermediate Representation
Rust Implementation for Quantum Intermediate Representation
raw_rc
*const T
update
i32
is_alias
bool
raw_rc
*const T
update
i32
is_alias
bool