Skip to content

Commit 0a32537

Browse files
fix use-after-free in debug tools
1 parent 166604a commit 0a32537

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/id.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ pub struct Id {
88
impl Id {
99
/// Creates a clay id using the `label`
1010
#[inline]
11-
pub(crate) fn new(label: &str) -> Id {
11+
pub(crate) fn new(label: &'static str) -> Id {
1212
Self::new_index(label, 0)
1313
}
1414

1515
/// Creates a clay id using the `label` and the `index`
1616
#[inline]
17-
pub(crate) fn new_index(label: &str, index: u32) -> Id {
17+
pub(crate) fn new_index(label: &'static str, index: u32) -> Id {
1818
Self::new_index_internal(label, index)
1919
}
2020

2121
#[inline]
22-
pub(crate) fn new_index_internal(label: &str, index: u32) -> Id {
22+
pub(crate) fn new_index_internal(label: &'static str, index: u32) -> Id {
2323
let id = unsafe { Clay__HashString(label.into(), index, 0) };
2424
Id { id }
2525
}
2626

2727
#[inline]
28-
pub(crate) fn new_index_local(label: &str, index: u32) -> Id {
28+
pub(crate) fn new_index_local(label: &'static str, index: u32) -> Id {
2929
let id = unsafe { Clay__HashString(label.into(), index, Clay__GetParentElementId()) };
3030
Id { id }
3131
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,31 +374,31 @@ impl Clay {
374374
///
375375
/// This ID is global and must be unique across the entire scope.
376376
#[inline]
377-
pub fn id(&self, label: &str) -> id::Id {
377+
pub fn id(&self, label: &'static str) -> id::Id {
378378
id::Id::new(label)
379379
}
380380

381381
/// Generates a unique indexed ID based on the given `label` and `index`.
382382
///
383383
/// This is useful when multiple elements share the same label but need distinct IDs.
384384
#[inline]
385-
pub fn id_index(&self, label: &str, index: u32) -> id::Id {
385+
pub fn id_index(&self, label: &'static str, index: u32) -> id::Id {
386386
id::Id::new_index(label, index)
387387
}
388388

389389
/// Generates a locally unique ID based on the given `label`.
390390
///
391391
/// The ID is unique within a specific local scope but not globally.
392392
#[inline]
393-
pub fn id_local(&self, label: &str) -> id::Id {
393+
pub fn id_local(&self, label: &'static str) -> id::Id {
394394
id::Id::new_index_local(label, 0)
395395
}
396396

397397
/// Generates a locally unique indexed ID based on the given `label` and `index`.
398398
///
399399
/// This is useful for differentiating elements within a local scope while keeping their labels consistent.
400400
#[inline]
401-
pub fn id_index_local(&self, label: &str, index: u32) -> id::Id {
401+
pub fn id_index_local(&self, label: &'static str, index: u32) -> id::Id {
402402
id::Id::new_index_local(label, index)
403403
}
404404

0 commit comments

Comments
 (0)