官术网_书友最值得收藏!

Reading memory the unsafe way

unsafe is a concept in Rust where some compiler safety mechanisms are turned off. These superpowers bring Rust closer to C's abilities to manipulate (almost) arbitrary parts of the memory. unsafe itself qualifies a scope (or function) to be able to use these four superpowers (from https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html ):

  • Dereference a raw pointer.
  • Call an unsafe function or method.
  • Access or modify a mutable static variable.
  • Implement an unsafe trait.

In most projects, unsafe is only required for using the FFI (short for Foreign Function Interface) because it's outside of the borrow checker's reach. Regardless, in this recipe, we are going to explore some unsafe ways to read memory.

主站蜘蛛池模板: 平塘县| 珠海市| 曲沃县| 凌源市| 沈丘县| 永仁县| 桦甸市| 延长县| 嘉定区| 休宁县| 武宁县| 托克托县| 九江县| 阿鲁科尔沁旗| 东莞市| 丹江口市| 界首市| 清徐县| 依兰县| 延庆县| 嘉黎县| 湘潭市| 延寿县| 红河县| 乡城县| 松滋市| 宜良县| 武城县| 北安市| 兰坪| 云浮市| 左云县| 会东县| 任丘市| 长兴县| 罗甸县| 永清县| 泉州市| 平塘县| 勐海县| 普格县|