mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-05-02 06:40:14 +02:00
add Area::iter_x and iter_y
This commit is contained in:
parent
3837dbd47b
commit
8465d64807
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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::*;
|
||||
|
|
Loading…
Reference in a new issue