#![feature(proc_macro)] extern crate fn_mut; use fn_mut::fn_mut; struct Test1(u64); impl Test1 { #[fn_mut(enable_attrs = "text")] fn test(&self, text: &str) -> Option<&u64> { if_mut! { println!("This is mut fn: {}", text); } if_const! { println!("This is const fn: {}", text); } Some(ptr!(self.0)) } } #[test] fn test1() { let mut t = Test1(1); assert_eq!(t.test("const"), Some(&1)); let mut s = String::from("mut"); assert_eq!(t.test_mut(&mut s), Some(&mut 1)); }