]>
git.proxmox.com Git - rustc.git/blob - src/librustc_mir/hair/cx/to_ref.rs
1 // Copyright 2015 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.
18 fn to_ref(self) -> Self::Output
;
21 impl<'a
,'tcx
:'a
> ToRef
for &'tcx hir
::Expr
{
22 type Output
= ExprRef
<'tcx
>;
24 fn to_ref(self) -> ExprRef
<'tcx
> {
29 impl<'a
,'tcx
:'a
> ToRef
for &'tcx P
<hir
::Expr
> {
30 type Output
= ExprRef
<'tcx
>;
32 fn to_ref(self) -> ExprRef
<'tcx
> {
33 ExprRef
::Hair(&**self)
37 impl<'a
,'tcx
:'a
> ToRef
for Expr
<'tcx
> {
38 type Output
= ExprRef
<'tcx
>;
40 fn to_ref(self) -> ExprRef
<'tcx
> {
41 ExprRef
::Mirror(Box
::new(self))
45 impl<'a
,'tcx
:'a
,T
,U
> ToRef
for &'tcx Option
<T
>
46 where &'tcx T
: ToRef
<Output
=U
>
48 type Output
= Option
<U
>;
50 fn to_ref(self) -> Option
<U
> {
51 self.as_ref().map(|expr
| expr
.to_ref())
55 impl<'a
,'tcx
:'a
,T
,U
> ToRef
for &'tcx Vec
<T
>
56 where &'tcx T
: ToRef
<Output
=U
>
60 fn to_ref(self) -> Vec
<U
> {
61 self.iter().map(|expr
| expr
.to_ref()).collect()
65 impl<'a
,'tcx
:'a
,T
,U
> ToRef
for &'tcx P
<[T
]>
66 where &'tcx T
: ToRef
<Output
=U
>
70 fn to_ref(self) -> Vec
<U
> {
71 self.iter().map(|expr
| expr
.to_ref()).collect()