Skip to content

Add `array!` macro for creating inline `Array`s

Michael Aaron Murphy requested to merge huntergoldstein:array_macro into master

Created by: huntergoldstein

Problem: Writing Array::from_vec(vec![...]) is verbose and performs more computation than needed.

Solution: Add an array! macro that replaces any instance of Array::from_vec(vec![...]) with array![...]. Additionally it calls into on its elements, so instead of having to write:

Array::from_vec(vec!["foo".into(), "bar".into()])

it will be sufficient to write

array!["foo", "bar"]

Drawbacks: This creates an extra level of indirection: it is unclear what type the array! macro refers to. However I don't think it is any more indirection from before, where the Array type is just a SmallVec alias.

Merge request reports