pub fn fun(&self, name: &DirectName, ctx: &Context, pos: &Position) -> TypeResult<Function> {
        if let Some(function) = self.functions.iter().find(|f| &f.name == name) {
            return Ok(function.clone());
        }

        // TODO deal with conflicting function names in parents.
        // TODO check for cyclic dependencies after constructing Context.
        for parent in &self.parents {
            if let Ok(function) = ctx.class(parent, pos)?.fun(name, ctx, pos) {
                return Ok(function);
            }
        }

        Err(vec![TypeErr::new(pos, &format!("'{}' does not define \"{}\"", self, name))])
    }
/// Get function of class.
///
/// If class does not implement function, traverse parents until function
/// found.
Get function of class.
If class does not implement function, traverse parents until function
found.
Get function of class . If class does not implement function traverse parents until function found .
pub fn fun(&self, name: &DirectName, ctx: &Context, pos: &Position) -> TypeResult<Function> {
        if let Some(function) = self.functions.iter().find(|f| &f.name == name) {
            return Ok(function.clone());
        }
        // TODO deal with conflicting function names in parents.
        // TODO check for cyclic dependencies after constructing Context.
        for parent in &self.parents {
            if let Ok(function) = ctx.class(parent, pos)?.fun(name, ctx, pos) {
                return Ok(function);
            }
        }
        Err(vec![TypeErr::new(pos, &format!("'{}' does not define \"{}\"", self, name))])
    }
pub fn fun ( & self , name : & DirectName , ctx : & Context , pos : & Position ) -> TypeResult < Function > { if let Some ( function ) = self . functions . iter ( ) . find ( | f | & f . name == name ) { return Ok ( function . clone ( ) ) ; } // TODO deal with conflicting function names in parents. // TODO check for cyclic dependencies after constructing Context. for parent in & self . parents { if let Ok ( function ) = ctx . class ( parent , pos ) ? . fun ( name , ctx , pos ) { return Ok ( function ) ; } } Err ( vec ! [ TypeErr new ( pos format ( " \" \" " self name ) ) ] ) }
Get function of class.
Get function of class .
&self
name
&DirectName
ctx
&Context
pos
&Position