Skip to content

Add overload proc macro for #[splat] function overloading#5

Open
Ajay-singh1 wants to merge 6 commits into
rustfoundation:mainfrom
Ajay-singh1:overloading-macro-for-splat
Open

Add overload proc macro for #[splat] function overloading#5
Ajay-singh1 wants to merge 6 commits into
rustfoundation:mainfrom
Ajay-singh1:overloading-macro-for-splat

Conversation

@Ajay-singh1

@Ajay-singh1 Ajay-singh1 commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

This is a proof of concept for the overload! macro that makes #[splat]
easier to use for function overloading.

What it does

Case 1: Functions with single argument

overload! {
    fn foo(x: i32) { println!("i32: {}", x); }
    fn foo(x: f64) { println!("f64: {}", x); }
    fn foo(x: bool) { println!("bool: {}", x); }
}

foo(30);
foo(22.90);
foo(true);

Case 2: Functions with multiple arguments

overload! {
    fn foo(x: i32, y: f64) { println!("i32: {}, f64: {}", x, y); }
    fn foo(x: bool, y: i32, z: f64) { println!("bool: {}, i32: {}, f64: {}", x, y, z); }
}

foo(54, 63.90);
foo(true, 98, 65.09);

Current status

  • Multiple functions: done
  • Single argument: done
  • Multiple arguments with mixed types: done
  • Return values: in progress
  • Methods: not started
  • Generics: not started

Next steps

  • Handle return values
  • Handle methods
  • Handle generics

Signed-off-by: Ajay Singh <ajaykripa8736968359@gmail.com>
@Ajay-singh1 Ajay-singh1 marked this pull request as draft July 12, 2026 17:32
@teor2345 teor2345 self-requested a review July 13, 2026 03:36
@teor2345 teor2345 added the enhancement New feature or request label Jul 13, 2026
teor2345

This comment was marked as resolved.

@Ajay-singh1

This comment was marked as resolved.

Signed-off-by: Ajay Singh <ajaykripa8736968359@gmail.com>
Signed-off-by: Ajay Singh <ajaykripa8736968359@gmail.com>
Signed-off-by: Ajay Singh <ajaykripa8736968359@gmail.com>

@teor2345 teor2345 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix and merge what we have now, then open other PRs for further changes?

Comment thread rust-toolchain.toml
Comment thread splat-overload-test/src/bin/multiple-args.rs Outdated
Comment thread splat-overload-test/src/bin/multiple-args.rs
teor2345 and others added 2 commits July 15, 2026 12:58
Signed-off-by: Ajay Singh <ajaykripa8736968359@gmail.com>
@Ajay-singh1 Ajay-singh1 changed the title [WIP]: Add overload proc macro for #[splat] function overloading Add overload proc macro for #[splat] function overloading Jul 16, 2026
@Ajay-singh1 Ajay-singh1 marked this pull request as ready for review July 16, 2026 03:29
@Ajay-singh1

Copy link
Copy Markdown
Collaborator Author

Done! We can merge this now , we can open other PRs for next changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants