LPGhatguy / thunderdome

Arena type inspired by generational-arena
Apache License 2.0
197 stars 15 forks source link

mark functions as constant #38

Closed sanbox-irl closed 1 year ago

sanbox-irl commented 1 year ago

This PR does three things:

  1. Makes Arena::new const
  2. Updates our MSRV to 1.39 (which is required for Vec::new() to be const)
  3. Marks all the low-hanging API fruit as const which require no or highly minimal changes.

I care about 1 (which requires 2), but I don't care much for 3 at all -- some of these changes required refactoring map into a match, which is less readable (though not terribly), so those changes I do not feel strongly about.

To defend 1 however, I think making Arena::new allows it to be constructed in static contexts (notably in a parking_lot::RwLock, which has a const new) with ease. Technically this could cause breakage later on if a new constructor is devised which cannot be made const, but I highly doubt Arena will ever not be able to be const.

LPGhatguy commented 1 year ago

Looks like const NonZeroU32::new requires Rust 1.47.0. We can bump to that as a new MSRV and rerun the build.

tyler274 commented 1 year ago

Is there anything blocking this?

sanbox-irl commented 1 year ago

yup, the above comments. i just haven't had the time to do the minor fix! been traveling.

LPGhatguy commented 1 year ago

Released as part of 0.6.0!