If you just have one or two required fields, with the rest being optional, it can also be a good middle ground to just pass the required fields to new()
and use methods like in your example for the optionals.
PS.: A common convention for these methods is to prefix them with with_
, like with_max_depth(max_depth: usize) -> Self
.
As much as people like to make fun of JS/TS, I think you’re right, especially compared to the languages you mentioned. It’s my second-favorite language after Rust.
I think I would put Swift above it as well, except I don’t really use it since it’s too domain-specific in practice.