Skip to content
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

Support free functions #50

Open
BrynCooke opened this issue May 14, 2022 · 2 comments
Open

Support free functions #50

BrynCooke opened this issue May 14, 2022 · 2 comments

Comments

@BrynCooke
Copy link
Owner

BrynCooke commented May 14, 2022

Maybe we can support functions that are not on an impl

Alternative 1:

Directly on fn outside of impl.

#[builder(entry="foo", exit="call")
fn do_foo(a: usize) {
...
}

Alternative 2:

Still require an impl. Allow derivation of proxy method:

#[buildstructor::buildstructor]
impl Foo {
  #[builder(entry="foo", exit="call", proxy=true)
  fn do_foo(a: usize) {
  ...
  }
}

//Derived
fn foo() {
  Foo::foo()
}
@CGMossa
Copy link

CGMossa commented Jul 13, 2022

While using bevy_ecs, I want to add entities that has different sets of components attached to them.
This means that what I'd ideally want, is a way to construct a builder, around a function, but the resulting struct should atleast derive(Bundle).

@BrynCooke
Copy link
Owner Author

@CGMossa Could you elaborate a bit more?
The final struct that a buildstructor builder spits out is not derived, it is the result of a constructor being called. Thus you can put derives on that struct no problem.
Probably some code examples would help me understand.

@BrynCooke BrynCooke changed the title Support arbitrary functions Support free functions Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants