1 2 3 4 5 6 7 8 9 10 11 12 13
pub struct Example { a: i32 } impl Example { fn is_pos(&self) -> bool { self.a > 0 } } fn one() -> i32 { 1 } fn main() { if Example { a: one(), }.is_pos() { //~ ERROR invalid struct literal println!("Positive!"); } }