1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
pub mod rng; /// Combines the array literal with `.into()`. /// # Examples /// ``` /// use tb::array_from; /// let a: &[String] = &array_from!["a", "b", "c", "d"]; /// ``` #[macro_export] macro_rules! array_from { ($($item:expr),* $(,)?) => {[$($item.into(),)*]} } /// Combines the vector literal with `.into()`. /// # Examples /// ``` /// use tb::vec_from; /// let a: Vec<String> = vec_from!["a", "b", "c", "d"]; /// ``` #[macro_export] macro_rules! vec_from { ($($item:expr),* $(,)?) => {vec![$($item.into(),)*]} } /// Literal for `LinkedList`. /// # Examples /// ``` /// use std::collections::LinkedList; /// use literal::list; /// /// let a: LinkedList<i32> = list![1, 2, 3, 4]; #[macro_export] macro_rules! list { ($($item:expr),* $(,)?) => {{ let mut _list = LinkedList::new(); $(_list.push_back($item);)* _list }} } /// Combines the list literal with `.into()`. /// # Examples /// ``` /// use std::collections::LinkedList; /// use literal::list_from; /// /// let a: LinkedList<String> = list_from!["a", "b", "c", "d"]; /// ``` #[macro_export] macro_rules! list_from { ($($item:expr),* $(,)?) => {{ let mut _list = LinkedList::new(); $(_list.push_back($item.into());)* _list }} }