remove the step by feature

should have test to make sure it does what I want it to do
This commit is contained in:
Corwin Kuiper 2022-01-04 00:10:51 +00:00
parent 253897443d
commit 6d829bd741
2 changed files with 15 additions and 9 deletions

View file

@ -7,7 +7,6 @@
#![feature(alloc_error_handler)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
#![feature(step_trait)]
//! # agb
//! `agb` is a library for making games on the Game Boy Advance using the Rust
//! programming language. It attempts to be a high level abstraction over the

View file

@ -862,15 +862,22 @@ impl<T: Number> Rect<T> {
}
}
impl<T: FixedWidthUnsignedInteger + core::iter::Step> Rect<T> {
impl<T: FixedWidthUnsignedInteger> Rect<T> {
pub fn iter(self) -> impl Iterator<Item = (T, T)> {
(self.position.x..=(self.position.x + self.size.x))
.into_iter()
.flat_map(move |x| {
(self.position.y..=(self.position.y + self.size.y))
.into_iter()
.map(move |y| (x, y))
})
let mut x = self.position.x - T::one();
let mut y = self.position.y;
core::iter::from_fn(move || {
x = x + T::one();
if x > self.position.x + self.size.x {
x = self.position.x;
y = y + T::one();
if y > self.position.y + self.size.y {
return None;
}
}
Some((x, y))
})
}
}