External Publication
Visit Post

Pre-RFC: Explicit overload sets for mixed-arity function calls

Rust Internals [Unofficial] June 5, 2026
Source

Pre-RFC: Explicit overload sets for mixed-arity function calls

Problem

Rust can express:

draw(point);
draw((x, y));

with traits, or:

draw!(point);
draw!(x, y);

with macros, but it cannot express:

draw(point);
draw(x, y);

as ordinary function calls.

This proposal explores explicit overload sets as a narrow language feature for that specific problem.

Proposed syntax

fn draw_point(point: Point) {
    // ...
}

fn draw_xy(x: i32, y: i32) {
    // ...
}

fn draw_vector(vec: Vec3) {}

overload draw {
    fn(point: Point) = draw_point;
    fn(vec: Vec3) = draw_vector;
    fn(x: i32, y: i32) = draw_xy;
}

Usage:

draw(point);
draw(x, y);

Non-goals

  • No implicit conversions.
  • No overload ranking.
  • No return-type-only overloading.
  • No duplicate fn items with the same name.
  • No open overload sets across crates, at least initially.

Questions

  • Is this problem large enough to justify a language feature?
  • Is an explicit overload set preferable to traits, tuples, or macros?
  • Is the proposed syntax too foreign for Rust?
  • Are mixed-arity calls important enough to solve directly?

Discussion in the ATmosphere

Loading comments...