fera-fun 0.1.0

Free functions for fun programming.
Documentation
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

/// ```
/// #[macro_use] extern crate fera_fun;
///
/// # fn main() {
/// assert_eq!(Some(&2), max!(&[0, 2, 1]));
/// assert_eq!(8, max!(8, 2));
/// assert_eq!(3, max!(0, 3, 1));
/// # }
/// ```
#[macro_export]
macro_rules! max {
    ($e1: expr) => (
        $e1.into_iter().max()
    );
    ($e1: expr, $e2: expr) => (
        ::std::cmp::max($e1, $e2)
    );
    ($e1: expr, $e2: expr, $($e: expr),+) => (
        max!(::std::cmp::max($e1, $e2), $($e),+)
    )
}


/// ```
/// #[macro_use] extern crate fera_fun;
/// use fera_fun::vec;
///
/// # fn main() {
/// assert_eq!(vec![1, 4, 5], vec(chain!(1..2, 4..6)));
/// assert_eq!(vec![1, 4, 5, 8, 9], vec(chain!(1..2, 4..6, 8..10)));
/// # }
/// ```
#[macro_export]
macro_rules! chain {
    ($e1: expr, $e2: expr) => (
        $crate::chain($e1, $e2)
    );
    ($e1: expr, $e2: expr, $($e: expr),+) => (
        chain!($crate::chain($e1, $e2), $($e),+)
    )
}