use std::sync::OnceLock;
use crate::bench::BenchOptions;
pub struct EntryMeta {
pub display_name: &'static str,
pub raw_name: &'static str,
pub module_path: &'static str,
pub location: EntryLocation,
pub get_bench_options: Option<fn() -> BenchOptions<'static>>,
pub cached_bench_options: OnceLock<BenchOptions<'static>>,
}
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord)]
#[allow(missing_docs)]
pub struct EntryLocation {
pub file: &'static str,
pub line: u32,
pub col: u32,
}
impl EntryMeta {
#[inline]
pub(crate) fn bench_options(&self) -> Option<&BenchOptions> {
Some(self.cached_bench_options.get_or_init(self.get_bench_options?))
}
#[inline]
pub(crate) fn module_path_components<'a>(&self) -> impl Iterator<Item = &'a str> {
self.module_path.split("::")
}
}