Simplify creation of AutoBorrowMutability
This commit is contained in:
parent
6486ba94a3
commit
f9a332a48c
5 changed files with 34 additions and 48 deletions
|
@ -159,6 +159,18 @@ pub enum AutoBorrowMutability {
|
|||
Not,
|
||||
}
|
||||
|
||||
impl AutoBorrowMutability {
|
||||
/// Creates an `AutoBorrowMutability` from a mutability and allowance of two phase borrows.
|
||||
///
|
||||
/// Note that when `mutbl.is_not()`, `allow_two_phase_borrow` is ignored
|
||||
pub fn new(mutbl: hir::Mutability, allow_two_phase_borrow: AllowTwoPhase) -> Self {
|
||||
match mutbl {
|
||||
hir::Mutability::Not => Self::Not,
|
||||
hir::Mutability::Mut => Self::Mut { allow_two_phase_borrow },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AutoBorrowMutability> for hir::Mutability {
|
||||
fn from(m: AutoBorrowMutability) -> Self {
|
||||
match m {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue