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

Should #[rune::function] be associated if function returns Self #597

Open
ModProg opened this issue Aug 7, 2023 · 1 comment
Open

Should #[rune::function] be associated if function returns Self #597

ModProg opened this issue Aug 7, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ModProg
Copy link
Contributor

ModProg commented Aug 7, 2023

There is only detection in place for functions that take self, but not for e.g. constructors that return Self:

impl Struct {
    #[rune::function]
    fn new(it: usize) -> Self {
        Self(it)
    }
}

Fails with:

error[E0425]: cannot find value `__rune_fn__new` in this scope
  --> crates/rune/src/tests/rune_derive.rs:12:8
   |
12 |     fn new(it: usize) -> Self {
   |        ^^^ not found in this scope
   |
help: consider using the associated function
   |
12 |     fn Self::new(it: usize) -> Self {
   |        ++++++
help: consider importing this function
   |
1  + use crate::modules::bytes::__rune_fn__new;
   |
@udoprog
Copy link
Collaborator

udoprog commented Aug 7, 2023

Hm, yeah maybe. Interesting suggestion!

@udoprog udoprog added the enhancement New feature or request label Aug 7, 2023
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

No branches or pull requests

2 participants