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

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.

主站蜘蛛池模板: 宁国市| 合阳县| 广德县| 吉首市| 县级市| 新田县| 绍兴县| 龙里县| 肥东县| 石台县| 陆川县| 玛沁县| 临湘市| 乐昌市| 永川市| 沙田区| 赣榆县| 江源县| 阿克| 巴青县| 吉安市| 长丰县| 西城区| 葵青区| 黄平县| 临朐县| 忻城县| 天等县| 高雄县| 阿城市| 仙居县| 济宁市| 那曲县| 阳东县| 武汉市| 清丰县| 南宁市| 永宁县| 营口市| 尼勒克县| 板桥市|