Explain what Ferris means in the Introduction

This commit is contained in:
Artem Varaksa 2018-08-29 11:08:57 +03:00
parent 55ff82d6f1
commit 3b87791976
3 changed files with 26 additions and 4 deletions

View File

@ -27,3 +27,7 @@ body.ayu .not_desired_behavior {
width: 10%;
height: auto;
}
.ferris-explain {
width: 100px;
}

View File

@ -27,10 +27,17 @@ function makeFerris (type) {
var elements = document.getElementsByClassName(type.attr)
for (var codeBlock of elements) {
var img = document.createElement("img")
var a = document.createElement('a')
a.setAttribute('href', 'ch00-00-introduction.html#ferris')
a.setAttribute('target', '_blank')
var img = document.createElement('img')
img.setAttribute('src', 'img/ferris/' + type.attr + '.svg')
img.setAttribute('title', type.title)
img.className = 'ferris'
codeBlock.parentElement.insertBefore(img, codeBlock)
a.appendChild(img)
codeBlock.parentElement.insertBefore(a, codeBlock)
}
}

View File

@ -162,14 +162,25 @@ There is no wrong way to read this book: if you want to skip ahead, go for it!
You might have to jump back to earlier chapters if you experience any
confusion. But do whatever works for you.
<span id="ferris"></span>
An important part of the process of learning Rust is learning how to read the
error messages the compiler displays: these will guide you toward working code.
As such, well provide many examples of code that doesnt compile along with
the error message the compiler will show you in each situation. Know that if
you enter and run a random example, it may not compile! Make sure you read the
surrounding text to see whether the example youre trying to run is meant to
error. In most situations, well lead you to the correct version of any code
that doesnt compile.
error. Ferris will also help you distinguish code that isn't meant to work:
| Ferris | Meaning |
|------------------------------------------------------------------------|--------------------------------------------------|
| <img src="img/ferris/does_not_compile.svg" class="ferris-explain"> | This code does not compile! |
| <img src="img/ferris/panics.svg" class="ferris-explain"> | This code panics! |
| <img src="img/ferris/unsafe.svg" class="ferris-explain"> | This code block contains unsafe code. |
| <img src="img/ferris/not_desired_behavior.svg" class="ferris-explain"> | This code does not produce the desired behavior. |
In most situations, well lead you to the correct version of any code that
doesnt compile.
## Source Code