rune
rune copied to clipboard
Should `#[rune::function]` be associated if function returns `Self`
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;
|
Hm, yeah maybe. Interesting suggestion!