Urgent.News

What's breaking now, across thousands of outlets.

Tech

Does Rust Support Inheritance? Yes, No, and Maybe, All in the Same File

Does Rust Support Inheritance? Yes, No, and Maybe, All in the Same File C started with plain structs: bags of fields without attached behavior. C++ added methods and class inheritance on top, letting a Derived class reuse Base fields and virtual methods while overriding only what differed. For many developers, that transition from struct to class hierarchy defines what object orientation looks…

Rust supports inheritance in a unique way that combines aspects of both yes and no, with a hint of maybe. Inheritance in Java allows classes to inherit fields and methods automatically through the extends keyword, with selective overrides possible. However, Rust does not support this type of inheritance. Instead, Rust uses traits with default methods, which resemble default methods in Java interfaces.

These traits can provide default implementations that implementors can keep or override. Additionally, Rust uses composition by embedding one struct inside another to share implementation across multiple distinct types. This means that while Rust does not have a direct equivalent of class inheritance, it still provides mechanisms for code reuse and sharing implementation across different types.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Cross-Chain Bridge Risk Assessment: Robinhood

Cross-Chain Bridge Risk Assessment: Robinhood Target Protocol : Robinhood (TVL: $14270.6M) Cross‑Chain Bridge Risk Assessment – Robinhood TVL: ≈ $14.27 B (Ethereum + L2) Date: 13 Sept 2026 Prepared…

The Matrix of HFT: Unpacking the Hype

The Quest Begins (The "Why") Here's the thing: I used to think high‑frequency trading (HFT) was some sort of wizardry—people in dark rooms flashing green numbers, making millions in the blink of an…

More from Sunday 13 September →