Hacker News new | ask | show | jobs
by chipdart 708 days ago
> You're mistaken. Rust does not require you to define all constructors. Rust does not have constructors.

I don't think you managed to understand what I actually said, and consequently you wrote a whole wall of text that's not related to the point I made.

2 comments

Your post starts with the flawed assumption that you have to define constructors in Rust, and then your own wall of text (ironically longer than mine) about avoiding boilerplate which doesn't apply to Rust. I'm not sure you understood my point.
> Your post starts with the flawed assumption that you have to define constructors in Rust (...)

I did not. Read what I wrote.

Just to further illustrate what I'm saying, are you really trying to say that

``` //explicitly annotating this struct is default initializable and copyable #[derive(Default, Copy, Clone)] struct Foo { ... } ```

is actually worse than

``` struct Foo {...}; // rule of zero, copy/move/default are defined/deleted based arcane rules predicated on the contents of Foo ```

> Just to further illustrate what I'm saying, are you really trying to say that (...)

If you read what I wrote you'll notice I was pointing out the absurdity of claiming that being forced to write each and every single factory method/constructor is somehow better and simpler than allowing the compiler to write them for us for trivia classes but still having the compiler step off when we opt to write each and every single factory method/constructor ourselves.