diff --git a/README.md b/README.md index 779893c..f78ce95 100644 --- a/README.md +++ b/README.md @@ -288,8 +288,7 @@ assert_eq!(*unshared_vec[0].borrow(), 1); assert_eq!(*unshared_vec[1].borrow(), 0); ``` -You can also use the macro with a list of elements, like `vec!`, -though `vec!` is probably faster: +You can also use the macro with a list of elements, like `vec!`: ```rust use map_macro::vec_no_clone; diff --git a/TODO.md b/TODO.md index 1883cba..a4acaba 100644 --- a/TODO.md +++ b/TODO.md @@ -25,3 +25,9 @@ * [x] documentation * [x] publish `v0.2.2` + +* [x] `vec_no_clone` fallback to `vec` + +* [ ] `btree_map` + +* [ ] `btree_set` diff --git a/src/lib.rs b/src/lib.rs index 348e191..e0155c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,11 +101,6 @@ macro_rules! set { /// #[macro_export] macro_rules! vec_no_clone { - (@to_unit $($_:tt)*) => (()); - (@count $($tail:expr),*) => ( - <[()]>::len(&[$(vec_no_clone!(@to_unit $tail)),*]) - ); - {$v: expr; $c: expr} => { { let mut vec = Vec::with_capacity($c); @@ -119,15 +114,7 @@ macro_rules! vec_no_clone { }; {$($v: expr),* $(,)?} => { { - let mut vec = Vec::with_capacity( - vec_no_clone!(@count $($v),*), - ); - - $( - vec.push($v); - )* - - vec + vec![$($v),*] } }; }