What is the proper way to create a new generic struct?
问题 I'm trying to make a generic struct that can be initialized to something of type T . It looks like this: pub struct MyStruct<T> { test_field: Option<T>, name: String, age: i32, } impl MyStruct<T> { fn new(new_age: i32, new_name: String) -> MyStruct<T> { MyStruct<T> { test_field: None, age: new_age, name: new_name, } } } This doesn't seem to work. Among other errors, I get: error: chained comparison operators require parentheses --> src/lib.rs:9:17 | 9 | MyStruct<T> { | ^^^^^ | 回答1: I highly