Skip to content

Commit 2b2fbe9

Browse files
authored
Merge pull request #723 from Zerotask/update-exercises-readme
docs(exercises): consistent excersises README.md files
2 parents 54804e3 + 249ad44 commit 2b2fbe9

File tree

20 files changed

+85
-54
lines changed

20 files changed

+85
-54
lines changed

exercises/clippy/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
### Clippy
1+
# Clippy
22

33
The Clippy tool is a collection of lints to analyze your code so you can catch common mistakes and improve your Rust code.
44

55
If you used the installation script for Rustlings, Clippy should be already installed.
66
If not you can install it manually via `rustup component add clippy`.
77

8-
For more information about Clippy lints, please see [their documentation page](https://rust-lang.github.io/rust-clippy/master/).
8+
## Further information
9+
10+
- [GitHub Repository](https://github.com/rust-lang/rust-clippy).

exercises/collections/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Collections
1+
# Collections
22

33
Rust’s standard library includes a number of very useful data
44
structures called collections. Most other data types represent one
@@ -17,4 +17,6 @@ structures that are used very often in Rust programs:
1717
You may also know this by the names [*unordered map* in C++](https://en.cppreference.com/w/cpp/container/unordered_map),
1818
[*dictionary* in Python](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) or an *associative array* in other languages.
1919

20-
[Rust book chapter](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html)
20+
## Further information
21+
22+
- [Storing Lists of Values with Vectors](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html)

exercises/conversions/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
### Type conversions
2-
1+
# Type conversions
32

43
Rust offers a multitude of ways to convert a value of a given type into another type.
54

@@ -15,6 +14,8 @@ Furthermore, the `std::str` module offers a trait called [`FromStr`](https://doc
1514

1615
These should be the main ways ***within the standard library*** to convert data into your desired types.
1716

18-
#### Book Sections
17+
## Further information
1918

20-
These are not directly covered in the book, but the standard library has great documentation for [conversions here](https://doc.rust-lang.org/std/convert/index.html). The `FromStr` trait is also covered [here](https://doc.rust-lang.org/std/str/trait.FromStr.html).
19+
These are not directly covered in the book, but the standard library has a great documentation for it.
20+
- [conversions](https://doc.rust-lang.org/std/convert/index.html)
21+
- [`FromStr` trait](https://doc.rust-lang.org/std/str/trait.FromStr.html)

exercises/enums/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
### Enums
1+
# Enums
22

33
Rust allows you to define types called "enums" which enumerate possible values.
44
Enums are a feature in many languages, but their capabilities differ in each language. Rust’s enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell.
55
Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration.
66

7-
#### Book Sections
7+
## Further information
88

99
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)
1010
- [Pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html)

exercises/error_handling/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
For this exercise check out the sections:
2-
- [Error Handling](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html)
3-
- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html)
1+
# Error handling
2+
Most errors aren’t serious enough to require the program to stop entirely.
3+
Sometimes, when a function fails, it’s for a reason that you can easily interpret and respond to.
4+
For example, if you try to open a file and that operation fails because the file doesn’t exist, you might want to create the file instead of terminating the process.
45

5-
of the Rust Book.
6+
## Further information
67

7-
or alternatively, check out the sections:
8+
- [Error Handling](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html)
9+
- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html)
810
- [Result](https://doc.rust-lang.org/rust-by-example/error/result.html)
911
- [Boxing errors](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/boxing_errors.html)
10-
11-
of the Rust By Example Book.

exercises/functions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
### Functions
1+
# Functions
22

33
Here, you'll learn how to write functions and how Rust's compiler can trace things way back.
44

5-
#### Book Sections
5+
## Further information
66

77
- [How Functions Work](https://doc.rust-lang.org/book/ch03-03-how-functions-work.html)

exercises/generics/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
### Generics
1+
# Generics
22

3-
In this section you'll learn about saving yourself many lines of code with generics!
3+
Generics is the topic of generalizing types and functionalities to broader cases.
4+
This is extremely useful for reducing code duplication in many ways, but can call for rather involving syntax.
5+
Namely, being generic requires taking great care to specify over which types a generic type is actually considered valid.
6+
The simplest and most common use of generics is for type parameters.
47

5-
### Book Sections
8+
## Further information
69

710
- [Generic Data Types](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html)
811
- [Bounds](https://doc.rust-lang.org/rust-by-example/generics/bounds.html)

exercises/if/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
### If
1+
# If
22

33
`if`, the most basic type of control flow, is what you'll learn here.
44

5-
#### Book Sections
5+
## Further information
66

77
- [Control Flow - if expressions](https://doc.rust-lang.org/book/ch03-05-control-flow.html#if-expressions)

exercises/macros/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
### Macros
1+
# Macros
22

33
Rust's macro system is very powerful, but also kind of difficult to wrap your
44
head around. We're not going to teach you how to write your own fully-featured
55
macros. Instead, we'll show you how to use and create them.
66

7-
#### Book Sections
7+
## Further information
88

99
- [Macros](https://doc.rust-lang.org/book/ch19-06-macros.html)
1010
- [The Little Book of Rust Macros](https://danielkeep.github.io/tlborm/book/index.html)

exercises/modules/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
### Modules
1+
# Modules
22

33
In this section we'll give you an introduction to Rust's module system.
44

5-
#### Book Sections
5+
## Further information
66

77
- [The Module System](https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html)

exercises/move_semantics/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
### Move Semantics
1+
# Move Semantics
22

33
These exercises are adapted from [pnkfelix](https://github.com/pnkfelix)'s [Rust Tutorial](https://pnkfelix.github.io/rust-examples-icfp2014/) -- Thank you Felix!!!
44

5-
#### Book Sections
5+
## Further information
66

77
For this section, the book links are especially important.
88

exercises/option/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
### Option
1+
# Option
22

3-
#### Book Sections
3+
Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not.
4+
Option types are very common in Rust code, as they have a number of uses:
5+
- Initial values
6+
- Return values for functions that are not defined over their entire input range (partial functions)
7+
- Return value for otherwise reporting simple errors, where None is returned on error
8+
- Optional struct fields
9+
- Struct fields that can be loaned or "taken"
10+
- Optional function arguments
11+
- Nullable pointers
12+
- Swapping things out of difficult situations
413

5-
To learn about Option<T>, check out these links:
14+
## Further Information
615

716
- [Option Enum Format](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-enum-definitions)
817
- [Option Module Documentation](https://doc.rust-lang.org/std/option/)

exercises/primitive_types/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
### Primitive Types
1+
# Primitive Types
22

33
Rust has a couple of basic types that are directly implemented into the
44
compiler. In this section, we'll go through the most important ones.
55

6-
#### Book Sections
6+
## Further information
77

88
- [Data Types](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html)
99
- [The Slice Type](https://doc.rust-lang.org/stable/book/ch04-03-slices.html)
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
For the Box exercise check out the chapter [Using Box to Point to Data on the Heap](https://doc.rust-lang.org/book/ch15-01-box.html).
1+
# Standard library types
22

3-
For the Arc exercise check out the chapter [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html) of the Rust Book.
3+
This section will teach you about Box, Shared-State Concurrency and Iterators.
44

5-
For the Iterator exercise check out the chapters [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html) of the Rust Book and the [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/).
5+
## Further information
6+
7+
- [Using Box to Point to Data on the Heap](https://doc.rust-lang.org/book/ch15-01-box.html)
8+
- [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html)
9+
- [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html)
10+
- [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/)

exercises/strings/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
### Strings
1+
# Strings
22

33
Rust has two string types, a string slice (`&str`) and an owned string (`String`).
44
We're not going to dictate when you should use which one, but we'll show you how
55
to identify and create them, as well as use them.
66

7-
#### Book Sections
7+
## Further information
88

99
- [Strings](https://doc.rust-lang.org/book/ch08-02-strings.html)

exercises/structs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
### Structs
1+
# Structs
22

33
Rust has three struct types: a classic C struct, a tuple struct, and a unit struct.
44

5-
#### Book Sections
5+
## Further information
66

77
- [Structures](https://doc.rust-lang.org/book/ch05-01-defining-structs.html)
88
- [Method Syntax](https://doc.rust-lang.org/book/ch05-03-method-syntax.html)

exercises/tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
### Tests
1+
# Tests
22

33
Going out of order from the book to cover tests -- many of the following exercises will ask you to make tests pass!
44

5-
#### Book Sections
5+
## Further information
66

77
- [Writing Tests](https://doc.rust-lang.org/book/ch11-01-writing-tests.html)

exercises/threads/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
For this exercise check out the [Dining Philosophers example](https://doc.rust-lang.org/1.4.0/book/dining-philosophers.html) and the chapter [Concurrency](https://doc.rust-lang.org/book/ch16-01-threads.html) of the Rust Book.
1+
# Threads
2+
3+
In most current operating systems, an executed program’s code is run in a process, and the operating system manages multiple processes at once.
4+
Within your program, you can also have independent parts that run simultaneously. The features that run these independent parts are called threads.
5+
6+
## Further information
7+
8+
- [Dining Philosophers example](https://doc.rust-lang.org/1.4.0/book/dining-philosophers.html)
9+
- [Using Threads to Run Code Simultaneously](https://doc.rust-lang.org/book/ch16-01-threads.html)

exercises/traits/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Traits
1+
# Traits
22

33
A trait is a collection of methods.
44

@@ -7,14 +7,13 @@ Data types can implement traits. To do so, the methods making up the trait are d
77
In this way, traits are somewhat similar to Java interfaces and C++ abstract classes.
88

99
Some additional common Rust traits include:
10-
11-
+ `Clone` (the `clone` method),
12-
+ `Display` (which allows formatted display via `{}`), and
13-
+ `Debug` (which allows formatted display via `{:?}`).
10+
- `Clone` (the `clone` method)
11+
- `Display` (which allows formatted display via `{}`)
12+
- `Debug` (which allows formatted display via `{:?}`)
1413

1514
Because traits indicate shared behavior between data types, they are useful when writing generics.
1615

1716

18-
#### Book Sections
17+
## Further information
1918

2019
- [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html)

exercises/variables/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
### Variables
1+
# Variables
22

3-
Here you'll learn about simple variables.
3+
In Rust, variables are immutable by default.
4+
When a variable is immutable, once a value is bound to a name, you can’t change that value.
5+
You can make them mutable by adding mut in front of the variable name.
46

5-
#### Book Sections
7+
## Further information
68

79
- [Variables and Mutability](https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html)

0 commit comments

Comments
 (0)