summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/ty/binding.rs
blob: af594bc5f24c8517d592ce5118395adbba4d2f65 (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),
}

TrivialTypeTraversalImpls! { 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),
        }
    }
}