Closed
Description
Given the following code:
pub trait Elements
where
Self: IntoWasmAbi,
{
fn get_pos(&self) -> Vec2<f64>;
fn get_pos_json(&self) -> String;
fn get_collision_bodies(&self) -> &HashMap<String, CollisionBody>;
fn add_collision_body(&mut self);
fn remove_collision_body(&mut self);
fn draw_collisions(&self, engine: &Engine);
}
#[wasm_bindgen]
pub struct Engine {
window_dimensions: Vec2<u32>,
speed: f64,
acceleration: f64,
elements: HashMap<String, Box<dyn Elements<Abi = String>>>,
context: CanvasRenderingContext2d,
}
The current output is:
194 | pub trait Elements
| -------- this trait cannot be made into an object...
= help: consider turning `describe` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
help: consider turning `describe` into a method by giving it a `&self` argument
|
56 | fn describe&self();
| +++++
194 | pub trait Elements
| -------- this trait cannot be made into an object...
= help: consider turning `describe` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
help: consider turning `describe` into a method by giving it a `&self` argument
|
56 | fn describe(&self);
| +++++
The IntoWasmAbi is a trait from another crate btw, I don't think this should be the right answer because you can't really modify the other crate. I mean, you can, but not inside the project.