diff --git a/crates/bevy_math/src/cubic_splines.rs b/crates/bevy_math/src/cubic_splines.rs index 8e6e880108..31fbc8824b 100644 --- a/crates/bevy_math/src/cubic_splines.rs +++ b/crates/bevy_math/src/cubic_splines.rs @@ -63,9 +63,9 @@ pub struct CubicBezier { #[cfg(feature = "alloc")] impl CubicBezier

{ /// Create a new cubic Bezier curve from sets of control points. - pub fn new(control_points: impl Into>) -> Self { + pub fn new(control_points: impl IntoIterator) -> Self { Self { - control_points: control_points.into(), + control_points: control_points.into_iter().collect(), } } } @@ -287,18 +287,18 @@ pub struct CubicCardinalSpline { #[cfg(feature = "alloc")] impl CubicCardinalSpline

{ /// Build a new Cardinal spline. - pub fn new(tension: f32, control_points: impl Into>) -> Self { + pub fn new(tension: f32, control_points: impl IntoIterator) -> Self { Self { tension, - control_points: control_points.into(), + control_points: control_points.into_iter().collect(), } } /// Build a new Catmull-Rom spline, the special case of a Cardinal spline where tension = 1/2. - pub fn new_catmull_rom(control_points: impl Into>) -> Self { + pub fn new_catmull_rom(control_points: impl IntoIterator) -> Self { Self { tension: 0.5, - control_points: control_points.into(), + control_points: control_points.into_iter().collect(), } } @@ -444,9 +444,9 @@ pub struct CubicBSpline { #[cfg(feature = "alloc")] impl CubicBSpline

{ /// Build a new B-Spline. - pub fn new(control_points: impl Into>) -> Self { + pub fn new(control_points: impl IntoIterator) -> Self { Self { - control_points: control_points.into(), + control_points: control_points.into_iter().collect(), } } @@ -630,11 +630,11 @@ impl CubicNurbs

{ /// /// At least 4 points must be provided, otherwise an error will be returned. pub fn new( - control_points: impl Into>, - weights: Option>>, - knots: Option>>, + control_points: impl IntoIterator, + weights: Option>, + knots: Option>, ) -> Result { - let mut control_points: Vec

= control_points.into(); + let mut control_points: Vec

= control_points.into_iter().collect(); let control_points_len = control_points.len(); if control_points_len < 4 { @@ -643,11 +643,11 @@ impl CubicNurbs

{ }); } - let weights = weights - .map(Into::into) + let weights: Vec = weights + .map(|ws| ws.into_iter().collect()) .unwrap_or_else(|| vec![1.0; control_points_len]); - let mut knots: Vec = knots.map(Into::into).unwrap_or_else(|| { + let mut knots: Vec = knots.map(|ks| ks.into_iter().collect()).unwrap_or_else(|| { Self::open_uniform_knots(control_points_len) .expect("The amount of control points was checked") }); @@ -846,9 +846,9 @@ pub struct LinearSpline { #[cfg(feature = "alloc")] impl LinearSpline

{ /// Create a new linear spline from a list of points to be interpolated. - pub fn new(points: impl Into>) -> Self { + pub fn new(points: impl IntoIterator) -> Self { Self { - points: points.into(), + points: points.into_iter().collect(), } } } @@ -1139,8 +1139,8 @@ pub struct CubicCurve { impl CubicCurve

{ /// Create a new curve from a collection of segments. If the collection of segments is empty, /// a curve cannot be built and `None` will be returned instead. - pub fn from_segments(segments: impl Into>>) -> Option { - let segments: Vec<_> = segments.into(); + pub fn from_segments(segments: impl IntoIterator>) -> Option { + let segments: Vec<_> = segments.into_iter().collect(); if segments.is_empty() { None } else { @@ -1455,8 +1455,8 @@ pub struct RationalCurve { impl RationalCurve

{ /// Create a new curve from a collection of segments. If the collection of segments is empty, /// a curve cannot be built and `None` will be returned instead. - pub fn from_segments(segments: impl Into>>) -> Option { - let segments: Vec<_> = segments.into(); + pub fn from_segments(segments: impl IntoIterator>) -> Option { + let segments: Vec<_> = segments.into_iter().collect(); if segments.is_empty() { None } else {