fn point_mapper(
  radius: f32,
  start_theta: f32,
  end_theta: f32,
  n_points: f32,
) -> impl Fn(i32) -> Point2 {
  move |n| {
    let factor = n as f32 / n_points;
    let theta = start_theta + factor * (end_theta - start_theta);
    let x = theta.cos() * radius;
    let y = theta.sin() * radius;
    pt2(x, y)
  }
}
// Not sure if it's better to return the closure with this `impl Fn` notation
// as recommended by this
// https://doc.rust-lang.org/stable/rust-by-example/fn/closures/output_parameters.html
// or by wrapping in a Box as recommended by this
// https://doc.rust-lang.org/book/ch19-05-advanced-functions-and-closures.html
//
// I think the impl Fn is a bit cleaner looking and also a little less verbose
// so I'm going with that style here


I think the impl Fn is a bit cleaner looking and also a little less verbose
so I'm going with that style here
I think the impl Fn is a bit cleaner looking and also a little less verbose so I ' m going with that style here
fn point_mapper(
  radius: f32,
  start_theta: f32,
  end_theta: f32,
  n_points: f32,
) -> impl Fn(i32) -> Point2 {
  move |n| {
    let factor = n as f32 / n_points;
    let theta = start_theta + factor * (end_theta - start_theta);
    let x = theta.cos() * radius;
    let y = theta.sin() * radius;
    pt2(x, y)
  }
}
fn point_mapper ( radius : f32 , start_theta : f32 , end_theta : f32 , n_points : f32 , ) -> impl Fn ( i32 ) -> Point2 { move | n | { let factor = n as f32 / n_points ; let theta = start_theta + factor * ( end_theta - start_theta ) ; let x = theta . cos ( ) * radius ; let y = theta . sin ( ) * radius ; pt2 ( x , y ) } }
Not sure if it's better to return the closure with this `impl Fn` notation
as recommended by this
https://doc.rust-lang.org/stable/rust-by-example/fn/closures/output_parameters.html
or by wrapping in a Box as recommended by this
https://doc.rust-lang.org/book/ch19-05-advanced-functions-and-closures.html
Not sure if it ' s better to return the closure with this ` impl Fn ` notation as recommended by this https : // doc . rust - lang . org / stable / rust - by - example / fn / closures / output_parameters . html or by wrapping in a Box as recommended by this https : // doc . rust - lang . org / book / ch19 - 05 - advanced - functions - and - closures . html
radius
f32
start_theta
f32
end_theta
f32
n_points
f32