becheran/grid

Support zero-sized grids

nicoburns opened this issue · 1 comments

A great feature of Vec is that you can create a zero-length Vec with Vec::new(), and this does not allocate. This is great if you if you want to initialise a struct containing a Vec, but you don't yet know what the dimensions of the Vec should be. You can initialise the struct with the placeholder for very low cost.

It would be great if grid supported the same. I think it could make sense to only support both dimensions being zero, or both being non-zero. One being zero while the other is non-zero doesn't make much sense.

Good idea. Definitely a better option than panicking as I have it right now when one tries to init an empty grid.