SQ in silver chrome letters, a lab's gear stacked against the S: a rack, two oscilloscopes, pizza boxes and a six-pack. Strange Query Lab
Chapters

rust-cardiac

  1. Contents
  2. Lexical structure
  3. Macros
  4. Items
  5. Attributes
  6. Statements and expressions
  7. Patterns
  8. Types
  9. Memory
  10. Panic
  11. Unsafety
  12. Constant evaluation
  13. The runtime
  14. Appendix: The core library

CARDIAC › rust-cardiac › Language Reference › Unsafety

Unsafety

What's different on CARDIAC

  • assume() matters more than in Rust: every check the compiler can drop saves cells out of 96.
  • Everything else on this page works as in Rust.

assume

unsafe { assume(cond) }, from the cardiac crate, is Rust's assert_unchecked. It lets the compiler leave out a check it can then prove. Break the assumption and the program reads whatever is there. With debug assertions on (debug-assertions in the profile), the assumption is checked on CARDIAC too. Natively it always is.

assume() also helps the range pass: an Option<i16> whose payload is assumed never negative needs no tag cell. See Types.

Unchecked operations

unchecked_add and its kin, core::hint::assert_unchecked and unreachable_unchecked work. With debug assertions on, their preconditions are checked, and a violated one aborts: see Panic.

Raw pointers, unions and mutable statics

Raw pointers work, with p.add(i). A union works when it is read through the field it was written by. static mut works.

Feature tests: types and items.