adrientetar / rust-tuts Goto Github PK
View Code? Open in Web Editor NEWA tutorial for the Rust programming language. Open to contributions!
Home Page: http://adrientetar.github.io/rust-tuts
A tutorial for the Rust programming language. Open to contributions!
Home Page: http://adrientetar.github.io/rust-tuts
This will make keeping the tutorial up-to-date easier, and will catch any accidental mistakes in the snippets.
(src/etc/extract-tests.py
in the main Rust codebase is a script that does something similar for the examples in the "official" tutorial.)
Here are the general rules:
cast as T ref change-no allocation ⇒ read-only &'a T -> &'a U
conversion .to_T() .into_T() allocates new memory “in-place” conversion, without copying &T -> ~U ~T -> ~UYou can see as as a sole modified reference to a value in memory, while others change the in-memory representation of the converted variable.
(&str).into_owned() -> ~str
has to allocate an new memory and copy, because it comes from a trait)as T
isn't a general conversion mechanism, in particular (&T) as (&U)
is never ever valid, and T as U
is only valid for a restricted subset of types. It should be .as_T()
to match the the othersas T
itself does change the in memory representation (e.g. int as f64
will perform a (relatively expensive) int
-> f64
conversion: they're not bitwise identical)The current document states:
Rust is also the result of a true willingness to reuse what’s been left by the rich history of programming languages, rather been building up the wheel over again. ;) ~ as you might have seen, that’s where the name “Rust” comes from!
However, this is not the whole story :)
Here is a quote from an email I got from Graydon when I asked him a few months back where the name came from, I think it should be put somewhere in the docs, but I'm not sure where so I open an issue for now:
I was fiddling with a number of names. Primarily it's named after the pathogenic fungi [1] which are just amazing multi-lifecycle, multi-host parasites, fascinating creatures.
But the name "rust" has other nice features. It fits with our theme of being "close to the metal" and "using old well-worn language technology". It's also a substring of "trust" and "robust". What's not to like?
Optional tracing-GC (WIP) – the std::gc::Gc type recently landed on mainline
The Gc type is not a GC and definitely not tracing: it's currently just using @ internally.
http://adridu59.github.io/rust-tuts/tutorial/ch-03.html:
fn abs(x: int) -> uint {
if x > 0 { x }
-x
}
is missing an else
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.