- 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
- MySQL 8從入門到精通(視頻教學(xué)版)
- Visual Basic編程:從基礎(chǔ)到實(shí)踐(第2版)
- C#完全自學(xué)教程
- Web Application Development with R Using Shiny(Second Edition)
- C程序設(shè)計(jì)案例教程
- Big Data Analytics
- TypeScript項(xiàng)目開發(fā)實(shí)戰(zhàn)
- 深入淺出Go語言編程
- Python入門很輕松(微課超值版)
- Java Web應(yīng)用開發(fā)給力起飛
- 玩轉(zhuǎn).NET Micro Framework移植:基于STM32F10x處理器
- Greenplum構(gòu)建實(shí)時(shí)數(shù)據(jù)倉庫實(shí)踐
- C語言從入門到精通
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)案例教程(第二版)