On Fri, Jun 7, 2013 at 12:21 AM, Tim Chevalier <catamorph...@gmail.com> wrote:
> Hi all,
>
> I'm currently working on slides for a Rust tutorial, that I'm going to
> be presenting at Open Source Bridge in Portland in two weeks. I wanted
> the tutorial to be driven by examples from real code, but I've had a
> hard time finding examples that are both relevant, and self-contained
> enough to use in a talk. I specified that I expect the audience to
> know how to program in some language and to be at least a little bit
> familiar with C, so I'm assuming relatively little about their
> knowledge. I'm certainly not assuming that they have already looked at
> Rust.
>
> I'd like to have an extended example to illustrate borrowed pointers,
> and another (can be separate or related) to illustrate traits. I've
> done a fair amount of looking through Servo; Patrick's sprocketnes and
> fempeg projects; and the Rust standard libraries. The first three seem
> to make relatively little use of traits (and many of the traits that
> are there seem to be collections of methods rather than representing
> concepts that could be described more abstractly). Of course, borrowed
> pointers are everywhere, but it's hard for me to say what is a good,
> self-contained example for them. In the current draft of my talk, I'm
> using the Container and Map traits and the HashMap implementation from
> the standard library to illustrate both traits and borrowed pointers.
> I'm okay with keeping it that way, but I'd love to use a less
> textbook-y example that shows off what Rust can do. I had hoped some
> of the test cases under bench/ might be good for this, but many of
> them are written in fairly old-style Rust.
>
> Thanks in advance, and I'll certainly acknowledge in the talk anybody
> who points me to a good example.
>
> Cheers,
> Tim

The Map trait is a bit ugly because it's sorely in need of default
methods to reduce the burden on implementations.

I think the Iterator trait in the `std::iterator` module is a great
example, because it's a simple trait and it's easy to demonstrate
implementations and adaptors for it. It's also a nice way of showing
off the lifetime system because with owned containers you can't
invalidate the iterators. I don't think there are many other languages
able to represent something like statically freezable mutable
containers.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to