Hello!
I am using a plotting package, https://crates.io/crates/charts, and I am having some problems making it understand how to understand a specific trait. It is giving me an error:
.load_data(&scatter_data_1)
| ^^^^^^^^^^^^^^^ the trait `charts::PointDatum<f32, f32>` is not implemented for `nalgebra::Point<f32, nalgebra::U3>`
And basically what I have been doing is then:
use nalgebra::{Point3};
impl charts::PointDatum<f32, f32> for Point3<f32> {
fn get_x(&self) -> f32 {
self.coords[0]
}
fn get_y(&self) -> f32 {
self.coords[2]
}
fn get_key(&self) -> String {
String::new()
}
}
This gives the error:
only traits defined in the current crate can be implemented for arbitrary types
impl doesn't use only types from inside the current crate
note: define and implement a trait or new type insteadrustc(E0117)
So I have tried looking E0117 up to circumvent this problem, but my tries up till now has not been succesful. I have written it as:
struct MyType(Point3<f32>);
impl charts::PointDatum<f32, f32> for MyType {
fn get_x(&self) -> f32 {
self.0.coords[0]
}
fn get_y(&self) -> f32 {
self.0.coords[2]
}
fn get_key(&self) -> String {
String::new()
}
}
But I still get the first mentioned error that for some reason it cannot figure out that "Point3<f32" == MyType now..
Maybe I am doing something wrong still.
Kind regards