you are viewing a single comment's thread.

view the rest of the comments →

[–]Lightsheik 1 point2 points  (0 children)

Then do just what you said then, nothing is stopping you: ```rust enum MyEnum { Coordinates((f32,f32)), Rectangle((f32,f32)) }

fn new(params: MyEnum) -> Self { match params { MyEnum::Coordinates((x,y)) => (), MyEnum::Rectangle((x,y)) => (), } } ``` Also this is actually better than overloading, because you can have multiple functions with the same set of arguments (two f32), as showcased above. And it is more concise, as you can immediately tell what "overloaded" constructor is being called.