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

  • Rust Programming Cookbook
  • Claus Matzinger
  • 115字
  • 2021-06-24 12:27:50

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.

主站蜘蛛池模板: 炉霍县| 万山特区| 鸡泽县| 诏安县| 泌阳县| 新郑市| 乌兰察布市| 宝兴县| 德庆县| 固安县| 巴楚县| 绥宁县| 托里县| 上高县| 勐海县| 咸阳市| 奎屯市| 昌江| 湖南省| 伊春市| 襄垣县| 积石山| 堆龙德庆县| 康乐县| 丹寨县| 常熟市| 抚宁县| 曲松县| 新绛县| 清镇市| 永吉县| 越西县| 方城县| 抚顺县| 万盛区| 喀喇| 黑河市| 潼南县| 威海市| 弥勒县| 枞阳县|