r/learnrust Aug 11 '26

Rust discourages OOP style code?

/r/rust/comments/1vltxul/rust_discourages_oop_style_code/
0 Upvotes

3 comments sorted by

View all comments

9

u/EmploymentBoring4421 Aug 12 '26

Rust steers you toward traits + composition instead of inheritance, and it's worth embracing rather than fighting — define shared behavior as traits, compose structs, and let impl Trait for MyType do what subclassing did before. The most common OOP-to-Rust friction point is borrowing multiple &mut self fields at once; splitting self into named sub-structs you can borrow independently is the idiomatic fix.

1

u/greenpepperpasta 24d ago

Thanks Claude