{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigtphub44o74fr7dpc5idktonwaj6t4fr46aka5qwkrjmxkm36mk4",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mnjcvo7qzs22"
},
"path": "/t/pre-rfc-explicit-overload-sets-for-mixed-arity-function-calls/24372#post_1",
"publishedAt": "2026-06-05T04:00:35.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "# Pre-RFC: Explicit overload sets for mixed-arity function calls\n\n## Problem\n\nRust can express:\n\n\n draw(point);\n draw((x, y));\n\n\nwith traits, or:\n\n\n draw!(point);\n draw!(x, y);\n\n\nwith macros, but it cannot express:\n\n\n draw(point);\n draw(x, y);\n\n\nas ordinary function calls.\n\nThis proposal explores explicit overload sets as a narrow language feature for that specific problem.\n\n## Proposed syntax\n\n\n fn draw_point(point: Point) {\n // ...\n }\n\n fn draw_xy(x: i32, y: i32) {\n // ...\n }\n\n fn draw_vector(vec: Vec3) {}\n\n overload draw {\n fn(point: Point) = draw_point;\n fn(vec: Vec3) = draw_vector;\n fn(x: i32, y: i32) = draw_xy;\n }\n\n\nUsage:\n\n\n draw(point);\n draw(x, y);\n\n\n## Non-goals\n\n * No implicit conversions.\n * No overload ranking.\n * No return-type-only overloading.\n * No duplicate `fn` items with the same name.\n * No open overload sets across crates, at least initially.\n\n\n\n## Questions\n\n * Is this problem large enough to justify a language feature?\n * Is an explicit overload set preferable to traits, tuples, or macros?\n * Is the proposed syntax too foreign for Rust?\n * Are mixed-arity calls important enough to solve directly?\n\n",
"title": "Pre-RFC: Explicit overload sets for mixed-arity function calls"
}