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 #[stable(feature = "rust1", since = "1.0.0")]
17 impl<'a> $imp for &'a $t {
18 type Output = <$t as $imp>::Output;
21 fn $method(self) -> <$t as $imp>::Output {
28 // implements binary operators "&T op U", "T op &U", "&T op &U"
29 // based on "T op U" where T and U are expected to be `Copy`able
30 macro_rules! forward_ref_binop {
31 (impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
32 #[stable(feature = "rust1", since = "1.0.0")]
33 impl<'a> $imp<$u> for &'a $t {
34 type Output = <$t as $imp<$u>>::Output;
37 fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
38 $imp::$method(*self, other)
42 #[stable(feature = "rust1", since = "1.0.0")]
43 impl<'a> $imp<&'a $u> for $t {
44 type Output = <$t as $imp<$u>>::Output;
47 fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
48 $imp::$method(self, *other)
52 #[stable(feature = "rust1", since = "1.0.0")]
53 impl<'a, 'b> $imp<&'a $u> for &'b $t {
54 type Output = <$t as $imp<$u>>::Output;
57 fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
58 $imp::$method(*self, *other)