dummy_crate 0.1.1

A dummy crate to learn how to publish crates. Do not use.
Documentation
///! # Dummy crate
/// A useless dummy crate to learn how to publish crates. Do not use.

/// Function that adds two numbers
pub fn add(left: u64, right: u64) -> u64 {
    left + right
}

/// Just some struct with two fields
pub struct S {
    pub i: i32,
    pub u: u32,
}

impl S {
    /// Constructor
    pub fn new(i: i32, u: u32) -> S {
        S { i, u }
    }

    /// Add two structs and return a- new one
    /// ```
    /// use dummy_crate::S;
    /// let s1 = S::new(1i32, 1u32);
    /// let s2 = S::new(2i32, 2u32);
    ///
    /// let s3 = s1.add(&s2);
    ///
    /// assert_eq!(s3.i, 3);
    /// assert_eq!(s3.u, 3u32);
    /// ```
    pub fn add(&self, other: &S) -> S {
        S::new(self.i + other.i, self.u + other.u)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }

    #[test]
    fn create_s() {
        let s = S::new(10i32, 20u32);
        assert_eq!(s.i, 10i32);
        assert_eq!(s.u, 20u32);
    }

    #[test]
    fn add_s() {
        let s1 = S::new(1i32, 1u32);
        let s2 = S::new(2i32, 2u32);

        let s3 = s1.add(&s2);

        assert_eq!(s3.i, 3);
        assert_eq!(s3.u, 3u32);
    }
}