servo / euclid

Geometry primitives (basic linear algebra) for Rust
Other
463 stars 102 forks source link

Make most constructors const fns #368

Closed nical closed 5 years ago

nical commented 5 years ago

This will make declaring constant points, sizes, etc. quite a bit nicer.

Currently const fns only accept one trait bound (Sized), so some constructors that required Copy and other traits were moved to their own impl block to require no trait bounds. Also Rotation2D::new(Angle<T>) could not be made const because const fns can't destroy values (even if Angle does not implement Drop). This could work if the rotation stored an Angle<T> instead of a T directly which also makes sense regardless of the appeal of const fn. It wasn't worth the breaking change but it could be something we sneak in the next breaking changes when we address the matrix conventions for example.


This change is Reviewable

kvark commented 5 years ago

Somewhat relevant - https://github.com/rust-gamedev/wg/issues/28

nical commented 5 years ago

That gamedev wg thread has a point. I'm hoping that bumping to 1.31 is unlikely to break euclid users because hopefully the 2018 edition was compelling enough to have moved most of the rust ecosystem to at least that version, but I am ok with waiting for the next breaking change to land this if you want, and also ok with making it a policy to treat compiler bumps as breaking changes going forward.

nical commented 5 years ago

@bors-servo r=kvark

bors-servo commented 5 years ago

:pushpin: Commit face16d has been approved by kvark

bors-servo commented 5 years ago

:hourglass: Testing commit face16d88651f461194df745ae487525137f0dd9 with merge 076ac1aef894e1d108ef503ed28132de6a2da1a1...

nical commented 5 years ago

Looks like proc_macro dropped support for rustc older than 1.31, without making it a breaking change, which means euclid doesn't compile on these rustcs of older vintage anymore, so lets land this now.

bors-servo commented 5 years ago

:sunny: Test successful - checks-travis Approved by: kvark Pushing 076ac1aef894e1d108ef503ed28132de6a2da1a1 to master...