Compare commits
25 Commits
97d13e5c85
...
c437f75fcf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c437f75fcf | ||
|
|
f839fc00f9 | ||
|
|
954dd0ff14 | ||
|
|
33bcaf0a7a | ||
|
|
0aecb5380e | ||
|
|
276bdbbcdc | ||
|
|
a899ecec96 | ||
|
|
a0537f8c51 | ||
|
|
73649001ba | ||
|
|
99ee4b27c5 | ||
|
|
af6c605fe6 | ||
|
|
f613c9a58b | ||
|
|
e9c4f37130 | ||
|
|
e768d9dbd8 | ||
|
|
ea71ac2c0a | ||
|
|
0ca42ba058 | ||
|
|
681903a853 | ||
|
|
6bdcf19f5f | ||
|
|
297d78d750 | ||
|
|
cab4de6433 | ||
|
|
52c21a241d | ||
|
|
982a8f0789 | ||
|
|
1b050774e7 | ||
|
|
d269320825 | ||
|
|
8730a8458a |
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
@@ -15,16 +15,27 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
repository: mainmatter/core-sans-a-fonts
|
||||||
|
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
path: core-sans-a-fonts
|
||||||
|
- name: Install Fonts
|
||||||
|
run: |
|
||||||
|
sudo cp -r core-sans-a-fonts/* /usr/local/share/fonts/
|
||||||
|
sudo fc-cache -f -v
|
||||||
|
fc-list | grep "Core Sans"
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- name: Install exercise plugin
|
- name: Install exercise plugin
|
||||||
run: cargo install --path helpers/mdbook-exercise-linker
|
run: cargo install --path helpers/mdbook-exercise-linker
|
||||||
- name: Install link shortener plugin
|
- name: Install link shortener plugin
|
||||||
run: cargo install --path helpers/mdbook-link-shortener
|
run: cargo install --path helpers/mdbook-link-shortener
|
||||||
- name: Install mdbook-pandoc, calibre and related dependencies
|
- name: Install mdbook-pandoc, calibre, pdftk and related dependencies
|
||||||
run: |
|
run: |
|
||||||
cargo install mdbook-pandoc --locked --version 0.7.1
|
cargo install mdbook-pandoc --locked --version 0.7.1
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y fonts-noto calibre
|
sudo apt-get install -y fonts-noto calibre pdftk
|
||||||
|
|
||||||
export PANDOC_VERSION=3.3
|
export PANDOC_VERSION=3.3
|
||||||
curl -LsSf https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz | tar zxf -
|
curl -LsSf https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz | tar zxf -
|
||||||
@@ -70,6 +81,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd book
|
cd book
|
||||||
mdbook build
|
mdbook build
|
||||||
|
- name: Add cover and back to downloadable PDF
|
||||||
|
run: |
|
||||||
|
pdftk book/assets/cover.pdf book/book/pandoc/pdf/100-exercises-to-learn-rust.pdf book/assets/back.pdf cat output book/book/pandoc/pdf/100-exercises-to-learn-rust-with-cover.pdf
|
||||||
|
mv book/book/pandoc/pdf/100-exercises-to-learn-rust-with-cover.pdf book/book/pandoc/pdf/100-exercises-to-learn-rust.pdf
|
||||||
- name: Convert HTML to ePUB
|
- name: Convert HTML to ePUB
|
||||||
run: |
|
run: |
|
||||||
cd book/book/pandoc/html
|
cd book/book/pandoc/html
|
||||||
|
|||||||
BIN
book/assets/back.pdf
Normal file
BIN
book/assets/back.pdf
Normal file
Binary file not shown.
BIN
book/assets/cover.pdf
Normal file
BIN
book/assets/cover.pdf
Normal file
Binary file not shown.
@@ -22,32 +22,46 @@ git-repository-url = "https://github.com/mainmatter/100-exercises-to-learn-rust"
|
|||||||
optional = true
|
optional = true
|
||||||
hosted-html = "https://rust-exercises.com/100-exercises/"
|
hosted-html = "https://rust-exercises.com/100-exercises/"
|
||||||
|
|
||||||
|
[output.pandoc.code]
|
||||||
|
show-hidden-lines = true
|
||||||
|
|
||||||
[output.pandoc.profile.pdf] # options to pass to Pandoc (see https://pandoc.org/MANUAL.html)
|
[output.pandoc.profile.pdf] # options to pass to Pandoc (see https://pandoc.org/MANUAL.html)
|
||||||
output-file = "100-exercises-to-learn-rust.pdf"
|
output-file = "100-exercises-to-learn-rust.pdf"
|
||||||
to = "latex"
|
to = "latex"
|
||||||
highlight-style = "tango"
|
highlight-style = "./custom.theme"
|
||||||
# We use `lualatext` because, right now, it's the only engine
|
# We use `lualatext` because, right now, it's the only engine
|
||||||
# that supports fallback fonts, which we need for emojis.
|
# that supports fallback fonts, which we need for emojis.
|
||||||
pdf-engine = "lualatex"
|
pdf-engine = "lualatex"
|
||||||
metadata-file = "metadata.yml"
|
metadata-file = "metadata.yml"
|
||||||
|
|
||||||
[output.pandoc.profile.pdf.variables]
|
[output.pandoc.profile.pdf.variables]
|
||||||
|
mainfont = "CoreSansA45.ttf"
|
||||||
|
mainfontoptions = [
|
||||||
|
"BoldFont=CoreSansA65.ttf",
|
||||||
|
"ItalicFont=CoreSansA45It.ttf",
|
||||||
|
"BoldItalicFont=CoreSansA65It.ttf",
|
||||||
|
]
|
||||||
|
sansfont = "CoreSansA45.ttf"
|
||||||
|
sansfontoptions = [
|
||||||
|
"BoldFont=CoreSansA65.ttf",
|
||||||
|
"ItalicFont=CoreSansA45It.ttf",
|
||||||
|
"BoldItalicFont=CoreSansA65It.ttf",
|
||||||
|
]
|
||||||
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
|
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
|
||||||
mainfont = "Noto Serif"
|
|
||||||
sansfont = "Noto Sans"
|
|
||||||
monofont = "Noto Sans Mono"
|
monofont = "Noto Sans Mono"
|
||||||
mainfontfallback = ["Noto Color Emoji:mode=harf"]
|
mainfontfallback = ["Noto Color Emoji:mode=harf"]
|
||||||
sansfontfallback = ["Noto Color Emoji:mode=harf"]
|
sansfontfallback = ["Noto Color Emoji:mode=harf"]
|
||||||
monofontfallback = [
|
monofontfallback = [
|
||||||
"Noto Color Emoji:mode=harf",
|
"Noto Color Emoji:mode=harf",
|
||||||
]
|
]
|
||||||
linkcolor = "blue"
|
linkcolor = "Links"
|
||||||
urlcolor = "blue"
|
urlcolor = "Links"
|
||||||
urlstyle = "rm"
|
urlstyle = "rm"
|
||||||
documentclass = "book"
|
documentclass = "book"
|
||||||
fontsize = "11pt"
|
fontsize = "10pt"
|
||||||
geometry = "papersize={8in,10in},top=2cm,bottom=2cm,left=2.4cm,right=2.4cm"
|
geometry = "papersize={8in,10in},top=2cm,bottom=2cm,left=2.4cm,right=2.4cm"
|
||||||
header-includes = [
|
header-includes = [
|
||||||
|
"\\definecolor{Links}{HTML}{6200EE}",
|
||||||
# Reduce font size of code blocks
|
# Reduce font size of code blocks
|
||||||
"\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\},fontsize=\\small}",
|
"\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\},fontsize=\\small}",
|
||||||
]
|
]
|
||||||
@@ -62,20 +76,33 @@ metadata-file = "metadata.yml"
|
|||||||
pdf-engine = "lualatex"
|
pdf-engine = "lualatex"
|
||||||
|
|
||||||
[output.pandoc.profile.paperback.variables]
|
[output.pandoc.profile.paperback.variables]
|
||||||
|
mainfont = "CoreSansA45.ttf"
|
||||||
|
mainfontoptions = [
|
||||||
|
"BoldFont=CoreSansA65.ttf",
|
||||||
|
"ItalicFont=CoreSansA45It.ttf",
|
||||||
|
"BoldItalicFont=CoreSansA65It.ttf",
|
||||||
|
]
|
||||||
|
sansfont = "CoreSansA45.ttf"
|
||||||
|
sansfontoptions = [
|
||||||
|
"BoldFont=CoreSansA65.ttf",
|
||||||
|
"ItalicFont=CoreSansA45It.ttf",
|
||||||
|
"BoldItalicFont=CoreSansA65It.ttf",
|
||||||
|
]
|
||||||
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
|
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
|
||||||
mainfont = "Noto Serif"
|
|
||||||
sansfont = "Noto Sans"
|
|
||||||
monofont = "Noto Sans Mono"
|
monofont = "Noto Sans Mono"
|
||||||
mainfontfallback = ["Noto Color Emoji:mode=harf"]
|
mainfontfallback = ["Noto Color Emoji:mode=harf"]
|
||||||
sansfontfallback = ["Noto Color Emoji:mode=harf"]
|
sansfontfallback = ["Noto Color Emoji:mode=harf"]
|
||||||
monofontfallback = [
|
monofontfallback = [
|
||||||
"Noto Color Emoji:mode=harf",
|
"Noto Color Emoji:mode=harf",
|
||||||
]
|
]
|
||||||
|
linkcolor = "Links"
|
||||||
|
urlcolor = "Links"
|
||||||
urlstyle = "rm"
|
urlstyle = "rm"
|
||||||
documentclass = "book"
|
documentclass = "book"
|
||||||
fontsize = "11pt"
|
fontsize = "10pt"
|
||||||
geometry = "papersize={8in,10in},top=2cm,bottom=2cm,left=2.8cm,right=2.5cm"
|
geometry = "papersize={8in,10in},top=2cm,bottom=2cm,left=2.8cm,right=2.5cm"
|
||||||
header-includes = [
|
header-includes = [
|
||||||
|
"\\definecolor{Links}{HTML}{6200EE}",
|
||||||
# Reduce font size of code blocks
|
# Reduce font size of code blocks
|
||||||
"\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\},fontsize=\\small}",
|
"\\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\\\\{\\},fontsize=\\small}",
|
||||||
]
|
]
|
||||||
@@ -93,14 +120,10 @@ metadata-file = "metadata.yml"
|
|||||||
|
|
||||||
[output.pandoc.profile.html.variables]
|
[output.pandoc.profile.html.variables]
|
||||||
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
|
# You can get these fonts here: https://fonts.google.com/selection?query=noto+color+
|
||||||
mainfont = "Noto Serif"
|
|
||||||
sansfont = "Noto Sans"
|
|
||||||
monofont = "Noto Sans Mono"
|
monofont = "Noto Sans Mono"
|
||||||
mainfontfallback = ["Noto Color Emoji:mode=harf"]
|
mainfontfallback = ["Noto Color Emoji:mode=harf"]
|
||||||
sansfontfallback = ["Noto Color Emoji:mode=harf"]
|
sansfontfallback = ["Noto Color Emoji:mode=harf"]
|
||||||
monofontfallback = [
|
monofontfallback = [
|
||||||
"Noto Color Emoji:mode=harf",
|
"Noto Color Emoji:mode=harf",
|
||||||
]
|
]
|
||||||
linkcolor = "blue"
|
|
||||||
urlcolor = "blue"
|
|
||||||
urlstyle = "rm"
|
urlstyle = "rm"
|
||||||
|
|||||||
211
book/custom.theme
Normal file
211
book/custom.theme
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
{
|
||||||
|
"text-color": "#c9d1d9",
|
||||||
|
"background-color": "#343942",
|
||||||
|
"line-number-color": null,
|
||||||
|
"line-number-background-color": null,
|
||||||
|
"text-styles": {
|
||||||
|
"Alert": {
|
||||||
|
"text-color": "#ff0000",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Annotation": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": true,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Attribute": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"BaseN": {
|
||||||
|
"text-color": "#a5d6ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"BuiltIn": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Char": {
|
||||||
|
"text-color": "#a5d6ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Comment": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": true,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"CommentVar": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": true,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Constant": {
|
||||||
|
"text-color": "#79c0ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"ControlFlow": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"DataType": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"DecVal": {
|
||||||
|
"text-color": "#79c0ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Documentation": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": true,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Error": {
|
||||||
|
"text-color": "#ff0000",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Extension": {
|
||||||
|
"text-color": null,
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Float": {
|
||||||
|
"text-color": "#79c0ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Function": {
|
||||||
|
"text-color": "#d2a8ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Import": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Information": {
|
||||||
|
"text-color": "#8b949e",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": true,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Keyword": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Operator": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Other": {
|
||||||
|
"text-color": "#007020",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Preprocessor": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"SpecialChar": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"SpecialString": {
|
||||||
|
"text-color": "#03DAC5",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"String": {
|
||||||
|
"text-color": "#a5d6ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Variable": {
|
||||||
|
"text-color": "#a8daff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"VerbatimString": {
|
||||||
|
"text-color": "#a5d6ff",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false
|
||||||
|
},
|
||||||
|
"Warning": {
|
||||||
|
"text-color": "#60a0b0",
|
||||||
|
"background-color": null,
|
||||||
|
"bold": true,
|
||||||
|
"italic": true,
|
||||||
|
"underline": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -181,6 +181,7 @@
|
|||||||
"https://valgrind.org/docs/manual/dh-manual.html": "f2t",
|
"https://valgrind.org/docs/manual/dh-manual.html": "f2t",
|
||||||
"https://veykril.github.io/tlborm/": "fz5",
|
"https://veykril.github.io/tlborm/": "fz5",
|
||||||
"https://without.boats/blog/the-scoped-task-trilemma/": "f67",
|
"https://without.boats/blog/the-scoped-task-trilemma/": "f67",
|
||||||
|
"https://www.amazon.com/dp/B0DJ14KQQG/": "f6g",
|
||||||
"https://www.lpalmieri.com/": "ffv",
|
"https://www.lpalmieri.com/": "ffv",
|
||||||
"https://www.lpalmieri.com/posts/2020-12-11-zero-to-production-6-domain-modelling/": "f4t",
|
"https://www.lpalmieri.com/posts/2020-12-11-zero-to-production-6-domain-modelling/": "f4t",
|
||||||
"https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/": "f6y",
|
"https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/": "f6y",
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ also find solutions to all exercises in the
|
|||||||
|
|
||||||
## Formats
|
## Formats
|
||||||
|
|
||||||
You can go through the course material [in the browser](https://rust-exercises.com/100-exercises/).\
|
You can go through the course material [in the browser](https://rust-exercises.com/100-exercises/) or [download it as a PDF file](https://rust-exercises.com/100-exercises-to-learn-rust.pdf), for offline reading.\
|
||||||
You can also [download it as a PDF file](https://rust-exercises.com/100-exercises-to-learn-rust.pdf), for offline reading.
|
If you prefer to have the course material printed out, [buy a paperback copy on Amazon](https://www.amazon.com/dp/B0DJ14KQQG/).
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ store and retrieve tickets.
|
|||||||
The task will give us an opportunity to explore new Rust concepts, such as:
|
The task will give us an opportunity to explore new Rust concepts, such as:
|
||||||
|
|
||||||
- Stack-allocated arrays
|
- Stack-allocated arrays
|
||||||
- `Vec`, a growable array type, and slices
|
- `Vec`, a growable array type
|
||||||
- `Iterator` and `IntoIterator`, for iterating over collections
|
- `Iterator` and `IntoIterator`, for iterating over collections
|
||||||
- Slices (`&[T]`), to work with parts of a collection
|
- Slices (`&[T]`), to work with parts of a collection
|
||||||
- Lifetimes, to describe how long references are valid
|
- Lifetimes, to describe how long references are valid
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Combinators
|
# Combinators
|
||||||
|
|
||||||
Iterators can do so much more than `for` loops!\
|
Iterators can do so much more than `for` loops!\
|
||||||
If you look at the documentation for the `Iterator` trait, you'll find a **vast** collections of
|
If you look at the documentation for the `Iterator` trait, you'll find a **vast** collection of
|
||||||
methods that you can leverage to transform, filter, and combine iterators in various ways.
|
methods that you can leverage to transform, filter, and combine iterators in various ways.
|
||||||
|
|
||||||
Let's mention the most common ones:
|
Let's mention the most common ones:
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ asynchronous programming in Rust.
|
|||||||
The entrypoint of your executable, the `main` function, must be a synchronous function.
|
The entrypoint of your executable, the `main` function, must be a synchronous function.
|
||||||
That's where you're supposed to set up and launch your chosen async runtime.
|
That's where you're supposed to set up and launch your chosen async runtime.
|
||||||
|
|
||||||
Most runtimes provides a macro to make this easier. For `tokio`, it's `tokio::main`:
|
Most runtimes provide a macro to make this easier. For `tokio`, it's `tokio::main`:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ impl Ticket {
|
|||||||
// - the `title` should be at most 50 bytes long.
|
// - the `title` should be at most 50 bytes long.
|
||||||
// - the `description` should be at most 500 bytes long.
|
// - the `description` should be at most 500 bytes long.
|
||||||
// The method should panic if any of the requirements are not met.
|
// The method should panic if any of the requirements are not met.
|
||||||
|
// You can find the needed panic messages in the tests.
|
||||||
//
|
//
|
||||||
// You'll have to use what you learned in the previous exercises,
|
// You'll have to use what you learned in the previous exercises,
|
||||||
// as well as some `String` methods. Use the documentation of Rust's standard library
|
// as well as some `String` methods. Use the documentation of Rust's standard library
|
||||||
|
|||||||
@@ -99,5 +99,11 @@ mod tests {
|
|||||||
|
|
||||||
let ticket = &store[id];
|
let ticket = &store[id];
|
||||||
assert_eq!(ticket.status, Status::InProgress);
|
assert_eq!(ticket.status, Status::InProgress);
|
||||||
|
|
||||||
|
let ticket = &mut store[&id];
|
||||||
|
ticket.status = Status::Done;
|
||||||
|
|
||||||
|
let ticket = &store[id];
|
||||||
|
assert_eq!(ticket.status, Status::Done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,6 +180,7 @@
|
|||||||
/f2t https://valgrind.org/docs/manual/dh-manual.html
|
/f2t https://valgrind.org/docs/manual/dh-manual.html
|
||||||
/fz5 https://veykril.github.io/tlborm/
|
/fz5 https://veykril.github.io/tlborm/
|
||||||
/f67 https://without.boats/blog/the-scoped-task-trilemma/
|
/f67 https://without.boats/blog/the-scoped-task-trilemma/
|
||||||
|
/f6g https://www.amazon.com/dp/B0DJ14KQQG/
|
||||||
/ffv https://www.lpalmieri.com/
|
/ffv https://www.lpalmieri.com/
|
||||||
/f4t https://www.lpalmieri.com/posts/2020-12-11-zero-to-production-6-domain-modelling/
|
/f4t https://www.lpalmieri.com/posts/2020-12-11-zero-to-production-6-domain-modelling/
|
||||||
/f6y https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/
|
/f6y https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/
|
||||||
|
|||||||
Reference in New Issue
Block a user