Make size_of available at compile time

#1

As @chris kindly pointed out on StackOverflow, std::mem::size_of() cannot currently be used as a constant expression. size_of::<T>() appears to be evaluated at runtime, which artificially limits the construct in my opinion.

I went searching for historical background and only managed to dig up a mailing list thread from 2012, which punts the issue as a nice to have.

I’m unsure how to proceed at this point. Would an RFC be the logical next step? Does compile time sizeof jive with Rust philosophy?

0 Likes

#2

This has been proposed as an RFC before, but has been postponed (i.e. to be discussed/implemented after 1.0)

0 Likes

#3

Thanks for the link. I figured it wouldn’t block 1.0 but it’s good to see that compile time sizeof is on the radar.

0 Likes

closed #4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

0 Likes