mirror of
https://github.com/gnu4cn/rust-lang-zh_CN.git
synced 2026-08-19 04:33:27 +08:00
Updated 'src/smart_pointers/deref-t'.
This commit is contained in:
@@ -17,9 +17,12 @@ impl<T> Deref for MyBox<T> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
let y = MyBox::new(x);
|
||||
hello("Rust");
|
||||
|
||||
assert_eq! (5, x);
|
||||
assert_eq! (5, *y);
|
||||
let m = MyBox::new(String::from("Rust"));
|
||||
hello(&m);
|
||||
}
|
||||
|
||||
fn hello(name: &str) {
|
||||
println! ("你好,{name}!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user