- 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.
推薦閱讀
- Python程序設計教程(第2版)
- 體驗設計原理:行為、情感和細節
- Hadoop+Spark大數據分析實戰
- Bootstrap Essentials
- 人人都懂設計模式:從生活中領悟設計模式(Python實現)
- TradeStation交易應用實踐:量化方法構建贏家策略(原書第2版)
- JavaScript入門經典
- Visual FoxPro程序設計習題集及實驗指導(第四版)
- Getting Started with Eclipse Juno
- Android項目實戰:手機安全衛士開發案例解析
- Visualforce Developer’s guide
- Mastering Python Design Patterns
- 寫給青少年的人工智能(Python版·微課視頻版)
- Android技術內幕(系統卷)
- Python數據可視化之matplotlib實踐