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

View file

@ -862,14 +862,21 @@ 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)> { pub fn iter(self) -> impl Iterator<Item = (T, T)> {
(self.position.x..=(self.position.x + self.size.x)) let mut x = self.position.x - T::one();
.into_iter() let mut y = self.position.y;
.flat_map(move |x| { core::iter::from_fn(move || {
(self.position.y..=(self.position.y + self.size.y)) x = x + T::one();
.into_iter() if x > self.position.x + self.size.x {
.map(move |y| (x, y)) x = self.position.x;
y = y + T::one();
if y > self.position.y + self.size.y {
return None;
}
}
Some((x, y))
}) })
} }
} }