fn main() {
let my_str: Rc<RefCell<Box<MyStruct1>>> =
Rc::new(RefCell::new(Box::new(MyStruct1)));
my_trait_fn(Rc::new(RefCell::new(Box::new((**my_str.borrow()).clone()))));
my_str.borrow().my_fn();
}
I come from a Python/Java world and I remember when I first delved into embedded MCU programming in C/C++, it was a cognitive overload and a half. I think we need to take a step back and while I understand the differences between high level languages (Java/Python) and C/C++ having the burden to allow for low-level programming; readability aspects of code often gets the lowest attention.If we, humans, spend so much time writing/parsing code through our vision system, programming languages need to take this aspect seriously and optimize the syntax over readability than expressivity.
I recall Kernighan's "The Elements of Programming Style" where he talks about making the code more understandable than "clever". The syntax of a programming language directly facilitates (or impedes) this idea.
Edit - Everyone seems to keep pointing out it is a contrived example. Yes, I agree but the syntax has nothing to do with making the contrived example even more difficult to read?