Build on current nightly
This commit is contained in:
1 parent
7b54aaf3c4
commit
fae21a1991
10 files changed
+26
-24
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
use crate::{UiRsc, WidgetIdFn, WidgetLike, WeakWidget};
|
use crate::{UiRsc, WeakWidget, WidgetIdFn, WidgetLike};
|
||||||
|
|
||||||
pub trait WidgetAttr<Rsc, W: ?Sized> {
|
pub trait WidgetAttr<Rsc, W: ?Sized> {
|
||||||
type Input;
|
type Input;
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
#![feature(const_ops)]
|
#![feature(const_ops)]
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
#![feature(const_convert)]
|
#![feature(const_convert)]
|
||||||
#![feature(map_try_insert)]
|
|
||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(const_cmp)]
|
|
||||||
#![feature(const_destruct)]
|
#![feature(const_destruct)]
|
||||||
#![feature(portable_simd)]
|
#![feature(portable_simd)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
|
|||||||
+5
-5
@@ -5,19 +5,19 @@ pub const trait UiNum {
|
|||||||
fn to_f32(self) -> f32;
|
fn to_f32(self) -> f32;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl const UiNum for f32 {
|
const impl UiNum for f32 {
|
||||||
fn to_f32(self) -> f32 {
|
fn to_f32(self) -> f32 {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl const UiNum for u32 {
|
const impl UiNum for u32 {
|
||||||
fn to_f32(self) -> f32 {
|
fn to_f32(self) -> f32 {
|
||||||
self as f32
|
self as f32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl const UiNum for i32 {
|
const impl UiNum for i32 {
|
||||||
fn to_f32(self) -> f32 {
|
fn to_f32(self) -> f32 {
|
||||||
self as f32
|
self as f32
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ pub const fn vec2(x: impl const UiNum, y: impl const UiNum) -> Vec2 {
|
|||||||
Vec2::new(x.to_f32(), y.to_f32())
|
Vec2::new(x.to_f32(), y.to_f32())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: const UiNum + Copy> const From<T> for Vec2 {
|
const impl<T: const UiNum + Copy> From<T> for Vec2 {
|
||||||
fn from(v: T) -> Self {
|
fn from(v: T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
x: v.to_f32(),
|
x: v.to_f32(),
|
||||||
@@ -36,7 +36,7 @@ impl<T: const UiNum + Copy> const From<T> for Vec2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: const UiNum, U: const UiNum> const From<(T, U)> for Vec2
|
const impl<T: const UiNum, U: const UiNum> From<(T, U)> for Vec2
|
||||||
where
|
where
|
||||||
(T, U): const Destruct,
|
(T, U): const Destruct,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ impl From<CardinalAlign> for Align {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl const From<RegionAlign> for UiVec2 {
|
const impl From<RegionAlign> for UiVec2 {
|
||||||
fn from(align: RegionAlign) -> Self {
|
fn from(align: RegionAlign) -> Self {
|
||||||
Self::rel(align.rel())
|
Self::rel(align.rel())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,14 +74,14 @@ pub const trait AxisT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct XAxis;
|
pub struct XAxis;
|
||||||
impl const AxisT for XAxis {
|
const impl AxisT for XAxis {
|
||||||
fn get() -> Axis {
|
fn get() -> Axis {
|
||||||
Axis::X
|
Axis::X
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct YAxis;
|
pub struct YAxis;
|
||||||
impl const AxisT for YAxis {
|
const impl AxisT for YAxis {
|
||||||
fn get() -> Axis {
|
fn get() -> Axis {
|
||||||
Axis::Y
|
Axis::Y
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,13 +124,13 @@ impl Display for UiVec2 {
|
|||||||
impl_op!(UiVec2 Add add; x y);
|
impl_op!(UiVec2 Add add; x y);
|
||||||
impl_op!(UiVec2 Sub sub; x y);
|
impl_op!(UiVec2 Sub sub; x y);
|
||||||
|
|
||||||
impl const From<Vec2> for UiVec2 {
|
const impl From<Vec2> for UiVec2 {
|
||||||
fn from(abs: Vec2) -> Self {
|
fn from(abs: Vec2) -> Self {
|
||||||
Self::abs(abs)
|
Self::abs(abs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: const UiNum, U: const UiNum> const From<(T, U)> for UiVec2
|
const impl<T: const UiNum, U: const UiNum> From<(T, U)> for UiVec2
|
||||||
where
|
where
|
||||||
(T, U): const Destruct,
|
(T, U): const Destruct,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ impl ColorNum for f32 {
|
|||||||
|
|
||||||
unsafe impl bytemuck::Pod for Color<u8> {}
|
unsafe impl bytemuck::Pod for Color<u8> {}
|
||||||
|
|
||||||
impl const F32Conversion for f32 {
|
const impl F32Conversion for f32 {
|
||||||
fn to(self) -> f32 {
|
fn to(self) -> f32 {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ impl const F32Conversion for f32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl const F32Conversion for u8 {
|
const impl F32Conversion for u8 {
|
||||||
fn to(self) -> f32 {
|
fn to(self) -> f32 {
|
||||||
self as f32 / 255.0
|
self as f32 / 255.0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,16 @@ pub const trait DivOr {
|
|||||||
fn div_or(self, rhs: Self, other: Self) -> Self;
|
fn div_or(self, rhs: Self, other: Self) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl const DivOr for f32 {
|
const impl DivOr for f32 {
|
||||||
fn div_or(self, rhs: Self, other: Self) -> Self {
|
fn div_or(self, rhs: Self, other: Self) -> Self {
|
||||||
let res = self / rhs;
|
let res = self / rhs;
|
||||||
if res.is_nan() { other } else { res }
|
if res.is_nan() { other } else { res }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: const Add<Output = T> + const Sub<Output = T> + const Mul<Output = T> + const DivOr + Copy> const
|
const impl<
|
||||||
LerpUtil for T
|
T: const Add<Output = T> + const Sub<Output = T> + const Mul<Output = T> + const DivOr + Copy,
|
||||||
|
> LerpUtil for T
|
||||||
{
|
{
|
||||||
/// linear interpolation
|
/// linear interpolation
|
||||||
/// from * (1.0 - self) + to * self
|
/// from * (1.0 - self) + to * self
|
||||||
@@ -37,7 +38,7 @@ macro_rules! impl_op {
|
|||||||
use super::*;
|
use super::*;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::ops::*;
|
use std::ops::*;
|
||||||
impl const $op for $T {
|
const impl $op for $T {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn $fn(self, rhs: Self) -> Self::Output {
|
fn $fn(self, rhs: Self) -> Self::Output {
|
||||||
@@ -46,12 +47,12 @@ macro_rules! impl_op {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl const $opa for $T {
|
const impl $opa for $T {
|
||||||
fn $fna(&mut self, rhs: Self) {
|
fn $fna(&mut self, rhs: Self) {
|
||||||
*self = self.$fn(rhs);
|
*self = self.$fn(rhs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl const $op<f32> for $T {
|
const impl $op<f32> for $T {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn $fn(self, rhs: f32) -> Self::Output {
|
fn $fn(self, rhs: f32) -> Self::Output {
|
||||||
@@ -60,7 +61,7 @@ macro_rules! impl_op {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl const $op<$T> for f32 {
|
const impl $op<$T> for f32 {
|
||||||
type Output = $T;
|
type Output = $T;
|
||||||
|
|
||||||
fn $fn(self, rhs: $T) -> Self::Output {
|
fn $fn(self, rhs: $T) -> Self::Output {
|
||||||
@@ -69,7 +70,7 @@ macro_rules! impl_op {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl const $opa<f32> for $T {
|
const impl $opa<f32> for $T {
|
||||||
fn $fna(&mut self, rhs: f32) {
|
fn $fna(&mut self, rhs: f32) {
|
||||||
*self = self.$fn(rhs);
|
*self = self.$fn(rhs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ impl_op!(Vec2 Sub sub; x y);
|
|||||||
impl_op!(Vec2 Mul mul; x y);
|
impl_op!(Vec2 Mul mul; x y);
|
||||||
impl_op!(Vec2 Div div; x y);
|
impl_op!(Vec2 Div div; x y);
|
||||||
|
|
||||||
impl const DivOr for Vec2 {
|
const impl DivOr for Vec2 {
|
||||||
fn div_or(self, rhs: Self, other: Self) -> Self {
|
fn div_or(self, rhs: Self, other: Self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
x: self.x.div_or(rhs.x, other.x),
|
x: self.x.div_or(rhs.x, other.x),
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
components = ["clippy", "rustfmt"]
|
||||||
Reference in new issue
Block a user