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

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.

主站蜘蛛池模板: 屏山县| 蒙城县| 台湾省| 元氏县| 会泽县| 靖远县| 沈丘县| 瑞昌市| 南涧| 开平市| 岳西县| 龙口市| 湘乡市| 阿尔山市| 叶城县| 明星| 芷江| 开化县| 增城市| 丁青县| 同仁县| 岐山县| 上高县| 孟津县| 柘荣县| 耿马| 潮安县| 库车县| 瑞金市| 绵竹市| 法库县| 嘉兴市| 阿克陶县| 灵璧县| 黔江区| 康保县| 郸城县| 元阳县| 临漳县| 呼玛县| 全南县|