MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / check_interval_value_and_unit

Function check_interval_value_and_unit

crates/gitql-parser/src/parse_interval.rs:316–341  ·  view source on GitHub ↗
(
    is_used_twice: &mut bool,
    interval_value: i64,
    unit_name: &str,
    location: &SourceLocation,
)

Source from the content-addressed store, hash-verified

314}
315
316fn check_interval_value_and_unit(
317 is_used_twice: &mut bool,
318 interval_value: i64,
319 unit_name: &str,
320 location: &SourceLocation,
321) -> Result<(), Box<Diagnostic>> {
322 if !*is_used_twice {
323 *is_used_twice = true;
324 return Ok(());
325 }
326
327 if !(-INTERVAL_MAX_VALUE..=INTERVAL_MAX_VALUE).contains(&interval_value) {
328 return Err(Diagnostic::error(&format!(
329 "Interval value for unit `{unit_name}` is out of the range",
330 ))
331 .add_help("Interval value must be in range from -170_000_000 to 170_000_000")
332 .with_location(*location)
333 .as_boxed());
334 }
335
336 Err(Diagnostic::error(&format!(
337 "Can't use the same interval unit `{unit_name}` twice",
338 ))
339 .with_location(*location)
340 .as_boxed())
341}
342
343#[cfg(test)]
344mod tests {

Callers 1

parse_interval_literalFunction · 0.85

Calls 4

containsMethod · 0.80
as_boxedMethod · 0.80
with_locationMethod · 0.80
add_helpMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…