
Rust Lang in a nutshell - Edouar1
https://www.softax.pl/blog/rust-lang-in-a-nutshell-1-introduction/
======
chrismorgan
Skimming through this, there are syntax errors (e.g. → instead of -> and ’
instead of ' in some function signatures), inconsistencies in code style, and
a number of content errors (e.g. the content surrounding early return is still
quite wrong and suggests a lack of understanding of the actual feature,
expression-orientation; and the description of what &str is; and the
description of Copy and copy semantics being simplified beyond what I would
consider truth). Overall it’s a decent summary and most of the content seems
correct, but be careful.

~~~
sansnomme
The arrow thing is probably just editor font ligatures.

------
cpascal
If you are more of an interactive learner I would recommend installing rust on
your machine and then cloning the rustlings repo [https://github.com/rust-
lang/rustlings](https://github.com/rust-lang/rustlings).

Rustlings is an interactive collection of rust exercises that are either
incorrect or incomplete. The exercises are grouped into key concepts of rust
and cross referenced with relevant chapters in the rust book
[https://doc.rust-lang.org/book/](https://doc.rust-lang.org/book/)

The general flow is to open up the given chapter of the rust book for a set of
exercises and hack away at them until they compile. It's a good way to quickly
get an introduction to rust and its core features.

~~~
tasubotadas
Having gone through rustlings while learning rust, I can say that apart syntax
overview, they are almost useless.

I was much more successful by studying the rust book while trying to
solve/implement not completely trivial pet projects.

~~~
QueijoFresco
Do you mind sharing what kind of projects? Just in case you have a list laying
around.

~~~
tasubotadas
That would be something like:

* ToDo list with UI

* Stock Quote retrieval/analysis

* Toy VM/Interpreter

------
Lorkki
This seems like a fairly gentle introduction. I will definitely consider it as
a starting point for more junior developers interested in touching our Rust
code.

For those with more experience, Rust By Example walks through the same
concepts in a more compact form that also lets you experiment with the code in
your browser: [https://doc.rust-lang.org/rust-by-
example/index.html](https://doc.rust-lang.org/rust-by-example/index.html)

------
Karliss
Example for skipping return keyword in case of early return is just wrong. It
can be made to work if you have if x > 0 { x } else { x + 1 } but then it
isn't early return anymore.

~~~
bartkk
Thank you. We fixed this unfortunate example, and added some more explanation.

------
vsnf
See also, [https://doc.rust-lang.org/book/title-page.html](https://doc.rust-
lang.org/book/title-page.html)

~~~
rgoulter
I tend to like "Learn X in Y minutes" for a quick overview of common syntax /
constructs.
[https://learnxinyminutes.com/docs/rust/](https://learnxinyminutes.com/docs/rust/)

~~~
psibi
I have written down the summary of the Rust book when I was learning and going
through the book: [https://github.com/psibi/rust-book-
summary](https://github.com/psibi/rust-book-summary)

It's much denser than "Learn X in Y minutes" but it covers more.

------
xwowsersx
I highly, highly recommend this crash course from Michael Snoyman:
[https://www.snoyman.com/blog/2018/10/introducing-rust-
crash-...](https://www.snoyman.com/blog/2018/10/introducing-rust-crash-course)

------
brianzelip
Just heard an insightful (for an outsider) podcast episode on Rust with the
folks behind much of the resources being shared here in this thread.

_An Introduction to Rust featuring Carol Nichols and Jake Goulding_,
[https://www.heroku.com/podcasts/codeish/34-an-
introduction-t...](https://www.heroku.com/podcasts/codeish/34-an-introduction-
to-rust)

------
mcjiggerlog
Looks like it's down.

Webcache version -
[https://webcache.googleusercontent.com/search?q=cache:SHrbch...](https://webcache.googleusercontent.com/search?q=cache:SHrbchRsRpQJ:https://www.softax.pl/blog/rust-
lang-in-a-nutshell-1-introduction)

~~~
msrokk
we had some trouble but now it’s working

------
savolai

      let s1 ="hello world";
      let s2 = s1; // copied – x1 is still valid
      let x1 = 2;
      let x2 = x1; // copied – x1 is still valid
    
      println!("{} for the {}nd time!", s1, x1);
    

Typo in first comment? s1 vs x1?

~~~
msrokk
fixed, thank you

------
lordleft
I'm increasingly intrigued by Rust. Can anyone recommend a good analysis /
benchmarking of Rust compared to C/C++ code? Curious how it fares on a
performance basis.

~~~
bluejekyll
This is by no means scientific, but it’s a fun benchmark, there’s some debate
about the fastest Rust options submitted (ie I believe there were faster than
C versions that were rejected).

C: [https://benchmarksgame-
team.pages.debian.net/benchmarksgame/...](https://benchmarksgame-
team.pages.debian.net/benchmarksgame/fastest/rust.html)

Clang (for common llvm backend between rust and c): [https://benchmarksgame-
team.pages.debian.net/benchmarksgame/...](https://benchmarksgame-
team.pages.debian.net/benchmarksgame/fastest/rust-clang.html)

C++: [https://benchmarksgame-
team.pages.debian.net/benchmarksgame/...](https://benchmarksgame-
team.pages.debian.net/benchmarksgame/fastest/rust-gpp.html)

Rust is pretty much on par with both C and C++.

~~~
rumanator
> This is by no means scientific,

It's actually very scientific (testing hypothesis, measuring results, etc) but
might not be generalizable.

~~~
tasubotadas
What's missing in these tests is that they do not capture the required
knowledge by the developer to achieve those results.

If anybody has actually checked C/C++ examples, one could see that they use
non-trivial techniques/libraries to achieve superior performance.

What would be REALLY interesting to see is breakdown of the performance by the
years of experience of people that submitted working code examples.

I have a feeling that a developer with one year of experience in Java, will
probably beat developers with two years of experience in C/C++.

~~~
igouy
Do you have an example of program performance measurements that do "capture
the required knowledge by the developer" ?

How can you tell that the knowledge was actually "required" rather than
incidental ?

Wouldn't it depend exactly what experience they gained in that one year and
how relevant it was to the task at hand?

------
dantodor
Err Too many redirects

~~~
msrokk
we had some trouble but now it’s working

