-
-
Save QMaximillian/196c3898835fbcbc4432f2e97f2e98ee to your computer and use it in GitHub Desktop.
This file contains 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
//! This library has two functions | |
//! that will add an integer to the integer you pass in. | |
/// Adds 5 to the integer passed in. | |
/// | |
/// # Examples | |
/// | |
/// ```rust | |
/// # use addition_functions::add_five; | |
/// assert_eq!(15, add_five(10)) | |
/// ``` | |
pub fn add_five(number: usize) -> usize { | |
// I chose to return explicitly here | |
// for clarity in a blog where we're learning | |
// how to write comments | |
return number + 5; | |
} | |
/// Adds 10 to the integer passed in. | |
pub fn add_ten(number: usize) -> usize { | |
// I chose not to return explicitly here | |
// because we now know we can return explicitly in | |
// Rust, but we can also not include a ";" (semi-colon) | |
// and Rust will return that expression | |
number + 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment