Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Default for some enums. #800

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,17 @@ impl Mode {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
/// Enum representing the list format.
pub(crate) enum ListFormat {
/// The regular, default format.
#[default]
Pretty,
/// The terse format, where nothing other than the name of the test and ": benchmark" at the end
/// is printed out.
Terse,
}

impl Default for ListFormat {
fn default() -> Self {
Self::Pretty
}
}

/// Benchmark filtering support.
#[derive(Clone, Debug)]
pub enum BenchmarkFilter {
Expand Down Expand Up @@ -1272,9 +1267,10 @@ pub enum Throughput {
}

/// Axis scaling type
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Default, Clone, Copy)]
pub enum AxisScale {
/// Axes scale linearly
#[default]
Linear,

/// Axes scale logarithmically
Expand All @@ -1296,19 +1292,11 @@ pub enum AxisScale {
/// benchmark_group.plot_config(plot_config);
/// // Use benchmark group
/// ```
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub struct PlotConfiguration {
summary_scale: AxisScale,
}

impl Default for PlotConfiguration {
fn default() -> PlotConfiguration {
PlotConfiguration {
summary_scale: AxisScale::Linear,
}
}
}

impl PlotConfiguration {
#[must_use]
/// Set the axis scale (linear or logarithmic) for the summary plots. Typically, you would
Expand All @@ -1323,10 +1311,11 @@ impl PlotConfiguration {
/// This enum allows the user to control how Criterion.rs chooses the iteration count when sampling.
/// The default is Auto, which will choose a method automatically based on the iteration time during
/// the warm-up phase.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Default, Clone, Copy)]
pub enum SamplingMode {
/// Criterion.rs should choose a sampling method automatically. This is the default, and is
/// recommended for most users and most benchmarks.
#[default]
Auto,

/// Scale the iteration count in each sample linearly. This is suitable for most benchmarks,
Expand Down