3 ms·
Default only assigns parameters to their default value based on their type (e.g. "0" for u8), it's not an actual implementation of actual default parameters. M
by hota_mazi 5y ago
Default only assigns parameters to their default value based on their type (e.g. "0" for u8), it's not an actual implementation of actual default parameters.
More details about this and what else is lacking in Rust compared to Kotlin:
https://medium.com/@cedricbeust/what-rust-could-learn-from-kotlin-b32ebe2da28d https://medium.com/@cedricbeust/what-rust-could-learn-from-k...
- tristan957 5y agoYou can derive the Default trait (this is the most popular use case) or implement it yourself where you can have custom default values.
- slashink 5y agoYou can just implement the Default trait yourself and set sane defaults right? At least that’s how I use it, implement the default trait manually to easily return a initialized struct.
- hota_mazi 5y agoYes, I was referring to when you derive the trait, I should have been more specific. Also, this doesn't help at all for function invocation, which is still very cumbersome in Rust in the absence of default parameters, named parameters, and overloading.