mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 17:00:18 +00:00
create_export_manager -> ExportManager::new
This commit is contained in:
1 parent
aabe1331a2
commit
bd81fe65a2
2 files changed
+10
-11
No files matched your search
@@ -73,20 +73,19 @@ trait Exporter {
|
|||||||
fn serialize(&self, values: &Vec<ExportEntry>) -> Result<Vec<u8>>;
|
fn serialize(&self, values: &Vec<ExportEntry>) -> Result<Vec<u8>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new ExportManager
|
/// Handles the management of multiple file exporters.
|
||||||
pub fn create_export_manager() -> ExportManager {
|
|
||||||
ExportManager {
|
|
||||||
exporters: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The ExportManager handles the management of multiple file
|
|
||||||
/// exporters.
|
|
||||||
pub struct ExportManager {
|
pub struct ExportManager {
|
||||||
exporters: Vec<ExportType>,
|
exporters: Vec<ExportType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExportManager {
|
impl ExportManager {
|
||||||
|
/// Create a new ExportManager
|
||||||
|
pub fn new() -> ExportManager {
|
||||||
|
ExportManager {
|
||||||
|
exporters: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Add an additional exporter to the ExportManager
|
/// Add an additional exporter to the ExportManager
|
||||||
pub fn add_exporter(&mut self, for_type: ExportType) {
|
pub fn add_exporter(&mut self, for_type: ExportType) {
|
||||||
self.exporters.push(for_type);
|
self.exporters.push(for_type);
|
||||||
|
|||||||
+2
-2
@@ -39,7 +39,7 @@ mod hyperfine;
|
|||||||
|
|
||||||
use hyperfine::internal::{CmdFailureAction, HyperfineOptions, OutputStyleOption};
|
use hyperfine::internal::{CmdFailureAction, HyperfineOptions, OutputStyleOption};
|
||||||
use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark};
|
use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark};
|
||||||
use hyperfine::export::{create_export_manager, ExportEntry, ExportManager, ExportType};
|
use hyperfine::export::{ExportEntry, ExportManager, ExportType};
|
||||||
|
|
||||||
/// Print error message to stderr and terminate
|
/// Print error message to stderr and terminate
|
||||||
pub fn error(message: &str) -> ! {
|
pub fn error(message: &str) -> ! {
|
||||||
@@ -223,7 +223,7 @@ fn create_exporter(targets: ExportTargetList) -> Option<ExportManager> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut export_manager = create_export_manager();
|
let mut export_manager = ExportManager::new();
|
||||||
|
|
||||||
if let Some(filename) = targets.json_file {
|
if let Some(filename) = targets.json_file {
|
||||||
export_manager.add_exporter(ExportType::Json(filename.to_string()));
|
export_manager.add_exporter(ExportType::Json(filename.to_string()));
|
||||||
|
|||||||
Reference in new issue
Block a user