Why does rust use struct keyword?

It depends how unique. Niko had a good post about this recently.

Note that if you try to use struct (and enum) in Rust like you would in C, it works pretty much the same. They may have additional things they can do, and there are always slight nuances (like opt-in Copy), but they're used in roughly the same ways for roughly the same things, so the intuitions are valuable.

Compare trait, which could have been named interface, but wasn't. One could argue either way, but I think overall that was the right choice, since even though they have similar goals if you squint hard enough, trying to take a Java-style design with interfaces and translate it directly into Rust has a whole bunch of gotchas.

3 Likes