
Rust by Example - kercker
http://rustbyexample.com/
======
killercup
If you want something like this but a little bit shorter that easily fits on 3
printed pages:
[https://learnxinyminutes.com/docs/rust/](https://learnxinyminutes.com/docs/rust/)

~~~
sitkack
And [https://play.rust-lang.org/](https://play.rust-lang.org/) can be used to
test snippets of Rust code w/o having to install compiler. The best feature is
you can make a link to your code for others to review.

------
sambe
I found this to be okay as a relatively speedy intro. It's quite disorganised
though - some concepts and terms appear to be assumed but then introduced
properly later on. I was wondering if this was intentional or not (maybe you
are supposed to be patient?).

~~~
halomru
I assume the site is mostly aimed at people who have already read the rust
book [1].

[1] [https://doc.rust-lang.org/book/](https://doc.rust-lang.org/book/)

~~~
brinker
Rust by Example was actually not originally a Rust team project. It was an
independent work that was handed over to the Rust team for maintenance by the
original author.

As I understand, it received basic polishing and updates to make sure it was
correct, but hasn't been edited much beyond that.

~~~
steveklabnik
This history is accurate. RBE is pretty low on my priority list; finishing up
the book and the standard library docs are much more important right now. I to
try to keep up on PRs.

------
Twirrim
What's with the exclamation mark at the end of function names? e.g.
println!("foo")

~~~
cfallin
That signifies a macro. It's meant to visually distinguish macros from
ordinary function calls because macros may have arbitrary semantics (they can
expand into any code at all). The stdlib defines `println` as a macro because
it allows for a neat compile-time parsing of format strings.

(See [1] and the linked source if curious.)

[1] [https://doc.rust-lang.org/std/macro.println!.html](https://doc.rust-
lang.org/std/macro.println!.html)

~~~
Grue3
Sounds like what Rust needs is _compile macros_ [1]. That way, printf can
still be a function, but it would be optimized at compile time if the
formatting string is constant.

[1]
[https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node101.html](https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node101.html)

~~~
akjj
Compile macros wouldn't be sufficient for Rust's println! because the type
signature (even the number of arguments) depends on the format string. The
format string has to be constant and has to be interpreted at compile time so
that the variables being printed can be type-checked.

------
sig_chld_mike
no table of contents? see the gobyexample.com site for how to do it better

~~~
robmccoll
Are you on mobile? I get a hamburger menu at the top that pulls out a ToC from
the left side.

~~~
blub
Nothing appears on iOS with content blockers on, but the menu is still
clickable. Another brilliant example of modern web-design.

~~~
whateveracct
Did you scroll a little bit? It's not visible unless you scroll up.

