> Ah, thank you for the clarification. I was not aware that such an > operation could occur. (There are no examples of anything like it > in the Tutorial or Reference Manual.)
Be sure that you're looking at the up-to-date docs: http://dl.rust-lang.org/doc/tutorial.html#structs "Rust struct types must be declared before they are used using the structsyntax: struct Name { field1: T1, field2: T2 [, ...] }, where T1, T2, ... denote types. To construct a struct, use the same syntax, but leave off the struct; for example: Point { x: 1.0, y: 2.0 }." Note that these are *not* the docs linked from the rust-lang.org homepage. FWIW, I really love Rust's closure syntax. And since no two languages can agree on closure syntax, there's really no single "right" way to do it. On Tue, Sep 11, 2012 at 11:36 AM, James Boyden <[email protected]> wrote: > On Wed, Sep 12, 2012 at 1:10 AM, Marijn Haverbeke <[email protected]> > wrote: > >> Are you saying that struct destructuring also occurs outside of > >> match constructs, as a stand-alone assignment statement? > > > > Yes, he is, and that fact is one of the major constraints on what > > patterns may look like. The same pattern syntax is used in regular > > assignment and alt matching. > > Ah, thank you for the clarification. I was not aware that such an > operation could occur. (There are no examples of anything like it > in the Tutorial or Reference Manual.) > > I wouldn't be particularly keen on a 'let'-laden syntax like: > let Foo { x: let x, y: let y } = ...; > > The obvious alternative is a version without an initial 'let': > Foo { x: let x, y: let y } = ...; > > But would this be parseable? > > And even if it _were_ parseable, it's still closer to the "subtle" end > of the statement spectrum than I'd like -- you don't really know what > you're looking at until you reach the 4th whitespace-delimited token. > > I'll have to think about this further. > > Thanks, > jb > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
