diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-23 18:22:51 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-23 20:26:31 +0000 |
| commit | da40965300eec9aad4ea2f2fde9e6b59262cd5d6 (patch) | |
| tree | 57171d455fea2007b2cf5e7fc710ae71d47e7028 /compiler/rustc_ast | |
| parent | 9b9c7d0ecc9d902b3ed5eac2f06f8669fed57f43 (diff) | |
| download | rust-da40965300eec9aad4ea2f2fde9e6b59262cd5d6.tar.gz rust-da40965300eec9aad4ea2f2fde9e6b59262cd5d6.zip | |
Add `Mutability::{is_mut,is_not}`
Diffstat (limited to 'compiler/rustc_ast')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 0567bb5a6c9..146fe7cd593 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -803,6 +803,16 @@ impl Mutability { Mutability::Mut => "&mut ", } } + + /// Return `true` if self is mutable + pub fn is_mut(self) -> bool { + matches!(self, Self::Mut) + } + + /// Return `true` if self is **not** mutable + pub fn is_not(self) -> bool { + matches!(self, Self::Not) + } } /// The kind of borrow in an `AddrOf` expression, |
