1 //! In general, there are a number of things for which it's convenient
2 //! to just call `builder.into` and have it emit its result into a
3 //! given location. This is basically for expressions or things that can be
4 //! wrapped up as expressions (e.g., blocks). To make this ergonomic, we use this
5 //! latter `EvalInto` trait.
7 use build::{BlockAnd, Builder};
11 pub(in build) trait EvalInto<'tcx> {
12 fn eval_into<'a, 'gcx>(self,
13 builder: &mut Builder<'a, 'gcx, 'tcx>,
14 destination: &Place<'tcx>,
19 impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
20 pub fn into<E>(&mut self,
21 destination: &Place<'tcx>,
25 where E: EvalInto<'tcx>
27 expr.eval_into(self, destination, block)
31 impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> {
32 fn eval_into<'a, 'gcx>(self,
33 builder: &mut Builder<'a, 'gcx, 'tcx>,
34 destination: &Place<'tcx>,
37 let expr = builder.hir.mirror(self);
38 builder.into_expr(destination, block, expr)
42 impl<'tcx> EvalInto<'tcx> for Expr<'tcx> {
43 fn eval_into<'a, 'gcx>(self,
44 builder: &mut Builder<'a, 'gcx, 'tcx>,
45 destination: &Place<'tcx>,
48 builder.into_expr(destination, block, self)