diff --git a/masq/src/terminal/terminal_interface.rs b/masq/src/terminal/terminal_interface.rs index d941d95fd..86c3cf43f 100644 --- a/masq/src/terminal/terminal_interface.rs +++ b/masq/src/terminal/terminal_interface.rs @@ -7,7 +7,6 @@ use crate::terminal::secondary_infrastructure::{ use linefeed::{Interface, Signal}; use masq_lib::command::StdStreams; use masq_lib::constants::MASQ_PROMPT; -use masq_lib::utils::WrapResult; use std::sync::Arc; #[cfg(not(test))] @@ -65,8 +64,9 @@ impl TerminalWrapper { if std::env::var(prod_cfg::MASQ_TEST_INTEGRATION_KEY) .eq(&Ok(prod_cfg::MASQ_TEST_INTEGRATION_VALUE.to_string())) { - TerminalWrapper::new(Arc::new(prod_cfg::IntegrationTestTerminal::default())) - .wrap_to_ok() + Ok(TerminalWrapper::new(Arc::new( + prod_cfg::IntegrationTestTerminal::default(), + ))) } else { //we have no positive test aimed at this (only negative and as an integration test) Self::configure_interface_generic(Box::new(prod_cfg::DefaultTerminal::new)) @@ -80,11 +80,10 @@ impl TerminalWrapper { F: FnOnce() -> std::io::Result, TerminalType: linefeed::Terminal + 'static, { - Self::new(Arc::new(interface_configurator( + Ok(Self::new(Arc::new(interface_configurator( terminal_creator_of_certain_type, Box::new(Interface::with_term), - )?)) - .wrap_to_ok() + )?))) } } @@ -109,7 +108,7 @@ where set_all_settable_parameters(interface.as_mut())?; - TerminalReal::new(interface).wrap_to_ok() + Ok(TerminalReal::new(interface)) } fn set_all_settable_parameters(interface: &mut I) -> Result<(), String> diff --git a/masq/src/test_utils/mocks.rs b/masq/src/test_utils/mocks.rs index 574009ce4..2ce41c058 100644 --- a/masq/src/test_utils/mocks.rs +++ b/masq/src/test_utils/mocks.rs @@ -17,7 +17,6 @@ use masq_lib::command::StdStreams; use masq_lib::constants::DEFAULT_UI_PORT; use masq_lib::test_utils::fake_stream_holder::{ByteArrayWriter, ByteArrayWriterInner}; use masq_lib::ui_gateway::MessageBody; -use masq_lib::utils::WrapResult; use std::cell::RefCell; use std::fmt::Arguments; use std::io::{Read, Write}; @@ -624,7 +623,7 @@ impl InterfaceWrapper for InterfaceRawMock { if let Err(err) = taken_result { Err(err) } else { - (taken_result.unwrap() as Box).wrap_to_ok() + Ok(taken_result.unwrap() as Box) } } diff --git a/masq_lib/src/multi_config.rs b/masq_lib/src/multi_config.rs index 2a8b167ac..99062d9e6 100644 --- a/masq_lib/src/multi_config.rs +++ b/masq_lib/src/multi_config.rs @@ -1,7 +1,6 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. use crate::shared_schema::{ConfiguratorError, ParamError}; -use crate::utils::WrapResult; #[allow(unused_imports)] use clap::{value_t, values_t}; use clap::{App, ArgMatches}; @@ -78,7 +77,7 @@ impl<'a> MultiConfig<'a> { _ => return Err(Self::make_configurator_error(e)), }, }; - MultiConfig { arg_matches }.wrap_to_ok() + Ok(MultiConfig { arg_matches }) } pub fn make_configurator_error(e: clap::Error) -> ConfiguratorError { diff --git a/masq_lib/src/utils.rs b/masq_lib/src/utils.rs index 8f34daa92..5196086c5 100644 --- a/masq_lib/src/utils.rs +++ b/masq_lib/src/utils.rs @@ -314,25 +314,6 @@ fn expect_value_panic(subject: &str, found: Option<&dyn fmt::Debug>) -> ! { ) } -pub trait WrapResult { - fn wrap_to_ok(self) -> Result - where - Self: Sized; - fn wrap_to_err(self) -> Result - where - Self: Sized; -} - -impl WrapResult for T { - fn wrap_to_ok(self) -> Result { - Ok(self) - } - - fn wrap_to_err(self) -> Result { - Err(self) - } -} - pub fn type_name_of(_examined: T) -> &'static str { std::any::type_name::() } diff --git a/node/src/database/db_migrations.rs b/node/src/database/db_migrations.rs index 6ed5dcb6f..52c97a660 100644 --- a/node/src/database/db_migrations.rs +++ b/node/src/database/db_migrations.rs @@ -13,7 +13,7 @@ use crate::sub_lib::cryptde::PlainData; use crate::sub_lib::neighborhood::{RatePack, DEFAULT_RATE_PACK}; use itertools::Itertools; use masq_lib::logger::Logger; -use masq_lib::utils::{ExpectValue, WrapResult}; +use masq_lib::utils::ExpectValue; use rusqlite::{params_from_iter, Error, Row, ToSql, Transaction}; use std::fmt::{Debug, Display, Formatter}; use tiny_hderive::bip32::ExtendedPrivKey; @@ -96,11 +96,10 @@ impl<'a> DBMigrationUtilitiesReal<'a> { conn: &'b mut dyn ConnectionWrapper, db_migrator_configuration: DBMigratorInnerConfiguration, ) -> rusqlite::Result { - Self { + Ok(Self { root_transaction: Some(conn.transaction()?), db_migrator_configuration, - } - .wrap_to_ok() + }) } fn root_transaction_ref(&self) -> &Transaction<'a> { diff --git a/node/src/node_configurator/mod.rs b/node/src/node_configurator/mod.rs index 7e6fe8fcb..ad232115c 100644 --- a/node/src/node_configurator/mod.rs +++ b/node/src/node_configurator/mod.rs @@ -20,7 +20,7 @@ use masq_lib::multi_config::{merge, CommandLineVcl, EnvironmentVcl, MultiConfig, use masq_lib::shared_schema::{ chain_arg, config_file_arg, data_directory_arg, real_user_arg, ConfiguratorError, }; -use masq_lib::utils::{localhost, ExpectValue, WrapResult}; +use masq_lib::utils::{localhost, ExpectValue}; use std::net::{SocketAddr, TcpListener}; use std::path::{Path, PathBuf}; @@ -60,7 +60,7 @@ pub fn determine_config_file_path( real_user_data_directory_opt_and_chain(dirs_wrapper, &multi_config); let directory = data_directory_from_context(dirs_wrapper, &real_user, &data_directory_opt, chain); - (directory.join(config_file_path), user_specified).wrap_to_ok() + Ok((directory.join(config_file_path), user_specified)) } pub fn initialize_database( diff --git a/node/src/node_configurator/node_configurator_standard.rs b/node/src/node_configurator/node_configurator_standard.rs index aab1f8b08..b5700144b 100644 --- a/node/src/node_configurator/node_configurator_standard.rs +++ b/node/src/node_configurator/node_configurator_standard.rs @@ -33,7 +33,6 @@ use crate::sub_lib::utils::make_new_multi_config; use crate::tls_discriminator_factory::TlsDiscriminatorFactory; use masq_lib::constants::{DEFAULT_UI_PORT, HTTP_PORT, TLS_PORT}; use masq_lib::multi_config::{CommandLineVcl, ConfigFileVcl, EnvironmentVcl}; -use masq_lib::utils::WrapResult; use std::str::FromStr; pub struct NodeConfiguratorStandardPrivileged { @@ -160,7 +159,7 @@ pub fn server_initializer_collected_params<'a>( .map(|dir| dir.to_path_buf()) .expectv("data_directory"); let real_user = real_user_from_multi_config_or_populate(&multi_config, dirs_wrapper); - GatheredParams::new(multi_config, data_directory, real_user).wrap_to_ok() + Ok(GatheredParams::new(multi_config, data_directory, real_user)) } pub fn establish_port_configurations(config: &mut BootstrapperConfig) { diff --git a/node/src/node_configurator/unprivileged_parse_args_configuration.rs b/node/src/node_configurator/unprivileged_parse_args_configuration.rs index 334bc1e77..45d771c40 100644 --- a/node/src/node_configurator/unprivileged_parse_args_configuration.rs +++ b/node/src/node_configurator/unprivileged_parse_args_configuration.rs @@ -21,7 +21,7 @@ use masq_lib::logger::Logger; use masq_lib::multi_config::MultiConfig; use masq_lib::shared_schema::{ConfiguratorError, ParamError}; use masq_lib::test_utils::utils::TEST_DEFAULT_CHAIN; -use masq_lib::utils::{AutomapProtocol, ExpectValue, WrapResult}; +use masq_lib::utils::{AutomapProtocol, ExpectValue}; use rustc_hex::FromHex; use std::net::{IpAddr, Ipv4Addr}; use std::str::FromStr; @@ -400,7 +400,7 @@ fn validate_descriptors_from_user( )) } } - Err(e) => ParamError::new("neighbors", &e).wrap_to_err() + Err(e) => Err(ParamError::new("neighbors", &e)) } }) .collect_vec() diff --git a/port_exposer/Cargo.lock b/port_exposer/Cargo.lock index 0c1b45562..d9a75a8aa 100644 --- a/port_exposer/Cargo.lock +++ b/port_exposer/Cargo.lock @@ -20,7 +20,7 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "port_exposer" -version = "0.7.1" +version = "0.7.2" dependencies = [ "default-net", ]