add Area::iter_x and iter_y

This commit is contained in:
🪞👃🪞 2025-03-02 14:17:13 +02:00
parent 3837dbd47b
commit 8465d64807
3 changed files with 9 additions and 1 deletions
cli
output/src

View file

@ -2,7 +2,7 @@ pub use tek::*;
pub(crate) use clap::{self, Parser, Subcommand};
/// Application entrypoint.
pub fn main () -> Usually<()> {
TekCli::parse().run()
TekCli::parse().run()
}
#[test] fn verify_cli () {
use clap::CommandFactory;

View file

@ -76,6 +76,13 @@ pub trait Area<N: Coordinate>: From<[N;4]> + Debug + Copy {
#[inline] fn centered (&self) -> [N;2] {
[self.x().minus(self.w()/2.into()), self.y().minus(self.h()/2.into())]
}
fn iter_x (&self) -> impl Iterator<Item = N> where N: std::iter::Step {
self.x()..(self.x()+self.w())
}
fn iter_y (&self) -> impl Iterator<Item = N> where N: std::iter::Step {
self.y()..(self.y()+self.h())
}
}
impl<N: Coordinate> Area<N> for (N, N, N, N) {

View file

@ -1,4 +1,5 @@
//#![feature(lazy_type_alias)]
#![feature(step_trait)]
#![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_assoc_type)]
mod direction; pub use self::direction::*;