A utility for guarding against stack overflows in the SQL parser. Usage: ``` use spacetimedb_sql_parser::parser::recursion; let mut depth = 0; assert!(recursion::guard(depth, 10, "test").is_ok()); ```
(depth: usize, limit: usize, source: &'static str)
| 18 | /// assert!(recursion::guard(depth, 10, "test").is_ok()); |
| 19 | /// ``` |
| 20 | pub fn guard(depth: usize, limit: usize, source: &'static str) -> Result<(), SqlParseError> { |
| 21 | if depth > limit { |
| 22 | Err(RecursionError { source_: source }.into()) |
| 23 | } else { |
| 24 | Ok(()) |
| 25 | } |
| 26 | } |
searching dependent graphs…