FooBar::apply(x, y) => FooBar::a(x, y) => FooBar(x, y)?

Answer is probably no, but just checking anyway.

Context: I'm building a DSL / playing with macros. I am trying to get rid of the "::apply"

impl FooBar {
  fn apply(x: X, y: Y) -> ...
}

is there anyway to register apply as the 'default function' so we can do FooBar(x, y) instead of FooBar::apply(x, y) ?

On nightly, you can use the fn_traits feature to directly implement the Fn(X,Y) trait.

1 Like

I recommend against it, but types and values have separate namespaces, so you could do

struct Foo {}
#[allow(non_snake_case)]
fn Foo() {}

fn_traits kinda-sorta works for singleton types, but it's not really what was asked for I think.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.