1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! See [llama-cpp-2](https://crates.io/crates/llama-cpp-2) for a documented and safe API.

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

use std::fmt::{Debug, Formatter};
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

impl Debug for llama_grammar_element {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        fn type_to_str(r#type: llama_gretype) -> &'static str {
            match r#type {
                LLAMA_GRETYPE_END => "END",
                LLAMA_GRETYPE_ALT => "ALT",
                LLAMA_GRETYPE_RULE_REF => "RULE_REF",
                LLAMA_GRETYPE_CHAR => "CHAR",
                LLAMA_GRETYPE_CHAR_NOT => "CHAR_NOT",
                LLAMA_GRETYPE_CHAR_RNG_UPPER => "CHAR_RNG_UPPER",
                LLAMA_GRETYPE_CHAR_ALT => "CHAR_ALT",
                _ => "Unknown",
            }
        }

        f.debug_struct("llama_grammar_element")
            .field("type", &type_to_str(self.type_))
            .field("value", &self.value)
            .finish()
    }
}