Is there a branch of CS about studying function calls branching?

I know little about computer science. I wrote a function that has some ifs and may call itself recursively.

Is there a branch of computer science that studies these possible branches?

I'd like to analyze the possible branches and maybe generate a graph of all of them to study all possible outcomes of my function.

my_func(&mut self, request: Request, retry_count: i32) -> Result<(), FuncError> {
let response = self.send(request);
let response = match response {
Ok(_) => return Ok(()),
Err(Error::Unauthorized(unauthorized)) => Err(FuncError::Unauthorized(unauthorized)),
Err(Error::ConnectionClosed) => Err(FuncError::ConnectionClosed{}),
Err(_) => Err(FuncError::UnknownError{})
}
match response {
Ok(()) => Ok(()),
Err(Error::Unauthorized(unauthorized)) => {
self.authorize();
return self.my_func(request, retry_count -1),
}
Err(Error::ConnectionClosed) => {
self.connect();
return self.my_func(request, retry_count -1),
}
Err(_) => Err(FuncError::UnknownError)
}
}


I'd like to generate a graph of all possible outcome for this Rust method, considering a small retry_count of 3 for example. Or maybe read more about some theory on how to analyze this function and know more about it, etc.

I don't think there's something ready for Rust, but maybe for C++. Maybe one that I can do manually, without parsing some language.

• I'm not sure I understand what you been by I'd like to generate a graph of all possible outcome for this Rust method, considering a small retry_count of 3 for example, but it seems you are talking about control-flow graph and/or data-flow analysis, which are studied in static analysis. – Dmitry Apr 10 at 19:57
• Cyclomatic complexity, perhaps? – D. Ben Knoble Apr 10 at 21:24
• I find it hard to understand what you want to know. I don't know what you mean by a "graph of all possible outcome" or a "graph of all of [the possible graphs]". I suggest reading about control-flow graphs and see if they meet your needs, then coming back and editing your question to state your requirements more clearly. Coding-specific questions (such as questions specific to Rust) are off-topic here. – D.W. Apr 11 at 7:21