ProgramBuilder: add resolve_cursor_id_safe() which doesn't unwrap

This commit is contained in:
Jussi Saurio 2025-04-15 13:16:28 +03:00
parent 5a1cfb7d15
commit 1fe1f0ebba

View file

@ -441,15 +441,17 @@ impl ProgramBuilder {
}
// translate table to cursor id
pub fn resolve_cursor_id_safe(&self, table_identifier: &str) -> Option<CursorID> {
self.cursor_ref.iter().position(|(t_ident, _)| {
t_ident
.as_ref()
.is_some_and(|ident| ident == table_identifier)
})
}
pub fn resolve_cursor_id(&self, table_identifier: &str) -> CursorID {
self.cursor_ref
.iter()
.position(|(t_ident, _)| {
t_ident
.as_ref()
.is_some_and(|ident| ident == table_identifier)
})
.unwrap()
self.resolve_cursor_id_safe(table_identifier)
.unwrap_or_else(|| panic!("Cursor not found: {}", table_identifier))
}
pub fn build(