Compare commits
6 Commits
5140cd3b37
...
ffb2f08b67
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffb2f08b67 | ||
|
|
baca47f782 | ||
|
|
d442b61795 | ||
|
|
d77272a5b4 | ||
|
|
deb4ccb643 | ||
|
|
35a2ff1efe |
@@ -95,8 +95,8 @@ Ownership can be transferred.
|
|||||||
If you own a value, for example, you can transfer ownership to another variable:
|
If you own a value, for example, you can transfer ownership to another variable:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
let a = 42; // <--- `a` is the owner of the value `42`
|
let a = "hello, world".to_string(); // <--- `a` is the owner of the String
|
||||||
let b = a; // <--- `b` is now the owner of the value `42`
|
let b = a; // <--- `b` is now the owner of the String
|
||||||
```
|
```
|
||||||
|
|
||||||
Rust's ownership system is baked into the type system: each function has to declare in its signature
|
Rust's ownership system is baked into the type system: each function has to declare in its signature
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ You've already encountered a few macros in past exercises:
|
|||||||
Rust macros are **code generators**.\
|
Rust macros are **code generators**.\
|
||||||
They generate new Rust code based on the input you provide, and that generated code is then compiled alongside
|
They generate new Rust code based on the input you provide, and that generated code is then compiled alongside
|
||||||
the rest of your program. Some macros are built into Rust's standard library, but you can also
|
the rest of your program. Some macros are built into Rust's standard library, but you can also
|
||||||
write your own. We won't be creating our macro in this course, but you can find some useful
|
write your own. We won't be creating our own macro in this course, but you can find some useful
|
||||||
pointers in the ["Further reading" section](#further-reading).
|
pointers in the ["Further reading" section](#further-reading).
|
||||||
|
|
||||||
### Inspection
|
### Inspection
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ assert_eq!(numbers.get(0), Some(&1));
|
|||||||
assert_eq!(numbers.get(3), None);
|
assert_eq!(numbers.get(3), None);
|
||||||
```
|
```
|
||||||
|
|
||||||
Access is bounds-checked, just element access with arrays. It has O(1) complexity.
|
Access is bounds-checked, just like element access with arrays. It has O(1) complexity.
|
||||||
|
|
||||||
## Memory layout
|
## Memory layout
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ pub async fn run() {
|
|||||||
if let Ok(reason) = e.try_into_panic() {
|
if let Ok(reason) = e.try_into_panic() {
|
||||||
// The task has panicked
|
// The task has panicked
|
||||||
// We resume unwinding the panic,
|
// We resume unwinding the panic,
|
||||||
// thus propagating it to the current thread
|
// thus propagating it to the current task
|
||||||
panic::resume_unwind(reason);
|
panic::resume_unwind(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ project and on [exercism.io](https://exercism.io)'s Rust track.
|
|||||||
Check out [the Rust book](https://doc.rust-lang.org/book/title-page.html) and
|
Check out [the Rust book](https://doc.rust-lang.org/book/title-page.html) and
|
||||||
["Programming Rust"](https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/)
|
["Programming Rust"](https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/)
|
||||||
if you're looking for a different perspective on the same concepts we covered throughout this course.
|
if you're looking for a different perspective on the same concepts we covered throughout this course.
|
||||||
The material doesn't overlap perfectly, therefore you'll certainly learn something new along the
|
You'll certainly learn something new since they don't cover exactly the same topics; Rust has a lot of surface area!
|
||||||
way.
|
|
||||||
|
|
||||||
### Advanced material
|
### Advanced material
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// TODO: Set `move_forward` to `true` in `ready` when you think you're done with this exercise.
|
||||||
|
// Feel free to call an instructor to verify your solution!
|
||||||
use channels::data::TicketDraft;
|
use channels::data::TicketDraft;
|
||||||
use channels::{launch, Command};
|
use channels::{launch, Command};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -24,8 +26,6 @@ fn ready() {
|
|||||||
// since our server doesn't expose any **read** actions.
|
// since our server doesn't expose any **read** actions.
|
||||||
// We have no way to know if the inserts are actually happening and if they
|
// We have no way to know if the inserts are actually happening and if they
|
||||||
// are happening correctly.
|
// are happening correctly.
|
||||||
// Set `move_forward` to `true` when you think you're done with this exercise.
|
|
||||||
// Feel free to call an instructor to verify your solution!
|
|
||||||
let move_forward = false;
|
let move_forward = false;
|
||||||
|
|
||||||
assert!(move_forward);
|
assert!(move_forward);
|
||||||
|
|||||||
Reference in New Issue
Block a user