INNER CODE UNIT · Rust
pick
apache/datafusion-sqlparser-rs · fuzz/fuzz_targets/expression/mod.rs:93
fn pick(table: &'static [&'static str], index: u8) -> &'static str {
table[usize::from(index) % table.len()]
}
impl Chain {
/// Writes the chain as SQL text in the tokens of `grammar`.
pub fn render(&self, grammar: &Grammar) -> String {
let mut out = String::new();
self.write(grammar, 0, &mut out);
out
}
fn write(&self, grammar: &Grammar, depth: usize, out: &mut String) {
self.first.write(grammar, depth, out);
for (infix, operand) in &self.rest {
let gap = if infix.tight { "" } else { " " };
let _ = write!(out, "{gap}{}{gap}", pick(grammar.infix, infix.op));
operand.write(grammar, depth, out);