-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overloaded function renaming might cause conflicts #1316
Comments
Yeah, this isn't great and as the manual says, this all needs to be overhauled a bit. Meanwhile though I do certainly consider this a bug, and I'd accept a pull request for a temporary solution, e.g. if |
Closely related to #995 |
Just sharing some random thoughts on overloaded functions. Would the following options be better?
struct Image;
pub trait ByteSwap<Args> {
type Output;
fn byte_swap(args: Args) -> Self::Output;
}
impl ByteSwap<(u64, bool)> for Image {
type Output = u64;
fn byte_swap(args: (u64, bool)) -> u64 { todo!() }
}
impl ByteSwap<(u32, bool)> for Image {
type Output = u32;
fn byte_swap(args: (u32, bool)) -> u32 { todo!() }
}
impl ByteSwap<(u16, bool)> for Image {
type Output = u16;
fn byte_swap(args: (u16, bool)) -> u16 { todo!() }
} Or generate a trait for the args so that the trait doesn't need to be public mod ffi {
pub struct Image;
impl Image {
fn byte_swap<Args: ByteSwapArgs<Image>>(args: Args) -> Args::Output {
ByteSwapArgs::<Image>::perform_byte_swap(args)
}
}
trait ByteSwapArgs<T> {
type Output;
fn perform_byte_swap(self) -> Self::Output;
}
impl ByteSwapArgs<Image> for (u64, bool) {
type Output = u64;
fn perform_byte_swap(self) -> u64 { todo!() }
}
impl ByteSwapArgs<Image> for (u32, bool) {
type Output = u32;
fn perform_byte_swap(self) -> u32 { todo!() }
}
impl ByteSwapArgs<Image> for (u16, bool) {
type Output = u16;
fn perform_byte_swap(self) -> u16 { todo!() }
}
} |
Describe the bug
Overloaded function renaming might cause conflicts
To Reproduce
See #1317
I have a class:
calling
generate!
on it will causebyteSwap2
to be generated twice. One for the overload, one for the actualbyteSwap2.
This is because the renaming of the return u16 overload is
byteSwap2
and there is an actualbyteSwap2
function.Expected behavior
Find a better renaming.
Or throw an error from the macro
Additional context
The text was updated successfully, but these errors were encountered: