Skip to content

Instantly share code, notes, and snippets.

@aaripurna
Created July 23, 2021 16:53
Show Gist options
  • Save aaripurna/42f00e9a9b3c31b3473f54cd8b746f26 to your computer and use it in GitHub Desktop.
Save aaripurna/42f00e9a9b3c31b3473f54cd8b746f26 to your computer and use it in GitHub Desktop.
depp nessted match mattern
match connect_database() {
Ok(mut conn) => match conn.fetch_user() {
Ok(user) => conn.get_post(user.id) {
Ok(post) => conn.get_comments(post.id) {
Ok(_comments) => println!("We got the coments"),
Err(_) => println!("its error, no comment")
}
Err(_) => println!("Can't find post")
}
Err(_) => println!("Can't find user")
}
Err(_) => println!("Database connetion failed")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment