I don't think there is another way. Do note however that Display and Debug impls are not required to format text with the same length every time, so if you are using this to preallocate a buffer, be sure to keep bound checks. In practice almost all Display and Debug impls will always use the same length. The Debug impls for atomics are likely to return different sizes though as the inner value may be changed in between both format calls.