Skip to content

Record inheritance #1776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Aluminium95 opened this issue Feb 7, 2012 · 2 comments
Closed

Record inheritance #1776

Aluminium95 opened this issue Feb 7, 2012 · 2 comments

Comments

@Aluminium95
Copy link

It would be great to be able to do some thing like this :
type A = { a: int }; type B = {b: int} herit A;

So in factB = {a: int, b: int};

It could maybe replace an object model when combined with interfaces.

@catamorphism
Copy link
Contributor

I think we're pretty firmly wedded to classes without inheritance at this point. Also, keeping our class design the way it is and adding records with inheritance sounds complex to me. Closing, reopen if anybody strongly opposes that.

@dobkeratops
Copy link

struct inheritance, single inheritance...
coming from C++, I've found myself missing simple single inheritance in rust.. the straightforward ability to have multiple structs with the same data prefix, no extra complexity for multiple inheritance with virtual bases. (i wouldn't ask for multiple inheritance with extra indirection going on)

I got the impression some of the rust compiler sourcecode is slightly complicated by its absence, eg situtaions where nodes share the same fields. (spans).. see spanned, then a series of duplicate symbols with _ prefixes like variant_ =spanned etc .. maybe i'm overlooking something
IMO single inheritance is simple from a low level perspective, just different records sharing the same data at the same offsets.. used to do it in ASM.

Would it create complex interactions eg with generics, inference, impls, traits ?

flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 2, 2021
…, r=llogiq

Don't trigger large_enum_variant in external macros

Closes rust-lang#1776 (the potential JSON output issue is not something we can fix in Clippy and I can't reproduce it anymore)

changelog: Don't trigger [`large_enum_variant`] in external macros
Kobzol pushed a commit to Kobzol/rust that referenced this issue Dec 30, 2024
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants