Can't find generic function

Hi, I called a generic function generic_fun from another function build. But the compiler said it cannot find the function. Any suggestion? Thanks!

pub struct Triangle<T> {
    side: T,
}

impl<T> Triangle<T> {
    pub fn generic_fun(side: T) -> bool {
        true
    }
    pub fn build(side: T) -> Option<Self> {
        if generic_fun(side) {
        }
        None
    }
}

fn main() {}
error[E0425]: cannot find function `generic_fun` in this scope
  --> src\main.rs:10:12
   |
10 |         if generic_fun(side) {
   |            ^^^^^^^^^^^ not found in this scope


generic_fun is an associated method of Triangle. You need to call it like so:

if Triangle::generic_fun(side) {
}
2 Likes

Thank you! I forgot generic function must be static.