Add and use stability helper methods
This avoids an ambiguity (when reading) where `.level.is_stable()` is not immediately clear whether it is general stability or const stability.
This commit is contained in:
parent
f53fc41cfc
commit
a9dd4cfa6b
8 changed files with 30 additions and 15 deletions
|
@ -101,6 +101,16 @@ pub struct Stability {
|
|||
pub feature: Symbol,
|
||||
}
|
||||
|
||||
impl Stability {
|
||||
pub fn is_unstable(&self) -> bool {
|
||||
self.level.is_unstable()
|
||||
}
|
||||
|
||||
pub fn is_stable(&self) -> bool {
|
||||
self.level.is_stable()
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
|
||||
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(HashStable_Generic)]
|
||||
|
@ -111,6 +121,16 @@ pub struct ConstStability {
|
|||
pub promotable: bool,
|
||||
}
|
||||
|
||||
impl ConstStability {
|
||||
pub fn is_const_unstable(&self) -> bool {
|
||||
self.level.is_unstable()
|
||||
}
|
||||
|
||||
pub fn is_const_stable(&self) -> bool {
|
||||
self.level.is_stable()
|
||||
}
|
||||
}
|
||||
|
||||
/// The available stability levels.
|
||||
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
|
||||
#[derive(HashStable_Generic)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue