wrapped-list

Build Crate License

This crate provides macros which allow you to create lists of elements that are wrappped by an object, function, or another macro at compile time. Check out the documentation.

rust wrapped_list![Box::new; value_1, value_2, ...]

Expands to:

rust [Box::new(value_1), Box::new(value_2), ...]

With this you can:

Examples

Wrap values with a tuple struct or enum

```rust use wrappedlist::wrappedlist;

[derive(Debug, PartialEq, Eq)]

struct Wrapper(i32);

let wrappeditems = wrappedlist![Wrapper; 1, 2, 3, 4];

asserteq!(wrappeditems, [Wrapper(1), Wrapper(2), Wrapper(3), Wrapper(4)]); ```

Wrap values with an object or function

```rust use wrappedlist::wrappedlist;

let boxeditems = wrappedlist![Box::new; 1, 2, 3];

asserteq!(boxeditems, [Box::new(1), Box::new(2), Box::new(3)]) ```

```rust use wrappedlist::wrappedlist;

let func = |x| x * 2;

let doubled = wrapped_list![func; 1, 2, 3];

assert_eq!(doubled, [2, 4, 6]); ```

Wrap values with a macro

```rust use wrappedlist::wrappedlist;

macrorules! addone { ($e:expr) => { $e + 1 }; }

let onemore = wrappedlist![add_one!; 1, 2, 3];

asserteq!(onemore, [2, 3, 4]); ```