mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
ProgramBuilder: add resolve_cursor_id_safe() which doesn't unwrap
This commit is contained in:
parent
5a1cfb7d15
commit
1fe1f0ebba
1 changed files with 10 additions and 8 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue