mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
add Area::iter_x and iter_y
This commit is contained in:
parent
3837dbd47b
commit
8465d64807
3 changed files with 9 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ pub use tek::*;
|
||||||
pub(crate) use clap::{self, Parser, Subcommand};
|
pub(crate) use clap::{self, Parser, Subcommand};
|
||||||
/// Application entrypoint.
|
/// Application entrypoint.
|
||||||
pub fn main () -> Usually<()> {
|
pub fn main () -> Usually<()> {
|
||||||
TekCli::parse().run()
|
TekCli::parse().run()
|
||||||
}
|
}
|
||||||
#[test] fn verify_cli () {
|
#[test] fn verify_cli () {
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,13 @@ pub trait Area<N: Coordinate>: From<[N;4]> + Debug + Copy {
|
||||||
#[inline] fn centered (&self) -> [N;2] {
|
#[inline] fn centered (&self) -> [N;2] {
|
||||||
[self.x().minus(self.w()/2.into()), self.y().minus(self.h()/2.into())]
|
[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) {
|
impl<N: Coordinate> Area<N> for (N, N, N, N) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//#![feature(lazy_type_alias)]
|
//#![feature(lazy_type_alias)]
|
||||||
|
#![feature(step_trait)]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
#![feature(impl_trait_in_assoc_type)]
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
mod direction; pub use self::direction::*;
|
mod direction; pub use self::direction::*;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue