From 13c1e190e083923f5df1ebe2cfdc0344bc66167f Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 13 Aug 2022 16:38:20 +0200 Subject: [PATCH] Add a bunch of getters to `Trial` --- src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 97c6fab..29d0ab0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,6 +182,32 @@ impl Trial { ..self } } + + /// Returns the name of this trial. + pub fn name(&self) -> &str { + &self.info.name + } + + /// Returns the kind of this trial. If you have not set a kind, this is an + /// empty string. + pub fn kind(&self) -> &str { + &self.info.kind + } + + /// Returns whether this trial has been marked as *ignored*. + pub fn has_ignored_flag(&self) -> bool { + self.info.is_ignored + } + + /// Returns `true` iff this trial is a test (as opposed to a benchmark). + pub fn is_test(&self) -> bool { + !self.info.is_bench + } + + /// Returns `true` iff this trial is a benchmark (as opposed to a test). + pub fn is_bench(&self) -> bool { + self.info.is_bench + } } impl fmt::Debug for Trial {