simple/simple.rs
1use std::any::TypeId;
2
3use typed_log::{Loggable, log_any};
4
5pub struct MyCustomStruct {
6 pub to_log: String,
7}
8
9impl Loggable for MyCustomStruct {
10 fn type_id(&self) -> std::any::TypeId {
11 TypeId::of::<Self>()
12 }
13}
14
15fn logger(my_struct: &MyCustomStruct) {
16 println!("{}", my_struct.to_log);
17}
18fn main() {
19 typed_log::push_log_impl(&logger);
20
21 log_any(&MyCustomStruct {
22 to_log: "inner value".to_string(),
23 });
24}