`RTSecret<T, std::cell::Cell<u8>>` is the same size as `RTSecret<T, std::cell::Cell<u16>>`, why? And how to optimize such that former is smaller than latter?

Yes, it does— A type T's size is always a multiple of its alignment, so that they can be placed in a slice with a stride of size_of::<T>(). Otherwise, the second element of the slice would be improperly aligned. That's what @CAD97 was referring to in their reply to your initial post:

2 Likes