Created
October 30, 2018 00:28
-
-
Save rust-play/c19f77cf066ca3f67f601ab262df2daa to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn save_status(text: &str) -> Result<i64, &'static str> { | |
if text.len() > 200 { | |
return Err("status is too long, must be under 200 bytes"); | |
} | |
let id = save_to_database(text)?; | |
// log id to server logs | |
Ok(id) | |
} | |
fn save_to_database(text: &str) -> Result<i64, &'static str> { | |
Err("database unavailable") | |
} | |
fn save_to_database(text: &str) -> Result<i64, DatabaseError> { | |
Err(DatabaseError::Unavailable) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment