Incorrect function no returned by no_args_constructor
The position in the vector is not important, the contents is.
@@ -442,11 +442,14 @@ impl Contract {
/// Return the constructor with no arguments
pub fn no_args_constructor(&self, ns: &Namespace) -> Option<usize> {
- self.functions.iter().position(|func_no| {
- let func = &ns.functions[*func_no];
+ self.functions
+ .iter()
+ .find(|func_no| {
+ let func = &ns.functions[**func_no];
func.is_constructor() && func.params.is_empty()
})
+ .cloned()
}
}
