logo
  • Search
  • Reddit Posts 🔥
  • Archive
  • GitHub

TIL you can destructure a struct in a let statement!

86 points Centri__ 2023-02-10 21:50:02
View on Reddit ↗

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9557412e85a7ef0821655a8d56af69c3

I tried to figure out whether you could do this quite some time ago, but couldn't find the syntax for it. Well, I checked the Rust by Example book today and it was right there in 3.1 (Structures)!

© 2025 Query.rs, built by Folyd with ❤️❤️, see about page to learn more · meiguo.app · aiberm.com