blob: 820941f9f505b99c7d98f8a5688a436a837ee5a0 [file] [log] [blame]
David Tolnay55535012018-01-05 16:39:23 -08001// Copyright 2018 Syn Developers
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
David Tolnaydd125562017-12-31 02:16:22 -05009#[macro_export]
10macro_rules! errorf {
11 ($($tt:tt)*) => {{
12 use ::std::io::Write;
13 let stderr = ::std::io::stderr();
14 write!(stderr.lock(), $($tt)*).unwrap();
15 }};
16}
17
18#[macro_export]
David Tolnayf2cfd722017-12-31 18:02:51 -050019macro_rules! punctuated {
David Tolnaya0834b42018-01-01 21:30:02 -080020 ($($e:expr,)+) => {{
David Tolnayf2cfd722017-12-31 18:02:51 -050021 let mut seq = ::syn::punctuated::Punctuated::new();
David Tolnaydd125562017-12-31 02:16:22 -050022 $(
David Tolnaya0834b42018-01-01 21:30:02 -080023 seq.push($e);
24 )+
David Tolnayf2cfd722017-12-31 18:02:51 -050025 seq
David Tolnaydd125562017-12-31 02:16:22 -050026 }};
27
28 ($($e:expr),+) => {
David Tolnayf2cfd722017-12-31 18:02:51 -050029 punctuated!($($e,)+)
David Tolnaydd125562017-12-31 02:16:22 -050030 };
31}