Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake most constructors const fns #368
Conversation
|
const for all! |
|
Somewhat relevant - rust-gamedev/wg#28 |
|
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. |
|
@bors-servo r=kvark |
|
|
Make most constructors const fns 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. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/368) <!-- Reviewable:end -->
|
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. |
|
|
nical commentedAug 16, 2019
•
edited by larsbergstrom
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
implblock 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 anAngle<T>instead of aTdirectly 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