How do I implement std::fmt::Debug
for a custom trait?
I want to be able to print Frame
in my below example.
However, I get the compile error that (dyn Series + 'static)` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug
I am unsure how I should implement this for Series
trait Series {
fn len(&self) -> usize;
//....
}
#[derive(Debug)]
struct Floats {
data: Vec<f64>,
name: String,
}
impl Series for Floats {
fn len(&self) -> usize {
self.data.len()
}
}
#[derive(Debug)]
struct Frame {
columns: Vec<Box<dyn Series>>,
}
fn main() {
let f = Floats{data: vec![1.,2.],name: "H1".to_string()};
let df = Frame{
columns: vec![Box::new(f)],
};
println!("{:?}", df);
}
Thanks for your help!