From 75564b8439d237da9c3147704d5113de360d3e5f Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Wed, 15 Mar 2017 14:09:48 +0000 Subject: [PATCH] macros: Move the wrapping macro in a separate file Will be reused. --- src/cuda/device.rs | 10 ---------- src/lib.rs | 3 +++ src/macros.rs | 11 +++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 src/macros.rs diff --git a/src/cuda/device.rs b/src/cuda/device.rs index fa683b3..a984ef5 100644 --- a/src/cuda/device.rs +++ b/src/cuda/device.rs @@ -8,16 +8,6 @@ pub struct CuDevice { device: CUdevice, } -macro_rules! wrap { - ($val:ident, $res:ident) => ( - if $res == CUDA_SUCCESS { - Ok($val) - } else { - Err($res) - } - ) -} - impl CuDevice { pub fn new(ordinal: c_int) -> Result { let mut d = CuDevice { device: 0 }; diff --git a/src/lib.rs b/src/lib.rs index ed8124b..fbc3b29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ extern crate nvidia_video_codec_sys as ffi; +#[macro_use] +mod macros; + pub mod cuda; diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..ca521a0 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,11 @@ +macro_rules! wrap { + ($val:ident, $res:ident) => ( + if $res == CUDA_SUCCESS { + Ok($val) + } else { + Err($res) + } + ) +} + +