Yeah, that is a cool feature.  They're called newtype structs, after
newtypes in Haskell, discussed in the tutorial at
http://static.rust-lang.org/doc/tutorial.html#tuple-structs

btw, updated that gist w/ a hacky impl of Clone that uses copy, which I
think I've heard is going away in the near future.  Works for me for now,
though.


On Sat, Jul 6, 2013 at 11:31 AM, Ashish Myles <[email protected]> wrote:

> On Sat, Jul 6, 2013 at 5:45 AM, Jason Fager <[email protected]> wrote:
> > I've started implementing traits for fixed-length vectors with a few
> macros:
> >
> > https://gist.github.com/jfager/5936197
> >
> > I don't have Clone yet, but it should be easy to add.
> >
>
> As a side note, looking through your code, this is cool:
> ----
> struct Foo([u8,..2]);
> ....
> Foo([1u8,2u8])
> ----
> I had no idea one could define single-item/wrapper structs that way;
> i.e. like an anonymous member. This is going in my cool tidbits
> collection.
>
> Ashish
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to