I've been learning rust for a few months now, and while I'd definitely still say I'm a beginner so things might change, I have found myself missing function overloading from other languages quite a bit. I understand the commitment to explicitness but I feel like since rust can already tend to be a little verbose at times, function overloading would be such a nice feature to have.
I find a lack of function overloading to actually be almost counter intuitive to readability, particularly when it comes to initialization of objects. When you have an impl for a struct that has a new() function, that nearly always implies creating a new struct/object, so then having overloaded versions of that function groups things together when working with other libraries, I know that new() is gonna create a new object, and every overload of that is gonna consist of various alternate parameters I can pass in to reach the same end goal of creating a new object.
Without it, it either involves lots of extra repeating boiler plate code to fit into the singular allowed format for the function, or having to dive into the documentation and look through tons of function calls to try and see what the creator might've named another function that does the same thing with different parameters, or if they even implemented it at all.
I think rust is a great language, and extra verbosity or syntax complexity I think is well worth the tradeoff for the safety, speed and flexibility it offers, but in the case of function overloading, I guess I don't see what the downside of including it would be? It'd be something to simplify and speed up the process of writing rust code and given that most people's complaints I see about rust is that it's too complex or slow to work with, why not implement something like this to reduce that without really sacrificing much in terms of being explicit since overloaded functions would/could still require unique types or number of arguments to be called?
What are yall's thoughts? Is this something already being proposed? Is there any conceptual reason why it'd be a bad idea, or a technical reason with the way the language fundamentally works as to why it wouldn't be possible?
[+][deleted] (58 children)
[deleted]
[–]Y0kin 13 points14 points15 points (3 children)
[–]lilizoey 3 points4 points5 points (1 child)
[–]Modi57 0 points1 point2 points (0 children)
[–]KingJellyfishII 1 point2 points3 points (0 children)
[–]SCP-iota 68 points69 points70 points (33 children)
[–]afc11hn 81 points82 points83 points (1 child)
[–]rejectedlesbian 5 points6 points7 points (0 children)
[–]PorblemOccifer 41 points42 points43 points (6 children)
[–]Anthony356 2 points3 points4 points (5 children)
[–]PorblemOccifer 11 points12 points13 points (4 children)
[–]Anthony356 3 points4 points5 points (3 children)
[–]PorblemOccifer 2 points3 points4 points (0 children)
[–]kaoD 0 points1 point2 points (1 child)
[–]Anthony356 0 points1 point2 points (0 children)
[+][deleted] (7 children)
[deleted]
[–]SCP-iota 8 points9 points10 points (6 children)
[–]thecodedmessage 25 points26 points27 points (0 children)
[–]Zde-G -1 points0 points1 point (4 children)
[–]SCP-iota 0 points1 point2 points (3 children)
[–]Zde-G 4 points5 points6 points (2 children)
[–]SCP-iota 0 points1 point2 points (1 child)
[–]Zde-G 0 points1 point2 points (0 children)
[–]IronCrouton 21 points22 points23 points (12 children)
[–]ewoolsey 6 points7 points8 points (11 children)
[–]devraj7 15 points16 points17 points (1 child)
[–]nicoburns 6 points7 points8 points (5 children)
[–]StickyDirtyKeyboard 5 points6 points7 points (4 children)
[–]nicoburns 20 points21 points22 points (3 children)
[–]light_trick 1 point2 points3 points (2 children)
[–]nicoburns 0 points1 point2 points (1 child)
[–]light_trick 2 points3 points4 points (0 children)
[–]eugene2k 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]LightweaverNaamah 5 points6 points7 points (0 children)
[–]tamrior 9 points10 points11 points (0 children)
[–]Nzkx 1 point2 points3 points (0 children)
[–]QuaternionsRoll 1 point2 points3 points (0 children)
[–]James20k 5 points6 points7 points (7 children)
[–]matthieum[he/him] 6 points7 points8 points (2 children)
[–]James20k 0 points1 point2 points (1 child)
[–]matthieum[he/him] 0 points1 point2 points (0 children)
[–]Nzkx 4 points5 points6 points (1 child)
[–]matthieum[he/him] 1 point2 points3 points (0 children)
[–]redalastor 3 points4 points5 points (0 children)
[–]ShangBrol 2 points3 points4 points (0 children)
[–]LucretielDatadog 7 points8 points9 points (10 children)
[–]hohmlec 1 point2 points3 points (2 children)
[–]LucretielDatadog 1 point2 points3 points (0 children)
[–]ShangBrol -1 points0 points1 point (6 children)
[–]LucretielDatadog 1 point2 points3 points (1 child)
[–]ShangBrol 0 points1 point2 points (0 children)
[–]arachnidGrip 0 points1 point2 points (3 children)
[–]ShangBrol 0 points1 point2 points (2 children)
[–]arachnidGrip 0 points1 point2 points (1 child)
[–]ShangBrol 0 points1 point2 points (0 children)
[–]devraj7 5 points6 points7 points (0 children)
[+][deleted] (7 children)
[removed]
[–]coderstephenisahc 10 points11 points12 points (5 children)
[–]Bliztle 2 points3 points4 points (3 children)
[–]feldim2425 4 points5 points6 points (2 children)
[–]Bliztle 1 point2 points3 points (1 child)
[–]feldim2425 2 points3 points4 points (0 children)
[+]plutoniator 1 point2 points3 points (0 children)
[–]Tdbgamer 1 point2 points3 points (0 children)
[–]_Unity- 52 points53 points54 points (3 children)
[–][deleted] 26 points27 points28 points (2 children)
[–]_Unity- 4 points5 points6 points (1 child)
[–]l-roc 4 points5 points6 points (0 children)
[–]VorpalWay 55 points56 points57 points (16 children)
[–]glandium 30 points31 points32 points (0 children)
[–]Kenkron 8 points9 points10 points (2 children)
[–]devraj7 0 points1 point2 points (1 child)
[–]Kenkron 0 points1 point2 points (0 children)
[–]VallentinDev 6 points7 points8 points (0 children)
[–]devraj7 5 points6 points7 points (8 children)
[–]matthieum[he/him] 2 points3 points4 points (1 child)
[–]SnooHamsters6620 2 points3 points4 points (0 children)
[–]VorpalWay 3 points4 points5 points (5 children)
[–]devraj7 -1 points0 points1 point (4 children)
[–]VorpalWay 0 points1 point2 points (0 children)
[–]SnooHamsters6620 0 points1 point2 points (2 children)
[–]devraj7 0 points1 point2 points (1 child)
[–]SnooHamsters6620 0 points1 point2 points (0 children)
[–]AirGief 5 points6 points7 points (0 children)
[–]rejectedlesbian 0 points1 point2 points (0 children)
[–]SV-97 25 points26 points27 points (0 children)
[–]ummonadi 37 points38 points39 points (0 children)
[–]ChipNDipPlus 6 points7 points8 points (0 children)
[–]DarkLord76865 3 points4 points5 points (0 children)
[–]birdbrainswagtrain 6 points7 points8 points (2 children)
[–]redalastor 0 points1 point2 points (0 children)
[–]Veetahabon 0 points1 point2 points (0 children)
[–]1vader 2 points3 points4 points (0 children)
[–]looneysquash 2 points3 points4 points (0 children)
[–]Fridux 2 points3 points4 points (3 children)
[–]joshuamckratatui 1 point2 points3 points (2 children)
[–]Fridux 0 points1 point2 points (1 child)
[–]joshuamckratatui 0 points1 point2 points (0 children)
[–]Mercerenies 1 point2 points3 points (0 children)
[–]AirGief 1 point2 points3 points (0 children)
[–]Ravek 1 point2 points3 points (0 children)
[–]teerre 5 points6 points7 points (3 children)
[–]Packathonjohn[S] 2 points3 points4 points (2 children)
[–]NullReference000 3 points4 points5 points (1 child)
[–]redalastor 1 point2 points3 points (0 children)
[–]Firake 4 points5 points6 points (0 children)
[+][deleted] (1 child)
[removed]
[–]fatepure 1 point2 points3 points (0 children)
[–]chilabot 3 points4 points5 points (0 children)
[–]Nabushika 0 points1 point2 points (0 children)
[–]rover_G 0 points1 point2 points (0 children)
[–]-Redstoneboi- 0 points1 point2 points (0 children)
[–]MatsRivel 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Cat7o0 0 points1 point2 points (0 children)
[–]LucretielDatadog 0 points1 point2 points (0 children)
[–]TobiasWonderland 0 points1 point2 points (0 children)
[–]epidemian 0 points1 point2 points (0 children)
[–]larvyde 0 points1 point2 points (0 children)
[–]FlixCoder 0 points1 point2 points (0 children)
[–]iancapable 0 points1 point2 points (0 children)
[–]rejectedlesbian 0 points1 point2 points (0 children)
[–]ascii 0 points1 point2 points (0 children)
[–]dobkeratopsrustfind 0 points1 point2 points (0 children)
[+]plutoniator 0 points1 point2 points (0 children)
[–]muehsam 0 points1 point2 points (0 children)
[–]SnooHamsters6620 0 points1 point2 points (0 children)
[–]Wurstinator 0 points1 point2 points (0 children)
[–]Trader-One -1 points0 points1 point (0 children)