Skip to content

Commit

Permalink
Favor vec![] over Vec::new
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 5, 2023
1 parent 6f6bec5 commit 2bea14e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl ToTokens for Func {
}

fn parse_signature(input: &mut TokenIter) -> Vec<TokenTree> {
let mut sig = Vec::new();
let mut sig = vec![];
let mut has_const = false;
loop {
match input.peek() {
Expand Down Expand Up @@ -82,7 +82,7 @@ fn parse_signature(input: &mut TokenIter) -> Vec<TokenTree> {
}

fn parse_attrs(input: &mut TokenIter) -> Result<Vec<Attribute>> {
let mut attrs = Vec::new();
let mut attrs = vec![];
loop {
let pound_token = match input.peek() {
Some(TokenTree::Punct(p)) if p.as_char() == '#' => input.next().unwrap(),
Expand Down
8 changes: 4 additions & 4 deletions test_suite/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ pub mod version {
fn test() {
assert!(const_min("variables") == "variables");
assert_eq!(const_let("variables"), "variables");
assert_eq!(const_vec_new::<u8>(), Vec::new());
assert_eq!(const_vec_new::<u8>(), vec![]);
assert_eq!(const_match(1), Some(1));
assert_eq!(A::const_fn_trait_bound(const_vec_new::<u8>()), A(Vec::new()));
assert_eq!(A::const_fn_trait_bound(const_vec_new::<u8>()), A(vec![]));
}
}

Expand Down Expand Up @@ -241,9 +241,9 @@ pub mod cfg {
fn test() {
assert!(const_min("variables") == "variables");
assert_eq!(const_let("variables"), "variables");
assert_eq!(const_vec_new::<u8>(), Vec::new());
assert_eq!(const_vec_new::<u8>(), vec![]);
assert_eq!(const_match(1), Some(1));
assert_eq!(A::const_fn_trait_bound(const_vec_new::<u8>()), A(Vec::new()));
assert_eq!(A::const_fn_trait_bound(const_vec_new::<u8>()), A(vec![]));
}
}

Expand Down

0 comments on commit 2bea14e

Please sign in to comment.