pub enum LazyLayoutKey {
User(u64),
Index(usize),
}Expand description
Key type for lazy list items.
Separates user-provided keys from default index-based keys to prevent collisions.
This matches JC’s getDefaultLazyLayoutKey() pattern where a wrapper type
(DefaultLazyKey) ensures default keys never collide with user-provided keys.
§JC Reference
LazyLayoutIntervalContent.getKey()returnscontent.key?.invoke(localIndex) ?: getDefaultLazyLayoutKey(index)Lazy.android.ktdefinesDefaultLazyKey(index)as a wrapper data class
Variants§
User(u64)
User-provided key (from scope.item(key: Some(k), ...) or scope.items(key: Some(|i| ...), ...))
Index(usize)
Default key based on global index. Cannot collide with User keys due to enum separation.
Implementations§
Source§impl LazyLayoutKey
impl LazyLayoutKey
Sourcepub fn to_slot_id(self) -> u64
pub fn to_slot_id(self) -> u64
Converts to u64 for slot ID usage with guaranteed non-overlapping ranges.
§Encoding
Uses high 2 bits of the 64-bit slot ID as a type tag:
- User keys:
0b00tag + 62-bit value (range: 0x0000… - 0x3FFF…) - Index keys:
0b01tag + 62-bit value (range: 0x4000… - 0x7FFF…)
§⚠️ Large Key Handling
Values larger than 62 bits are mixed down to 62 bits. This avoids panics
for extreme indices (e.g. usize::MAX) but introduces a small chance of
collisions for out-of-range keys. Prefer keys that fit in 62 bits when
you need guaranteed collision-free IDs.
§Cross-Platform Safety
The slot ID is always u64 regardless of target platform.
Sourcepub fn is_user_key(self) -> bool
pub fn is_user_key(self) -> bool
Returns true if this is a user-provided key.
Sourcepub fn is_index_key(self) -> bool
pub fn is_index_key(self) -> bool
Returns true if this is a default index-based key.
Trait Implementations§
Source§impl Clone for LazyLayoutKey
impl Clone for LazyLayoutKey
Source§fn clone(&self) -> LazyLayoutKey
fn clone(&self) -> LazyLayoutKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more