Hi folks,
I am a little un-easy on the level of depth of nested match.
I have code that looks like this in several place of my code base.
match f() {
Err(e) => e.reply(),
Ok(x) => match g(x) {
Err(e) => e.reply(),
Ok(y) => match h(y) {
Err(e) => e.reply(),
Ok(z) => match t(z) {
Err(e) => e.reply()
Ok(g) => j(g)
}
}
}
}
The problem with this pattern is that is extremely difficult to modify code in the middle, especially add other match
es since it is difficult to understand where close the brackets.
Sure it is a kind of trivial problem but I have lost quite some time in this issue.
Clearly re-write the code and keep the functions shorter would alleviate this problem but I am wondering if I am missing something fundamental.
I am quite more con