add stable_since convenience
This commit is contained in:
@@ -80,6 +80,10 @@ impl Stability {
|
|||||||
pub fn is_stable(&self) -> bool {
|
pub fn is_stable(&self) -> bool {
|
||||||
self.level.is_stable()
|
self.level.is_stable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn stable_since(&self) -> Option<StableSince> {
|
||||||
|
self.level.stable_since()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
|
/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
|
||||||
@@ -170,6 +174,12 @@ impl StabilityLevel {
|
|||||||
pub fn is_stable(&self) -> bool {
|
pub fn is_stable(&self) -> bool {
|
||||||
matches!(self, StabilityLevel::Stable { .. })
|
matches!(self, StabilityLevel::Stable { .. })
|
||||||
}
|
}
|
||||||
|
pub fn stable_since(&self) -> Option<StableSince> {
|
||||||
|
match *self {
|
||||||
|
StabilityLevel::Stable { since, .. } => Some(since),
|
||||||
|
StabilityLevel::Unstable { .. } => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
|
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
|
||||||
|
|||||||
@@ -638,10 +638,7 @@ impl Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<StableSince> {
|
pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<StableSince> {
|
||||||
match self.stability(tcx)?.level {
|
self.stability(tcx).and_then(|stability| stability.stable_since())
|
||||||
StabilityLevel::Stable { since, .. } => Some(since),
|
|
||||||
StabilityLevel::Unstable { .. } => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_non_exhaustive(&self) -> bool {
|
pub(crate) fn is_non_exhaustive(&self) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user