Update readme and another tutorial
This commit is contained in:
parent
3a5f80e153
commit
f635b26671
4
adder/Cargo.lock
generated
Normal file
4
adder/Cargo.lock
generated
Normal file
@ -0,0 +1,4 @@
|
||||
[root]
|
||||
name = "adder"
|
||||
version = "0.1.0"
|
||||
|
4
adder/Cargo.toml
Normal file
4
adder/Cargo.toml
Normal 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
30
adder/src/lib.rs
Normal 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
6
adder/tests/lib.rs
Normal file
@ -0,0 +1,6 @@
|
||||
extern crate adder;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(4, adder::add_two(2));
|
||||
}
|
Reference in New Issue
Block a user