I am trying to understand what exactly the scope is for functions defined within an impl
block but which don't accept &self
as a parameter. For example, why doesn't the following chunk of code compile? I get the error "cannot find function generate_a_result
in this scope".
pub struct Blob {
num: u32,
}
impl Blob {
pub fn new() -> Blob {
generate_a_result()
}
fn generate_a_result() -> Blob {
let result = Blob {
num: 0
};
result
}
}