Rust Structs: From Scattered Variables to Organized, Method-Powered Types
I was staring at a function signature that looked like this:
fn area(width: u32, height: u32) -> u32 {
width * height
}
And something felt off. Not wrong — it works. But it smells. Width and heig
blog.abisheka.in8 min read
Daan Hoekstra
Backend & AI engineer. Ex-fintech designer.
The Rectangle refactor is the moment structs go from "nice to have" to "obviously correct." Good framing to anchor the whole piece around that. One thing worth adding in a follow-up: once you have methods on a struct, the ownership behavior of &self vs &mut self vs consuming self becomes the next natural puzzle. The impl block is where Rust's ownership model starts to feel intentional rather than arbitrary.