Re:Abstraction without overhead: traits in Rust
by fmstephe on Monday May 11, 2015 @05:33PM
(#9528002)
I apologise in advance that this may not be most appropriate place to ask this question.
I am looking for a Rust tutorial. It looks like there was one, but it was deprecated in favour of 'the book'. But 'the book' doesn't seem to have a tutorial yet.
Are there any tutorial's running through how to build some small piece of working software.
I found the Golang tutorial, where you build a very basic blog extremely enjoyable. Does Rust have anything similar?
https://golang.org/doc/articles/wiki/
Thanks
Re:Abstraction without overhead: traits in Rust
by steveklabnik on Monday May 11, 2015 @05:36PM
(#9528018)
The book basically has two sets of tutorials: the "Syntax and Semantics" section is a bottom-up tutorial, and the "Learn Rust" section is a project-based, more top-down one. It's true that only one chapter of Learn Rust has landed at the moment. It's basically what I'm doing right now. Should have two or three more chapters over the next few days.
Re:Abstraction without overhead: traits in Rust
by fmstephe on Tuesday May 12, 2015 @04:19AM
(#9530210)
Great, thanks Steve.
Re:Abstraction without overhead: traits in Rust
by kalmar on Monday May 11, 2015 @11:29PM
(#9529437)
What is the representation for a type like Box<Reader+Writer>? Is there an extra indirection to get each of the vtables? Is there synthesized combined trait type and just one vtable pointer?
Re:Abstraction without overhead: traits in Rust
by Jweb_Guru on Tuesday May 12, 2015 @01:23AM
(#9529734)
I am pretty sure you can't actually construct such a type (at least not at the moment) so Rust sort of sidesteps the question.
Re:Abstraction without overhead: traits in Rust
by Manishearth on Tuesday May 12, 2015 @06:03AM
(#9530570)
IIRC you can.
Re:Abstraction without overhead: traits in Rust
by Rusky on Tuesday May 12, 2015 @09:07AM
(#9531409)
I get this when I try something like `as Box<Read+Write>`
error: only the builtin traits can be used as closure or object bounds [E0225]
Re:Abstraction without overhead: traits in Rust
by Manishearth on Tuesday May 12, 2015 @09:32AM
(#9531582)
TIL; thanks :)
[1]: http://www.phpcompiler.org/articles/virtualinheritance.html
Edit: I don't mean to bash C++ here, BTW; the skinny-pointer approach has a lot of benefits when all you need is single inheritance (and there are early-stage proposals to add it to Rust too). But I don't think it works well for multiple inheritance.