Add some convenience helper methods on hir::Safety
This commit is contained in:
parent
3a64bef2ba
commit
8a4e5d7444
27 changed files with 72 additions and 68 deletions
|
@ -3401,6 +3401,19 @@ impl Safety {
|
|||
Self::Safe => "",
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_unsafe(self) -> bool {
|
||||
!self.is_safe()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_safe(self) -> bool {
|
||||
match self {
|
||||
Self::Unsafe => false,
|
||||
Self::Safe => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Safety {
|
||||
|
@ -3445,7 +3458,7 @@ impl FnHeader {
|
|||
}
|
||||
|
||||
pub fn is_unsafe(&self) -> bool {
|
||||
matches!(&self.safety, Safety::Unsafe)
|
||||
self.safety.is_unsafe()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue