euclid/
macros.rs

1// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10macro_rules! mint_vec {
11    ($name:ident [ $($field:ident),* ] = $std_name:ident) => {
12        #[cfg(feature = "mint")]
13        impl<T, U> From<mint::$std_name<T>> for $name<T, U> {
14            fn from(v: mint::$std_name<T>) -> Self {
15                $name {
16                    $( $field: v.$field, )*
17                    _unit: PhantomData,
18                }
19            }
20        }
21        #[cfg(feature = "mint")]
22        impl<T, U> Into<mint::$std_name<T>> for $name<T, U> {
23            fn into(self) -> mint::$std_name<T> {
24                mint::$std_name {
25                    $( $field: self.$field, )*
26                }
27            }
28        }
29    }
30}