mirror of
https://github.com/bevyengine/bevy
synced 2024-12-23 03:23:20 +00:00
1690b28e9f
# Objective - `Curve<T>` was meant to be object safe, but one of the latest commits made it not object safe. - When trying to use `Curve<T>` as `&dyn Curve<T>` this compile error is raised: ``` error[E0038]: the trait `curve::Curve` cannot be made into an object --> crates/bevy_math/src/curve/mod.rs:1025:20 note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> crates/bevy_math/src/curve/mod.rs:60:8 | 23 | pub trait Curve<T> { | ----- this trait cannot be made into an object... ... 60 | fn sample_iter(&self, iter: impl IntoIterator<Item = f32>) -> impl Iterator<Item = Option<T>> { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `sample_iter` references an `impl Trait` type in its return type | | | ...because method `sample_iter` has generic type parameters ... ``` ## Solution - Making `Curve<T>` object safe again by adding `Self: Sized` to newly added methods. ## Testing - Added new test that ensures the `Curve<T>` trait can be made into an objet. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
clippy.toml | ||
README.md |