mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
parent
8eeb01e935
commit
3eaad948a7
1 changed files with 17 additions and 0 deletions
|
@ -4,6 +4,7 @@ use bevy_reflect::ReflectDeserialize;
|
|||
use bevy_reflect::ReflectSerialize;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::ops::Neg;
|
||||
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
||||
use thiserror::Error;
|
||||
|
||||
|
@ -154,6 +155,22 @@ impl DivAssign<f32> for Val {
|
|||
}
|
||||
}
|
||||
|
||||
impl Neg for Val {
|
||||
type Output = Val;
|
||||
|
||||
fn neg(self) -> Self::Output {
|
||||
match self {
|
||||
Val::Px(value) => Val::Px(-value),
|
||||
Val::Percent(value) => Val::Percent(-value),
|
||||
Val::Vw(value) => Val::Vw(-value),
|
||||
Val::Vh(value) => Val::Vh(-value),
|
||||
Val::VMin(value) => Val::VMin(-value),
|
||||
Val::VMax(value) => Val::VMax(-value),
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Error)]
|
||||
pub enum ValArithmeticError {
|
||||
#[error("the variants of the Vals don't match")]
|
||||
|
|
Loading…
Reference in a new issue