Skip to content

Determine trait inheritance hierarchies for core and std traits #3950

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
bstrie opened this issue Nov 12, 2012 · 6 comments
Closed

Determine trait inheritance hierarchies for core and std traits #3950

bstrie opened this issue Nov 12, 2012 · 6 comments

Comments

@bstrie
Copy link
Contributor

bstrie commented Nov 12, 2012

Lines like fn map_reduce<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send> can probably be compressed a bit with the aid of trait inheritance. Figure out the places where trait inheritance would be useful and determine the appropriate hierarchies.

@brendanzab
Copy link
Member

It's been raised a number of times on IRC, but it'd be really handy if we had:

pub trait Num: Ord, Eq, Add<self, self>, Sub<self, self>, Mul<self, self>, Div<self, self>, Modulo<self, self>, Neg<self> {
    pure fn to_int() -> int;
    static pure fn from_int(n: int) -> self;
}

@bstrie
Copy link
Contributor Author

bstrie commented Nov 12, 2012

Regarding the Num trait, would it also implement Copy? And would Ord inherit from Eq?

@brendanzab
Copy link
Member

I believe that pcwalton has to implement 'kind inheritance' before we can inherit Copy - 'kind' referring to Rust's magic in-built traits like Const, Copy, Send and Owned (I think).

Float, Integer, Signed and Unsigned traits might also be useful:

trait Float: Num, FuzzyEq {}

trait Integer: Num {}

trait Signed: Num, Neg<self> {}

trait Unsigned: Num {}

@catamorphism
Copy link
Contributor

Blocked on #3984

@alexcrichton
Copy link
Member

I don't think that we're in as bad as a situation as we were when this was opened, but this is also kind of a vague issue.

@bstrie, do you know of any existing specific locations which could use improvement. I think that @bjz has been tracking all the numeric-related things in another issue, so I'm tempted to close this due to lack of actionable work unless there are things left to take care of.

@bstrie
Copy link
Contributor Author

bstrie commented Jul 26, 2013

This was mostly a call-to-action for getting people thinking about our trait hierarchies (and numeric traits in particular), and I'd say it's served its purpose. Closing. Feel free to file more specific issues as they arise.

@bstrie bstrie closed this as completed Jul 26, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 15, 2024
…em, r=RalfJung,saethlin,oli-obk

remove -Zmiri-panic-on-unsupported flag

Fixes rust-lang/miri#3952, see that issue for discussion.
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

4 participants