mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
fix: otehrs.md 示例1处代码错误
This commit is contained in:
@ -99,7 +99,8 @@ fn foo() -> i32 {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let pointer = foo as *const ();
|
let pointer = foo as *const ();
|
||||||
let function = unsafe {
|
let function = unsafe {
|
||||||
std::mem::transmute::<*const (), fn() -> i32>(pointer)
|
std::mem::transmute::<*const (), fn() -> i32>(pointer)
|
||||||
|
};
|
||||||
assert_eq!(function(), 0);
|
assert_eq!(function(), 0);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -100,7 +100,8 @@ fn foo() -> i32 {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let pointer = foo as *const ();
|
let pointer = foo as *const ();
|
||||||
let function = unsafe {
|
let function = unsafe {
|
||||||
std::mem::transmute::<*const (), fn() -> i32>(pointer)
|
std::mem::transmute::<*const (), fn() -> i32>(pointer)
|
||||||
|
};
|
||||||
assert_eq!(function(), 0);
|
assert_eq!(function(), 0);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user