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

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

CloneTypeFoldableAndLiftImpls! { BindingMode, }

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