-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathinfo.toml
403 lines (328 loc) · 13 KB
/
info.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# INTRO
# [[exercises]]
# name = "intro1"
# path = "exercises/intro/intro1.rs"
# mode = "compile"
# hint = """
# Remove the I AM NOT DONE comment in the exercises/intro/intro1.rs file
# to move on to the next exercise."""
# VECS
[[exercises]]
name = "vecs1"
path = "exercises/vecs/vecs1.rs"
mode = "test"
hint = """
In Rust, there are two ways to define a Vector.
1. One way is to use the `Vec::new()` function to create a new vector
and fill it with the `push()` method.
2. The second way, which is simpler is to use the `vec![]` macro and
define your elements inside the square brackets.
Check this chapter: https://doc.rust-lang.org/stable/book/ch08-01-vectors.html
of the Rust book to learn more.
"""
[[exercises]]
name = "vecs2"
path = "exercises/vecs/vecs2.rs"
mode = "test"
hint = """
Hint 1: In the code, the variable `element` represents an item from the Vec as it is being iterated.
Can you try multiplying this?
Hint 2: For the first function, there's a way to directly access the numbers stored
in the Vec, using the * dereference operator. You can both access and write to the
number that way.
After you've completed both functions, decide for yourself which approach you like
better. What do you think is the more commonly used pattern under Rust developers?
"""
# MOVE SEMANTICS
[[exercises]]
name = "move_semantics4"
path = "exercises/move_semantics/move_semantics4.rs"
mode = "compile"
hint = """
Stop reading whenever you feel like you have enough direction :) Or try
doing one step and then fixing the compiler errors that result!
So the end goal is to:
- get rid of the first line in main that creates the new vector
- so then `vec0` doesn't exist, so we can't pass it to `fill_vec`
- `fill_vec` has had its signature changed, which our call should reflect
- since we're not creating a new vec in `main` anymore, we need to create
a new vec in `fill_vec`, similarly to the way we did in `main`"""
[[exercises]]
name = "move_semantics5"
path = "exercises/move_semantics/move_semantics5.rs"
mode = "compile"
hint = """
Carefully reason about the range in which each mutable reference is in
scope. Does it help to update the value of referent (x) immediately after
the mutable reference is taken? Read more about 'Mutable References'
in the book's section References and Borrowing':
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.
"""
[[exercises]]
name = "move_semantics6"
path = "exercises/move_semantics/move_semantics6.rs"
mode = "compile"
hint = """
To find the answer, you can consult the book section "References and Borrowing":
https://doc.rust-lang.org/stable/book/ch04-02-references-and-borrowing.html
The first problem is that `get_char` is taking ownership of the string.
So `data` is moved and can't be used for `string_uppercase`
`data` is moved to `get_char` first, meaning that `string_uppercase` cannot manipulate the data.
Once you've fixed that, `string_uppercase`'s function signature will also need to be adjusted.
Can you figure out how?
Another hint: it has to do with the `&` character."""
# STRUCTS
[[exercises]]
name = "structs1"
path = "exercises/structs/structs1.rs"
mode = "test"
hint = """
Rust has more than one type of struct. Three actually, all variants are used to package related data together.
There are normal (or classic) structs. These are named collections of related data stored in fields.
Tuple structs are basically just named tuples.
Finally, Unit-like structs. These don't have any fields and are useful for generics.
In this exercise you need to complete and implement one of each kind.
Read more about structs in The Book: https://doc.rust-lang.org/book/ch05-01-defining-structs.html"""
# STRINGS
[[exercises]]
name = "strings3"
path = "exercises/strings/strings3.rs"
mode = "test"
hint = """
There's tons of useful standard library functions for strings. Let's try and use some of
them: <https://doc.rust-lang.org/std/string/struct.String.html#method.trim>!
For the compose_me method: You can either use the `format!` macro, or convert the string
slice into an owned string, which you can then freely extend."""
[[exercises]]
name = "strings4"
path = "exercises/strings/strings4.rs"
mode = "compile"
hint = "No hints this time ;)"
# MODULES
[[exercises]]
name = "modules2"
path = "exercises/modules/modules2.rs"
mode = "compile"
hint = """
The delicious_snacks module is trying to present an external interface that is
different than its internal structure (the `fruits` and `veggies` modules and
associated constants). Complete the `use` statements to fit the uses in main and
find the one keyword missing for both constants.
Learn more at https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#re-exporting-names-with-pub-use"""
# HASHMAPS
[[exercises]]
name = "hashmaps1"
path = "exercises/hashmaps/hashmaps1.rs"
mode = "test"
hint = """
Hint 1: Take a look at the return type of the function to figure out
the type for the `basket`.
Hint 2: Number of fruits should be at least 5. And you have to put
at least three different types of fruits.
"""
[[exercises]]
name = "hashmaps2"
path = "exercises/hashmaps/hashmaps2.rs"
mode = "test"
hint = """
Use the `entry()` and `or_insert()` methods of `HashMap` to achieve this.
Learn more at https://doc.rust-lang.org/stable/book/ch08-03-hash-maps.html#only-inserting-a-value-if-the-key-has-no-value
"""
[[exercises]]
name = "hashmaps3"
path = "exercises/hashmaps/hashmaps3.rs"
mode = "test"
hint = """
Hint 1: Use the `entry()` and `or_insert()` methods of `HashMap` to insert entries corresponding to each team in the scores table.
Learn more at https://doc.rust-lang.org/stable/book/ch08-03-hash-maps.html#only-inserting-a-value-if-the-key-has-no-value
Hint 2: If there is already an entry for a given key, the value returned by `entry()` can be updated based on the existing value.
Learn more at https://doc.rust-lang.org/book/ch08-03-hash-maps.html#updating-a-value-based-on-the-old-value
"""
# QUIZ 2
[[exercises]]
name = "quiz2"
path = "exercises/quiz2.rs"
mode = "test"
hint = "No hints this time ;)"
# OPTIONS
[[exercises]]
name = "options1"
path = "exercises/options/options1.rs"
mode = "test"
hint = """
Options can have a Some value, with an inner value, or a None value, without an inner value.
There's multiple ways to get at the inner value, you can use unwrap, or pattern match. Unwrapping
is the easiest, but how do you do it safely so that it doesn't panic in your face later?"""
# Generics
[[exercises]]
name = "generics1"
path = "exercises/generics/generics1.rs"
mode = "compile"
hint = """
Vectors in Rust make use of generics to create dynamically sized arrays of any type.
You need to tell the compiler what type we are pushing onto this vector."""
[[exercises]]
name = "generics2"
path = "exercises/generics/generics2.rs"
mode = "test"
hint = """
Currently we are wrapping only values of type 'u32'.
Maybe we could update the explicit references to this data type somehow?
If you are still stuck https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-method-definitions
"""
# TRAITS
[[exercises]]
name = "traits3"
path = "exercises/traits/traits3.rs"
mode = "test"
hint = """
Traits can have a default implementation for functions. Structs that implement
the trait can then use the default version of these functions if they choose not
implement the function themselves.
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#default-implementations
"""
[[exercises]]
name = "traits4"
path = "exercises/traits/traits4.rs"
mode = "test"
hint = """
Instead of using concrete types as parameters you can use traits. Try replacing the
'??' with 'impl <what goes here?>'
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
"""
# QUIZ 3
[[exercises]]
name = "quiz3"
path = "exercises/quiz3.rs"
mode = "test"
hint = """
To find the best solution to this challenge you're going to need to think back to your
knowledge of traits, specifically Trait Bound Syntax - you may also need this: `use std::fmt::Display;`."""
# LIFETIMES
[[exercises]]
name = "lifetimes1"
path = "exercises/lifetimes/lifetimes1.rs"
mode = "compile"
hint = """
Let the compiler guide you. Also take a look at the book if you need help:
https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html"""
[[exercises]]
name = "lifetimes2"
path = "exercises/lifetimes/lifetimes2.rs"
mode = "compile"
hint = """
Remember that the generic lifetime 'a will get the concrete lifetime that is equal to the smaller of the lifetimes of x and y.
You can take at least two paths to achieve the desired result while keeping the inner block:
1. Move the string2 declaration to make it live as long as string1 (how is result declared?)
2. Move println! into the inner block"""
[[exercises]]
name = "lifetimes3"
path = "exercises/lifetimes/lifetimes3.rs"
mode = "compile"
hint = """
If you use a lifetime annotation in a struct's fields, where else does it need to be added?"""
# STANDARD LIBRARY TYPES
[[exercises]]
name = "iterators1"
path = "exercises/iterators/iterators1.rs"
mode = "compile"
hint = """
Step 1:
We need to apply something to the collection `my_fav_fruits` before we start to go through
it. What could that be? Take a look at the struct definition for a vector for inspiration:
https://doc.rust-lang.org/std/vec/struct.Vec.html
Step 2 & step 3:
Very similar to the lines above and below. You've got this!
Step 4:
An iterator goes through all elements in a collection, but what if we've run out of
elements? What should we expect here? If you're stuck, take a look at
https://doc.rust-lang.org/std/iter/trait.Iterator.html for some ideas.
"""
[[exercises]]
name = "iterators2"
path = "exercises/iterators/iterators2.rs"
mode = "test"
hint = """
Step 1
The variable `first` is a `char`. It needs to be capitalized and added to the
remaining characters in `c` in order to return the correct `String`.
The remaining characters in `c` can be viewed as a string slice using the
`as_str` method.
The documentation for `char` contains many useful methods.
https://doc.rust-lang.org/std/primitive.char.html
Step 2
Create an iterator from the slice. Transform the iterated values by applying
the `capitalize_first` function. Remember to collect the iterator.
Step 3.
This is surprisingly similar to the previous solution. Collect is very powerful
and very general. Rust just needs to know the desired type."""
# SMART POINTERS
[[exercises]]
name = "box1"
path = "exercises/smart_pointers/box1.rs"
mode = "test"
hint = """
Step 1
The compiler's message should help: since we cannot store the value of the actual type
when working with recursive types, we need to store a reference (pointer) to its value.
We should, therefore, place our `List` inside a `Box`. More details in the book here:
https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes
Step 2
Creating an empty list should be fairly straightforward (hint: peek at the assertions).
For a non-empty list keep in mind that we want to use our Cons "list builder".
Although the current list is one of integers (i32), feel free to change the definition
and try other types!
"""
[[exercises]]
name = "rc1"
path = "exercises/smart_pointers/rc1.rs"
mode = "compile"
hint = """
This is a straightforward exercise to use the Rc<T> type. Each Planet has
ownership of the Sun, and uses Rc::clone() to increment the reference count of the Sun.
After using drop() to move the Planets out of scope individually, the reference count goes down.
In the end the sun only has one reference again, to itself. See more at:
https://doc.rust-lang.org/book/ch15-04-rc.html
* Unfortunately Pluto is no longer considered a planet :(
"""
[[exercises]]
name = "arc1"
path = "exercises/smart_pointers/arc1.rs"
mode = "compile"
hint = """
Make `shared_numbers` be an `Arc` from the numbers vector. Then, in order
to avoid creating a copy of `numbers`, you'll need to create `child_numbers`
inside the loop but still in the main thread.
`child_numbers` should be a clone of the Arc of the numbers instead of a
thread-local copy of the numbers.
This is a simple exercise if you understand the underlying concepts, but if this
is too much of a struggle, consider reading through all of Chapter 16 in the book:
https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html
"""
[[exercises]]
name = "cow1"
path = "exercises/smart_pointers/cow1.rs"
mode = "test"
hint = """
If Cow already owns the data it doesn't need to clone it when to_mut() is called.
Check out https://doc.rust-lang.org/std/borrow/enum.Cow.html for documentation
on the `Cow` type.
"""
# MACROS
[[exercises]]
name = "macros1"
path = "exercises/macros/macros1.rs"
mode = "compile"
hint = """
When you call a macro, you need to add something special compared to a
regular function call. If you're stuck, take a look at what's inside
`my_macro`."""
[[exercises]]
name = "macros2"
path = "exercises/macros/macros2.rs"
mode = "compile"
hint = """
Macros don't quite play by the same rules as the rest of Rust, in terms of
what's available where.
Unlike other things in Rust, the order of "where you define a macro" versus
"where you use it" actually matters."""