Skip to content

Instantly share code, notes, and snippets.

@QMaximillian
Last active March 10, 2021 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QMaximillian/196c3898835fbcbc4432f2e97f2e98ee to your computer and use it in GitHub Desktop.
Save QMaximillian/196c3898835fbcbc4432f2e97f2e98ee to your computer and use it in GitHub Desktop.
//! 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