pub enum KeywordOrIdentifier {
Keyword(Keyword),
Identifier(Identifier),
}Expand description
Parse a keyword or identifier
This is the main entry point for lexing identifiers in PromQL. It first tries to match a keyword, and if that fails, parses as identifier.
§Examples
use rusty_promql_parser::lexer::identifier::{keyword_or_identifier, KeywordOrIdentifier, Keyword, Identifier};
// Keywords are recognized
let (_, result) = keyword_or_identifier("sum").unwrap();
assert_eq!(result, KeywordOrIdentifier::Keyword(Keyword::Sum));
// Regular identifiers
let (_, result) = keyword_or_identifier("http_requests").unwrap();
assert_eq!(result, KeywordOrIdentifier::Identifier(Identifier::Plain("http_requests".to_string())));
// Metric identifiers (with colon)
let (_, result) = keyword_or_identifier("job:rate:5m").unwrap();
assert_eq!(result, KeywordOrIdentifier::Identifier(Identifier::Metric("job:rate:5m".to_string())));Variants§
Keyword(Keyword)
Identifier(Identifier)
Trait Implementations§
Source§impl Clone for KeywordOrIdentifier
impl Clone for KeywordOrIdentifier
Source§fn clone(&self) -> KeywordOrIdentifier
fn clone(&self) -> KeywordOrIdentifier
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeywordOrIdentifier
impl Debug for KeywordOrIdentifier
Source§impl PartialEq for KeywordOrIdentifier
impl PartialEq for KeywordOrIdentifier
impl Eq for KeywordOrIdentifier
impl StructuralPartialEq for KeywordOrIdentifier
Auto Trait Implementations§
impl Freeze for KeywordOrIdentifier
impl RefUnwindSafe for KeywordOrIdentifier
impl Send for KeywordOrIdentifier
impl Sync for KeywordOrIdentifier
impl Unpin for KeywordOrIdentifier
impl UnwindSafe for KeywordOrIdentifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more