use std::any::Any;
use core::fmt::Debug;
trait ColTrait: std::fmt::Debug{
fn getself<T>(&self)->T;
}
#[derive(Debug)]
struct DataCell<T>{
val:T,
}
// #[derive(Debug)]
struct Col{
title:String,
data:Vec<Box<dyn ColTrait>>
}
impl<T> ColTrait for DataCell<T> {
// fn getself(&self) -> usize{
// // self.val
// 1
// }
}
// impl std::fmt::Display for dyn ColTrait {
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// write!(f, "<{:?}>", &self)
// }
// }
// impl Debug for dyn ColTrait {
// fn fmt(&self, f: &mut core::fmt::Formatter<'_>)->Result<(), std::fmt::Error> {
// write!(f, "<START{:?}END>", &self)
// }
// }
fn main(){
let a = DataCell{val:1.1};
let b = DataCell{val:1};
let c = Col{
title: "A".to_string(),
data: vec![Box::new(a), Box::new(b)],
};
let mut m = 1;
for i in c.data.iter(){
println!("{}", m);
m +=1;
println!("{:?}", *i);
}
}