3 ms·
I designed the lifetime syntax and I'm far from having a pure math background. There aren't any sigils in Rust that C doesn't have, other than the lifetime synt
by pcwalton 7y ago
I designed the lifetime syntax and I'm far from having a pure math background. There aren't any sigils in Rust that C doesn't have, other than the lifetime syntax, which needs separate syntax as it's a novel feature.
Can you name a specific feature you want removed from Rust?
- jandrese 7y agoI'm not sure I'd want it removed, but generics tend to be pretty horrific looking to people new to the language. An example: fn largest<T>(list: &[T]) -> T { let mut largest = list[0]; for &item in list.iter() { if item > largest { largest = item; } } I'm sure experienced Rust devs look at that and say it's fine, but that's definitely a hurdle for new developers.
- pcwalton 7y agoWhat would you want to see instead? That's pretty much the same syntax as generics in Java.
- slavik81 7y agoYou need to specify the properties of T that you use. So, that first line should be: fn largest<T: PartialOrd + Copy>(list: &[T]) -> T { https://tomtongue.com/docs/rust-wk-20.html#trait-bounds https://tomtongue.com/docs/rust-wk-20.html#trait-bounds