add Hint accessors

This commit is contained in:
Simon Gardling
2022-05-16 13:28:23 -04:00
parent 491c8eb6fb
commit c7e8865d7e
3 changed files with 37 additions and 3 deletions

View File

@@ -249,6 +249,26 @@ impl<'a> Hint<'a> {
#[allow(dead_code)]
pub const fn is_single(&self) -> bool { matches!(&self, &Hint::Single(_)) }
#[inline]
#[allow(dead_code)]
pub const fn single(&self) -> Option<&&str> {
if let Hint::Single(data) = self {
Some(data)
} else {
None
}
}
#[inline]
#[allow(dead_code)]
pub const fn many(&self) -> Option<&&[&str]> {
if let Hint::Many(data) = self {
Some(data)
} else {
None
}
}
}
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));