Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Pointer Exercises for Box #507

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions en/src/smart-pointers/box.md
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
# Box

1. 🌟
```rust,editable
// Make it work
fn main() {
// Create a new box `b` that contains the integer 5
assert_eq!(*b, 5);

println!("Success!");
}
```

2. 🌟
```rust,editable

// Make it work
fn main() {
let b = Box::new("Hello");
print_boxed_string(b);
}

fn print_boxed_string(b : _) {
println!("{}", b);
}
```

3. 🌟
```rust,editable

// Make it work
fn main() {
let b1 = Box::new(5);
let b2 = b1;
assert_eq!(_, 5);

println!("Success!");
}
```

4. 🌟
```rust,editable

// Make it work
fn main() {
// Create a box `b` with an array [1, 2, 3, 4, 5]
// Print each integer in `b`
}
```


> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it