Skip to content

Commit

Permalink
Rename trait template variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird committed Nov 10, 2024
1 parent 1068752 commit 72a760f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions codegen/templates/swizzle_traits.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
{% set components = ["x", "y", "z", "w"] %}
{% set dimensions = [2, 3, 4] %}
{% for dim in dimensions %}
{% set ret2 = "Self::Vec2" %}
{% set ret3 = "Self::Vec3" %}
{% set ret4 = "Self::Vec4" %}
{% set vec2_t = "Self::Vec2" %}
{% set vec3_t = "Self::Vec3" %}
{% set vec4_t = "Self::Vec4" %}

{% if dim == 4 %}
{% set ret4 = "Self" %}
{% set vec4_t = "Self" %}
{% elif dim == 3 %}
{% set ret3 = "Self" %}
{% set vec3_t = "Self" %}
{% elif dim == 2 %}
{% set ret2 = "Self" %}
{% set vec2_t = "Self" %}
{% endif %}

pub trait Vec{{ dim }}Swizzles: Sized + Copy + Clone {
Expand Down Expand Up @@ -52,28 +52,28 @@
{% if i == 2 %}
{% set skip = dim == 2 and e0 == "x" and e1 == "y" %}
{% if not skip %}
fn {{e0}}{{e1}}(self) -> {{ret2}};
fn {{e0}}{{e1}}(self) -> {{ vec2_t }};
{% endif %}
{% set skip = dim == 2 or e0 == e1 %}
{% if not skip %}
fn with_{{e0}}{{e1}}(self, rhs: {{ret2}}) -> Self;
fn with_{{e0}}{{e1}}(self, rhs: {{ vec2_t }}) -> Self;
{% endif %}
{% else %}
{% for e2 in components | slice(end=dim) %}
{% if i == 3 %}
{% set skip = dim == 3 and e0 == "x" and e1 == "y" and e2 == "z" %}
{% if not skip %}
fn {{e0}}{{e1}}{{e2}}(self) -> {{ret3}};
fn {{e0}}{{e1}}{{e2}}(self) -> {{ vec3_t }};
{% endif %}
{% set skip = dim == 3 or e0 == e1 or e0 == e2 or e1 == e2 %}
{% if not skip %}
fn with_{{e0}}{{e1}}{{e2}}(self, rhs: {{ret3}}) -> Self;
fn with_{{e0}}{{e1}}{{e2}}(self, rhs: {{ vec3_t }}) -> Self;
{% endif %}
{% else %}
{% for e3 in components | slice(end=dim) %}
{% set skip = dim == 4 and e0 == "x" and e1 == "y" and e2 == "z" and e3 == "w" %}
{% if not skip %}
fn {{e0}}{{e1}}{{e2}}{{e3}}(self) -> {{ret4}};
fn {{e0}}{{e1}}{{e2}}{{e3}}(self) -> {{ vec4_t }};
{% endif %}
{% endfor %}
{% endif %}
Expand Down

0 comments on commit 72a760f

Please sign in to comment.