You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct S {
x : uint,
func : fn(uint)
}
impl S {
fn no_func(val : uint) { println!("{}", val); }
fn new() -> S {
S { x : 0, func : S::no_func }
}
}
fn main() {
let s : S = S::new();
s.func(7);
}
And I got the error: error: typeSdoes not implement any method in scope named "func"
It seems to try to look for a member function and ignore the member variable. One person(alexchandel) in the rust irc channel said this was a bug and should work, another(p1start) said the error message should be improved.
The text was updated successfully, but these errors were encountered:
To get this working, you need to write (s.func)(7);. The problem is that Rust will search only for methods named func and not for fields. I don't know if there are plans of changing this behavior. If not, then I guess it would be nice to get a clearer error message which explains this.
I've tagged the bug so that it covers improving the error message by adding something like note: write (s.func)(...)if you meant to call the function stored in thefunc field.
I tried to do this:
And I got the error:
error: type
Sdoes not implement any method in scope named "func"
It seems to try to look for a member function and ignore the member variable. One person(alexchandel) in the rust irc channel said this was a bug and should work, another(p1start) said the error message should be improved.
The text was updated successfully, but these errors were encountered: