forked from rust-lang/book
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
388e1a3
commit 3a2eb34
Showing
6 changed files
with
145 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[[questions]] | ||
type = "MultipleChoice" | ||
prompt.prompt = """ | ||
The `Stream` trait is most analogous to which non-async trait in the Rust standard library? | ||
""" | ||
prompt.distractors = ["`Write`", "`Index`", "`Sync`"] | ||
answer.answer = "`Iterator`" | ||
context = """ | ||
The `Stream` trait provides an asynchronous version of a Rust iterator. | ||
""" | ||
id = "f94a87f0-a4d6-4cd6-bcee-dfcc606f8ec2" | ||
|
||
[[questions]] | ||
type = "MultipleChoice" | ||
prompt.prompt = """ | ||
Say you have a stream that produces the sequence `["A", "B", "C"]` and another stream that produces the sequence ["D", "E", "F"]. | ||
You do not know when each stream will emit each character, only that it occurs in the specified sequences. | ||
Consider merging these streams and printing each character. Then select each of the following output strings that could print. | ||
""" | ||
prompt.distractors = [ | ||
"ACBDEF", | ||
"CFBEAD" | ||
] | ||
answer.answer = [ | ||
"ABDEFC", | ||
"DEFABC" | ||
] | ||
context = """ | ||
Merging will always respect ordering in each stream, so for example "B" cannot occur before "C". | ||
""" | ||
id = "84452eff-13df-4fcb-91ea-1f504d5bfaf0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[[questions]] | ||
type = "MultipleChoice" | ||
prompt.prompt = """ | ||
Imagine Rust did not require that futures were pinned in order to be polled. | ||
Which of the following async functions could potentially cause undefined behavior if not pinned? | ||
""" | ||
prompt.distractors = [ | ||
""" | ||
```rust | ||
async fn example(x: &i32) -> i32 { | ||
sleep(Duration::from_secs(1)).await; | ||
*y | ||
} | ||
``` | ||
""", | ||
""" | ||
```rust | ||
async fn example(x: Vec<i32>) -> i32 { | ||
sleep(Duration::from_secs(1)).await; | ||
x[0] | ||
} | ||
``` | ||
""", | ||
""" | ||
```rust | ||
async fn example() -> i32 { | ||
let x = 0; | ||
sleep(Duration::from_secs(1)).await; | ||
x | ||
} | ||
``` | ||
""", | ||
] | ||
answer.answer = """ | ||
```rust | ||
async fn example(x: i32) -> i32 { | ||
let y = &x; | ||
sleep(Duration::from_secs(1)).await; | ||
*y | ||
} | ||
``` | ||
""" | ||
context = """ | ||
The core problem addressed by pinning in self-reference, or a future which contains a pointer to itself. | ||
This happens an async block contains a local variable that refers to another local variable in the future. | ||
Here, that would be `y = &x`. | ||
""" | ||
id = "bc8b4acb-d111-4fec-b89a-e5d1bc77c8f2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters