I was in a situation where I'd like to modify multiple attributes in a struct at once. Knowing that Rust theoretically supports tuple destructuring I attempted the following:
let (hints.ai_family, hints.ai_socktype) = (AF_INET, SOCK_STREAM); where hints is the struct in question, yet that threw a syntax error. Removing the let keyword did not work. I know that this is not specified in the language, but coming from other languages where destructuring can be done for anything that's an lvalue, it seems as though it would be intuitive and practical to have struct member destructuring, or support just any kind of lvalue assignment; it seems highly declarative of intent, and frankly looks very readable and a nice way to structure assigment visually. I'm stretching the analogy a bit but it would make it slightly closer to a LISP let-block. -- Andrés Osinski http://www.andresosinski.com.ar/
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
