Skip to content

Commit

Permalink
Use FromIterator<_> for TokenStream
Browse files Browse the repository at this point in the history
Also remove conservative_impl_trait feature flag, as this is now a
stable feature.

Refs lambda-fairy#121
  • Loading branch information
anxiousmodernman committed Apr 16, 2018
1 parent 0f453a5 commit 2d6558c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
1 change: 0 additions & 1 deletion maud/tests/control_structures.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(conservative_impl_trait)]
#![feature(plugin)]
#![feature(proc_macro)]

Expand Down
10 changes: 1 addition & 9 deletions maud_macros/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@ impl Builder {
/// Reifies the `Builder` into a raw list of statements.
pub fn build(mut self) -> TokenStream {
let Builder { stmts, .. } = { self.flush(); self };

// use a Group here?
let mut tts: Vec<TokenTree> = Vec::new();
for s in stmts.into_iter() {
let i = s.into_iter();
tts.extend(i);
}

tts.into_iter().collect()
stmts.into_iter().collect()
}

/// Pushes a statement, flushing the tail buffer in the process.
Expand Down
10 changes: 5 additions & 5 deletions maud_macros/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use proc_macro::{
};

use proc_macro::token_stream;
use std::iter;
use std::mem;

use literalext::LiteralExt;
Expand Down Expand Up @@ -302,14 +303,14 @@ impl Parser {
}

fn match_arms(&mut self) -> ParseResult<TokenStream> {
let mut arms: Vec<TokenTree> = Vec::new();
let mut arms = Vec::new();
while let Some(arm) = self.match_arm()? {
arms.extend(arm);
arms.push(arm);
}
Ok(arms.into_iter().collect())
}

fn match_arm(&mut self) -> ParseResult<Option<Vec<TokenTree>>> {
fn match_arm(&mut self) -> ParseResult<Option<TokenStream>> {
let mut pat: Vec<TokenTree> = Vec::new();
loop {
match self.peek2() {
Expand Down Expand Up @@ -364,8 +365,7 @@ impl Parser {
},
None => return self.error("unexpected end of @match arm"),
};
pat.push(body);
Ok(Some(pat))
Ok(Some(pat.into_iter().chain(iter::once(body)).collect()))
}

/// Parses and renders a `@let` expression.
Expand Down

0 comments on commit 2d6558c

Please sign in to comment.