- 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.
推薦閱讀
- LabVIEW 2018 虛擬儀器程序設(shè)計
- 在最好的年紀(jì)學(xué)Python:小學(xué)生趣味編程
- PyTorch Artificial Intelligence Fundamentals
- Visual C#通用范例開發(fā)金典
- NoSQL數(shù)據(jù)庫原理
- JavaScript應(yīng)用開發(fā)實踐指南
- 零基礎(chǔ)輕松學(xué)C++:青少年趣味編程(全彩版)
- 人人都能開發(fā)RPA機器人:UiPath從入門到實戰(zhàn)
- UI動效設(shè)計從入門到精通
- C/C++代碼調(diào)試的藝術(shù)
- 美麗洞察力:從化妝品行業(yè)看顧客需求洞察
- Linux Networking Cookbook
- Mastering R for Quantitative Finance
- Mastering Unity Scripting
- 零基礎(chǔ)入門學(xué)習(xí)C語言:帶你學(xué)C帶你飛