2020-01-05 02:37:57 +01:00
|
|
|
use rustc_hir::BindingAnnotation;
|
|
|
|
use rustc_hir::BindingAnnotation::*;
|
|
|
|
use rustc_hir::Mutability;
|
2017-07-21 19:29:43 -04:00
|
|
|
|
2020-06-11 15:49:57 +01:00
|
|
|
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Debug, Copy, HashStable)]
|
2017-07-21 19:29:43 -04:00
|
|
|
pub enum BindingMode {
|
|
|
|
BindByReference(Mutability),
|
|
|
|
BindByValue(Mutability),
|
|
|
|
}
|
|
|
|
|
2020-10-24 09:27:15 +02:00
|
|
|
TrivialTypeFoldableAndLiftImpls! { BindingMode, }
|
2018-06-07 15:25:08 +02:00
|
|
|
|
2017-07-21 19:29:43 -04:00
|
|
|
impl BindingMode {
|
|
|
|
pub fn convert(ba: BindingAnnotation) -> BindingMode {
|
|
|
|
match ba {
|
2019-12-16 17:28:40 +01:00
|
|
|
Unannotated => BindingMode::BindByValue(Mutability::Not),
|
|
|
|
Mutable => BindingMode::BindByValue(Mutability::Mut),
|
|
|
|
Ref => BindingMode::BindByReference(Mutability::Not),
|
|
|
|
RefMut => BindingMode::BindByReference(Mutability::Mut),
|
2017-07-21 19:29:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|