about summary refs log tree commit diff
path: root/src/librustc/ty/binding.rs
blob: 1290141b0a6b03314f3651a1dfd791bd12950845 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::hir::BindingAnnotation::*;
use crate::hir::BindingAnnotation;
use crate::hir::Mutability;

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum BindingMode {
    BindByReference(Mutability),
    BindByValue(Mutability),
}

CloneTypeFoldableAndLiftImpls! { BindingMode, }

impl BindingMode {
    pub fn convert(ba: BindingAnnotation) -> BindingMode {
        match ba {
            Unannotated => BindingMode::BindByValue(Mutability::MutImmutable),
            Mutable => BindingMode::BindByValue(Mutability::MutMutable),
            Ref => BindingMode::BindByReference(Mutability::MutImmutable),
            RefMut => BindingMode::BindByReference(Mutability::MutMutable),
        }
    }
}

impl_stable_hash_for!(enum self::BindingMode {
    BindByReference(mutability),
    BindByValue(mutability)
});