From c66aa6efbb74097e142490fa6fd6930373cdf03d Mon Sep 17 00:00:00 2001 From: meh Date: Mon, 26 Oct 2015 20:25:44 +0100 Subject: [PATCH] util/dictionary: add a dict! macro to create a dictionary --- src/lib.rs | 1 + src/util/dictionary/mod.rs | 14 ++++++++++++++ src/util/mod.rs | 1 + 3 files changed, 16 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2233e8f..91d89cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ extern crate ffmpeg_sys as sys; pub use sys as ffi; +#[macro_use] pub mod util; pub use util::error::Error; pub use util::dictionary; diff --git a/src/util/dictionary/mod.rs b/src/util/dictionary/mod.rs index 60dec26..3c0e16a 100644 --- a/src/util/dictionary/mod.rs +++ b/src/util/dictionary/mod.rs @@ -9,3 +9,17 @@ pub use self::owned::Owned; mod iter; pub use self::iter::Iter; + +#[macro_export] +macro_rules! dict { + ( $($key:expr => $value:expr),* $(,)*) => ({ + let mut dict = ::ffmpeg::Dictionary::new(); + + $( + dict.set($key, $value); + )* + + dict + } + ); +} diff --git a/src/util/mod.rs b/src/util/mod.rs index db3b92c..252f51f 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -1,3 +1,4 @@ +#[macro_use] pub mod dictionary; pub mod error; pub mod rational;