Guest User

Untitled

a guest
Nov 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. pub fn each_in_circle(x: i32, y: i32, r: i32, mut callback: impl FnMut(i32, i32)) {
  2. for cy in (-r) ..= r {
  3. for cx in (-r)..=r {
  4. if cx * cx + cy * cy <= r * r {
  5. callback(cx + x, cy + y)
  6. }
  7. }
  8. }
  9. }
  10.  
  11. fn main() {
  12. each_in_circle(0, 0, 3, |x, y| {
  13. println!("{}, {}", x, y);
  14. })
  15. }
Add Comment
Please, Sign In to add comment