1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 // implements the unary operator "op &T"
13 // based on "op T" where T is expected to be `Copy`able
14 macro_rules! forward_ref_unop {
15 (impl $imp:ident, $method:ident for $t:ty) => {
16 forward_ref_unop!(impl $imp, $method for $t,
17 #[stable(feature = "rust1", since = "1.0.0")]);
19 (impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => {
21 impl<'a> $imp for &'a $t {
22 type Output = <$t as $imp>::Output;
25 fn $method(self) -> <$t as $imp>::Output {
32 // implements binary operators "&T op U", "T op &U", "&T op &U"
33 // based on "T op U" where T and U are expected to be `Copy`able
34 macro_rules! forward_ref_binop {
35 (impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
36 forward_ref_binop!(impl $imp, $method for $t, $u,
37 #[stable(feature = "rust1", since = "1.0.0")]);
39 (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
41 impl<'a> $imp<$u> for &'a $t {
42 type Output = <$t as $imp<$u>>::Output;
45 fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
46 $imp::$method(*self, other)
51 impl<'a> $imp<&'a $u> for $t {
52 type Output = <$t as $imp<$u>>::Output;
55 fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
56 $imp::$method(self, *other)
61 impl<'a, 'b> $imp<&'a $u> for &'b $t {
62 type Output = <$t as $imp<$u>>::Output;
65 fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
66 $imp::$method(*self, *other)