(Maybe) fix macro compatibility for older Rusts

This commit is contained in:
Magnus Hallin 2017-02-04 11:52:27 +01:00
parent 3d8f88f59e
commit 90054cf9d1
2 changed files with 8 additions and 4 deletions

View file

@ -2,14 +2,16 @@ language: rust
cache: cargo
rust:
- stable
- beta
- nightly
# The five most recent stable releases before "stable"
- 1.10.0
- 1.11.0
- 1.12.1
- 1.13.0
- 1.14.0
- stable
- beta
- nightly
matrix:
allow_failures:

View file

@ -38,6 +38,8 @@ usable as arguments and default values.
*/
#[macro_export]
macro_rules! graphql_scalar {
( @as_expr, $e:expr) => { $e };
// Calls $val.$func($arg) if $arg is not None
( @maybe_apply, None, $func:ident, $val:expr ) => { $val };
( @maybe_apply, $arg:tt, $func:ident, $val:expr ) => { $val.$func($arg) };
@ -65,7 +67,7 @@ macro_rules! graphql_scalar {
type Context = ();
fn name() -> Option<&'static str> {
Some($outname)
Some(graphql_scalar!( @as_expr, $outname ))
}
fn meta<'r>(registry: &mut $crate::Registry<'r>) -> $crate::meta::MetaType<'r> {