1
Fork 0

Add some convenience helper methods on hir::Safety

This commit is contained in:
Oli Scherer 2024-12-13 12:19:46 +00:00
parent 3a64bef2ba
commit 8a4e5d7444
27 changed files with 72 additions and 68 deletions

View file

@ -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()
}
}