Idea: guestimate of size of datatype

I’m not sure why the concern is potential confusion rather than the opportunity being potential education. If you can have a note that says “the size of this object on x86_64 is X bytes, click here to learn more” (or whatever the bikeshed results in), then you can have an entire page devoted to educating new Rust users on the difference between direct and indirect memory usage of objects. That seems like a win to me.

1 Like

It’s not useful if you want to figure out how much RAM you’re going to use. But it is useful for a specific purpose: figuring out whether it’s okay for your hot paths to use that type directly in function arguments or return values, or whether you should use some sort of pointer instead. That includes Box, but also simple things like having arguments of type &Foo instead of Foo, or having an ‘out pointer’ argument of type &mut Foo instead of returning Foo. Or perhaps fancier tricks using unsafe code… (and maybe someday we’ll have something like &move pointers built into the language…)

1 Like

Adding to clippy would achieve the goal i think.

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