use call_trace::{trace_with, CallContext, Trace}; struct My<'a> { data: &'a [u8], } impl<'a> My<'a> { #[inline] #[trace_with(self)] /// test fn foo(&mut self) { self.bar(); } #[trace_with(self)] fn bar(&mut self) { let x = self.baz(); let y = self.baz(); println!("x + y = {}", x + y); } #[trace_with(self)] fn baz(&mut self) -> i32 { 15 } #[trace_with(self)] fn brw2(&mut self) -> &'a [u8] { self.baz(); &self.data } #[trace_with(self)] fn brw4(&mut self) -> &'a [u8] { self.brw2() } fn track(&mut self, c: char, ctx: &CallContext) { println!("!!! {} {:?}", c, ctx); } } impl<'a> Trace for My<'a> { fn on_pre(&mut self, ctx: &CallContext) { self.track('>', &ctx); } fn on_post(&mut self, ctx: &CallContext) { self.track('<', &ctx); } } #[test] fn test() { (My { data: b"asdf" }).brw4(); }