mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 20:49:41 +00:00
Signed-off-by: roneya <iamrohanvidhate@gmail.com>
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
```rust,editable
|
```rust,editable
|
||||||
// Make it work
|
// Make it work
|
||||||
fn main() {
|
fn main() {
|
||||||
let b = Box::new(5);
|
// Create a new box `b` that contains the integer 5
|
||||||
assert_eq!(*b, 5);
|
assert_eq!(*b, 5);
|
||||||
|
|
||||||
println!("Success!");
|
println!("Success!");
|
||||||
@ -20,7 +20,7 @@ fn main() {
|
|||||||
print_boxed_string(b);
|
print_boxed_string(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_boxed_string(b : Box<&str>) {
|
fn print_boxed_string(b : _) {
|
||||||
println!("{}", b);
|
println!("{}", b);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -32,7 +32,7 @@ fn print_boxed_string(b : Box<&str>) {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let b1 = Box::new(5);
|
let b1 = Box::new(5);
|
||||||
let b2 = b1;
|
let b2 = b1;
|
||||||
assert_eq!(*b2, 5);
|
assert_eq!(_, 5);
|
||||||
|
|
||||||
println!("Success!");
|
println!("Success!");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user