From 8dfd49af0d99965562f26e51a2bb3a7d4ed00216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 9 Apr 2020 17:54:09 +0200 Subject: [PATCH] cli helpers: in run function, take function as argument instead --- aquatic/src/bin/aquatic.rs | 2 +- cli_helpers/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aquatic/src/bin/aquatic.rs b/aquatic/src/bin/aquatic.rs index 7c44968..f52b5a8 100644 --- a/aquatic/src/bin/aquatic.rs +++ b/aquatic/src/bin/aquatic.rs @@ -7,7 +7,7 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; fn main(){ - cli_helpers::run_with_cli_and_config( + cli_helpers::run_with_cli_and_config::( "aquatic: udp bittorrent tracker", aquatic::run, ) diff --git a/cli_helpers/src/lib.rs b/cli_helpers/src/lib.rs index 8098c41..6541932 100644 --- a/cli_helpers/src/lib.rs +++ b/cli_helpers/src/lib.rs @@ -36,11 +36,11 @@ fn default_config_as_toml() -> String } -pub fn run_with_cli_and_config( +pub fn run_with_cli_and_config( title: &str, // Function that takes config file and runs application - f: F, -) where T: Default + Serialize + DeserializeOwned, F: Fn(T) { + f: fn(T), +) where T: Default + Serialize + DeserializeOwned { let args: Vec = ::std::env::args().collect(); match AppOptions::parse_args_default(&args[1..]){ @@ -77,4 +77,4 @@ fn print_help(title: &str, opt_error: Option<&str>){ } println!("\n{}", AppOptions::usage()); -} \ No newline at end of file +}