Skip to content

Make Point a new type rather than an alias? #620

@mitchmindtree

Description

@mitchmindtree

This would be heavily breaking, and may not be worth it, however I think there's a chance it could offer a lot of benefits, especially now that the conversion traits exist (they never used to when conrod first existed).

pub struct Point {
    pub xy: [Scalar; 2],
}

Pros

  • It could easily convert between [Scalar; 2] and (Scalar, Scalar) by impling From<[Scalar; 2]>, From<(Scalar, Scalar)>, Into<[Scalar; 2]>, Into<(Scalar, Scalar)>
  • We could implement the ops traits for it (we currently have to use vec2_add(a, b) which is ok though a little unwieldy at times as it requires an import and the vecmath crate.
  • Stronger type safety. If we were to do the same for Dimensions, it would be much harder to accidentally pass arguments the wrong way around (which I have done a couple times heh).
  • We can add any convenience methods as we think of them.

Cons

  • It would be a heavily breaking change.
  • Would require quite a bit of work, though it would generally be very easy work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions