Add assertion forbidding duplicate cursor keys

This commit is contained in:
Jussi Saurio 2025-05-29 01:04:45 +03:00
parent 77ce4780d9
commit 592ba41137

View file

@ -249,6 +249,13 @@ impl ProgramBuilder {
}
pub fn alloc_cursor_id_keyed(&mut self, key: CursorKey, cursor_type: CursorType) -> usize {
assert!(
!self
.cursor_ref
.iter()
.any(|(k, _)| k.as_ref().map_or(false, |k| k.equals(&key))),
"duplicate cursor key"
);
self._alloc_cursor_id(Some(key), cursor_type)
}