Update readme and another tutorial

This commit is contained in:
Tim Warren 2015-12-10 14:35:41 -05:00
parent 3a5f80e153
commit f635b26671
5 changed files with 46 additions and 0 deletions

View File

@ -1 +1,3 @@
# literate-tribble # literate-tribble
## Rust toy programs and tutorials

4
adder/Cargo.lock generated Normal file
View File

@ -0,0 +1,4 @@
[root]
name = "adder"
version = "0.1.0"

4
adder/Cargo.toml Normal file
View File

@ -0,0 +1,4 @@
[package]
name = "adder"
version = "0.1.0"
authors = ["Tim Warren <twarren@nexient.com>"]

30
adder/src/lib.rs Normal file
View File

@ -0,0 +1,30 @@
//! The `adder` crate provides functions that add numbers to other numbers
//!
//! # Examples
//!
//! ```
//! assert_eq!(4, adder::add_two(2));
//! ```
/// This function adds two to its argument
///
/// # Examples
///
/// ```
/// use adder::add_two;
///
/// assert_eq!(4, add_two(2));
/// ```
pub fn add_two(a: i32) -> i32 {
a + 2 // return
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(4, add_two(2));
}
}

6
adder/tests/lib.rs Normal file
View File

@ -0,0 +1,6 @@
extern crate adder;
#[test]
fn it_works() {
assert_eq!(4, adder::add_two(2));
}