1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Replace Id::null() with Id::NULL (#3544)

Shorter and more idiomatic
This commit is contained in:
Emil Ernerfeldt
2023-11-11 21:40:02 +01:00
committed by GitHub
parent b27aa27e94
commit 6ba356d3d8
6 changed files with 17 additions and 20 deletions

View File

@@ -13,11 +13,11 @@ pub(crate) struct TooltipState {
impl TooltipState {
pub fn load(ctx: &Context) -> Option<Self> {
ctx.data_mut(|d| d.get_temp(Id::null()))
ctx.data_mut(|d| d.get_temp(Id::NULL))
}
fn store(self, ctx: &Context) {
ctx.data_mut(|d| d.insert_temp(Id::null(), self));
ctx.data_mut(|d| d.insert_temp(Id::NULL, self));
}
fn individual_tooltip_size(&self, common_id: Id, index: usize) -> Option<Vec2> {

View File

@@ -35,6 +35,9 @@ impl Id {
///
/// The null [`Id`] is still a valid id to use in all circumstances,
/// though obviously it will lead to a lot of collisions if you do use it!
pub const NULL: Self = Self(0);
#[deprecated = "Use Id::NULL"]
pub fn null() -> Self {
Self(0)
}

View File

@@ -442,5 +442,5 @@ fn color_cache_set(ctx: &Context, rgba: impl Into<Rgba>, hsva: Hsva) {
// To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
fn use_color_cache<R>(ctx: &Context, f: impl FnOnce(&mut FixedCache<Rgba, Hsva>) -> R) -> R {
ctx.data_mut(|d| f(d.get_temp_mut_or_default(Id::null())))
ctx.data_mut(|d| f(d.get_temp_mut_or_default(Id::NULL)))
}