wip: refactor(tui): 44 errors
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
same mf who else 2026-02-15 07:07:08 +02:00
parent b7b1055fbc
commit 4fa5d74fa2
26 changed files with 1550 additions and 1548 deletions

View file

@ -41,6 +41,32 @@ pub trait Out: Send + Sync + Sized {
}
}
/// A numeric type that can be used as coordinate.
///
/// FIXME: Replace this ad-hoc trait with `num` crate.
pub trait Coord: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
+ Mul<Self, Output=Self>
+ Div<Self, Output=Self>
+ Ord + PartialEq + Eq
+ Debug + Display + Default
+ From<u16> + Into<u16>
+ Into<usize>
+ Into<f64>
{
fn plus (self, other: Self) -> Self;
fn minus (self, other: Self) -> Self {
if self >= other { self - other } else { 0.into() }
}
fn atomic (self) -> AtomicUsize {
AtomicUsize::new(self.into())
}
fn zero () -> Self {
0.into()
}
}
/// Drawable with dynamic dispatch.
pub trait Draw<O: Out> {
fn draw (&self, to: &mut O);
@ -93,32 +119,6 @@ pub trait HasContent<O: Out> {
// TODO DOCUMENTME
pub trait Content<O: Out>: Draw<O> + Layout<O> {}
/// A numeric type that can be used as coordinate.
///
/// FIXME: Replace this ad-hoc trait with `num` crate.
pub trait Coord: Send + Sync + Copy
+ Add<Self, Output=Self>
+ Sub<Self, Output=Self>
+ Mul<Self, Output=Self>
+ Div<Self, Output=Self>
+ Ord + PartialEq + Eq
+ Debug + Display + Default
+ From<u16> + Into<u16>
+ Into<usize>
+ Into<f64>
{
fn plus (self, other: Self) -> Self;
fn minus (self, other: Self) -> Self {
if self >= other { self - other } else { 0.into() }
}
fn atomic (self) -> AtomicUsize {
AtomicUsize::new(self.into())
}
fn zero () -> Self {
0.into()
}
}
// Something that has an origin point (X, Y).
pub trait HasXY<N: Coord> {
fn x (&self) -> N;