Skip to content

SizeVec? #232

Closed
Closed

Description

@sarkahn

I was wondering if there's any chance we could get a "SizeVec" or "USizeVec" (Vec whose elements are usize). I use (usize,usize) a lot to represent 2D size, I find myself wanting to replace them with UVec2 to make the math easier to read, but then I have to convert to usize to interact with array indices and such.

Activity

  1. bitshifter commented on Sep 11, 2021

    @bitshifter
    Owner

    Hey there. I am a bit reluctant to add this one. Since glam is not a generic library there's a bit more overhead to adding and maintaining new types. I will sit on this and see if there is further demand for it though.

    If there is anything you can think of that would make it easier to work with usize with existing types let me know.

  2. sarkahn commented on Sep 11, 2021

    @sarkahn
    Author

    That makes sense, thanks for the consideration! I think even implementing From<(usize,usize)> and vice verse for UVec2 and UVec3 would make things a lot smoother for how I'm using them, if that would be possible.

  3. bitshifter commented on Oct 26, 2021

    @bitshifter
    Owner

    I wouldn't add an impl From like this on the basis that Rust itself doesn't support impl From<usize> for u32 or any other conversion between types that loses information. I could look at adding explicit methods, such as from_tuple_usize or something. You could easily add something similar in your own project as an extension method for UVec* .

  4. Repository owner locked and limited conversation to collaborators on Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions