bevy_ecs_tilemap icon indicating copy to clipboard operation
bevy_ecs_tilemap copied to clipboard

`From<u32>` impls for square size types?

Open johanhelsing opened this issue 1 year ago • 1 comments

Hi, I was thinking maybe it would be nice to have constructors for creating square versions of the various size types.

For instance, I'm currently doing:

let tilemap_size = 32;
let mut tile_storage = TileStorage::empty(UVec2::splat(tilemap_size).into());

But would perhaps be nice to implement From<u32> for TilemapSize:

let tilemap_size = 32;
let mut tile_storage = TileStorage::empty(tilemap_size.into());

Same goes for the other size types, TilemapTileSize etc.

If TileStorage::empty was generic over T: Into<TilemapSize>, this would allow simply:

let tilemap_size = 32;
let mut tilemap_storage = TileStorage::empty(tilemap_size);

But perhaps this is being too "smart" about it?

johanhelsing avatar Oct 30 '22 08:10 johanhelsing