summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/ty/binding.rs
blob: a5b05a4f9b526a01fbeb9c67e5106e3e5635006f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use rustc_hir::{BindingAnnotation, ByRef, Mutability};

#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Debug, Copy, HashStable)]
pub enum BindingMode {
    BindByReference(Mutability),
    BindByValue(Mutability),
}

TrivialTypeTraversalAndLiftImpls! { BindingMode, }

impl BindingMode {
    pub fn convert(BindingAnnotation(by_ref, mutbl): BindingAnnotation) -> BindingMode {
        match by_ref {
            ByRef::No => BindingMode::BindByValue(mutbl),
            ByRef::Yes => BindingMode::BindByReference(mutbl),
        }
    }
}