orql 0.1.0

A toy SQL parser for a subset of the Oracle dialect.
Documentation
use super::CommentStyle;

/// A
/// [hint](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Comments.html#GUID-D316D545-89E2-4D54-977F-FC97815CD62E)
/// to Oracle's query optimizer. These are `/*+ ...*/` or `--+ ...` comments
/// immediately following a `SELECT`, `UPDATE`, `INSERT`, `MERGE`, or `DELETE`
/// keywords.
#[derive(Debug)]
pub struct Hint<'s> {
    /// the raw text of the hint omitting the leading and trailing markers
    /// (the `+` symbol is considered part of the marker, and, hence, _not_
    /// part of `text`)
    pub text: &'s str,

    /// the style of comment encapsulating `text`
    pub comment_style: CommentStyle,
}

impl<'s> crate::fmt::Display for Hint<'s> {
    fn fmt(&self, f: &mut impl crate::fmt::Formatter) -> std::fmt::Result {
        match self.comment_style {
            CommentStyle::Line => {
                f.write_str("--+")?;
                f.write_str(self.text)
            }
            CommentStyle::Block => {
                f.write_str("/*+")?;
                f.write_str(self.text)?;
                f.write_str("*/")
            }
        }
    }
}