mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
layout: remove more superfluous PhantomData usage
This commit is contained in:
parent
2b07e7963e
commit
f81a04dd44
3 changed files with 21 additions and 22 deletions
|
|
@ -4,29 +4,29 @@ use crate::*;
|
|||
/// along either the X axis, the Y axis, or both.
|
||||
macro_rules! transform_xy_unit {
|
||||
(|$self:ident : $Enum:ident, $to:ident|$layout:expr) => {
|
||||
pub enum $Enum<E: Engine, T: Content<E>> {
|
||||
X(E::Unit, T), Y(E::Unit, T), XY(E::Unit, E::Unit, T),
|
||||
pub enum $Enum<U, T> { X(U, T), Y(U, T), XY(U, U, T), }
|
||||
impl<U, T> $Enum<U, T> {
|
||||
pub fn x (x: U, item: T) -> Self { Self::X(x, item) }
|
||||
pub fn y (y: U, item: T) -> Self { Self::Y(y, item) }
|
||||
pub fn xy (x: U, y: U, item: T) -> Self { Self::XY(x, y, item) }
|
||||
}
|
||||
impl<E: Engine, T: Content<E>> $Enum<E, T> {
|
||||
pub fn x (x: E::Unit, item: T) -> Self { Self::X(x, item) }
|
||||
pub fn y (y: E::Unit, item: T) -> Self { Self::Y(y, item) }
|
||||
pub fn xy (x: E::Unit, y: E::Unit, item: T) -> Self { Self::XY(x, y, item) }
|
||||
pub fn dx (&self) -> E::Unit {
|
||||
impl<U: Copy + Coordinate, T> $Enum<U, T> {
|
||||
pub fn dx (&self) -> U {
|
||||
match self {
|
||||
Self::X(x, _) => *x,
|
||||
Self::Y(_, _) => E::Unit::zero(),
|
||||
Self::Y(_, _) => 0.into(),
|
||||
Self::XY(x, _, _) => *x,
|
||||
}
|
||||
}
|
||||
pub fn dy (&self) -> E::Unit {
|
||||
pub fn dy (&self) -> U {
|
||||
match self {
|
||||
Self::X(_, _) => E::Unit::zero(),
|
||||
Self::Y(y, _) => *y,
|
||||
Self::X(_, _) => 0.into(),
|
||||
Self::Y(y, _) => *y,
|
||||
Self::XY(_, y, _) => *y,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<E: Engine, T: Content<E>> Content<E> for $Enum<E, T> {
|
||||
impl<E: Engine, T: Content<E>> Content<E> for $Enum<E::Unit, T> {
|
||||
fn content (&self) -> impl Content<E> {
|
||||
Some(match self {
|
||||
Self::X(_, content) => content,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue