- 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.
推薦閱讀
- Monkey Game Development:Beginner's Guide
- Python量化投資指南:基礎、數據與實戰
- Apache Spark 2 for Beginners
- OpenNI Cookbook
- Mastering Kali Linux for Web Penetration Testing
- 軟件工程
- AutoCAD VBA參數化繪圖程序開發與實戰編碼
- SQL Server 2012數據庫管理與開發項目教程
- 從Java到Web程序設計教程
- Access 2010中文版項目教程
- MySQL程序員面試筆試寶典
- Xamarin Blueprints
- Learning Bootstrap 4(Second Edition)
- 每個人的Python:數學、算法和游戲編程訓練營
- Improving your Penetration Testing Skills