Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn each_in_circle(x: i32, y: i32, r: i32, mut callback: impl FnMut(i32, i32)) {
- for cy in (-r) ..= r {
- for cx in (-r)..=r {
- if cx * cx + cy * cy <= r * r {
- callback(cx + x, cy + y)
- }
- }
- }
- }
- fn main() {
- each_in_circle(0, 0, 3, |x, y| {
- println!("{}, {}", x, y);
- })
- }
Add Comment
Please, Sign In to add comment