]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/ty/binding.rs
Merge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree
[rust.git] / compiler / rustc_middle / src / ty / binding.rs
1 use rustc_hir::BindingAnnotation;
2 use rustc_hir::BindingAnnotation::*;
3 use rustc_hir::Mutability;
4
5 #[derive(Clone, PartialEq, TyEncodable, TyDecodable, Debug, Copy, HashStable)]
6 pub enum BindingMode {
7     BindByReference(Mutability),
8     BindByValue(Mutability),
9 }
10
11 TrivialTypeFoldableAndLiftImpls! { BindingMode, }
12
13 impl BindingMode {
14     pub fn convert(ba: BindingAnnotation) -> BindingMode {
15         match ba {
16             Unannotated => BindingMode::BindByValue(Mutability::Not),
17             Mutable => BindingMode::BindByValue(Mutability::Mut),
18             Ref => BindingMode::BindByReference(Mutability::Not),
19             RefMut => BindingMode::BindByReference(Mutability::Mut),
20         }
21     }
22 }