Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Nov 29, 2024
1 parent a9d6a9a commit f1adca7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl SharedSettings {
pub fn new_with_defaults(cli_args: &ArgMatches, config_file_defaults: &Self) -> Self {
let default_hostname = DEFAULT_HOST.to_string();
let should_use_tls =
*cli_args.get_one::<bool>("tls").unwrap() || config_file_defaults.tls || false;
*cli_args.get_one::<bool>("tls").unwrap() || config_file_defaults.tls;
let scheme = if should_use_tls { "https" } else { "http" };
let hostname = cli_args
.get_one::<String>("host")
Expand All @@ -105,7 +105,7 @@ impl SharedSettings {
.get_one::<u16>("port")
.cloned()
.or(config_file_defaults.port)
.or_else(|| {
.or({
if should_use_tls {
Some(DEFAULT_HTTPS_PORT)
} else {
Expand Down Expand Up @@ -162,7 +162,7 @@ impl SharedSettings {
let port: u16 = cli_args
.get_one::<u16>("port")
.cloned()
.or_else(|| {
.or({
if should_use_tls {
Some(DEFAULT_HTTPS_PORT)
} else {
Expand Down Expand Up @@ -213,7 +213,7 @@ impl SharedSettings {
let hostname = url.host_str().unwrap_or(DEFAULT_HOST).to_string();
let port = url
.port()
.or_else(|| {
.or({
if should_use_tls {
Some(DEFAULT_HTTPS_PORT)
} else {
Expand Down Expand Up @@ -263,7 +263,7 @@ impl SharedSettings {
let hostname = url.host_str().unwrap_or(DEFAULT_HOST).to_string();
let port = url
.port()
.or_else(|| {
.or({
if should_use_tls {
Some(DEFAULT_HTTPS_PORT)
} else {
Expand Down Expand Up @@ -330,8 +330,7 @@ fn from_local_path(path: &PathBuf) -> Result<ConfigurationMap, ConfigFileError>
fn read_from_local_path(path: &PathBuf) -> Result<ConfigurationMap, ConfigFileError> {
let contents = std::fs::read_to_string(path)?;
toml::from_str(&contents)
.and_then(|t| Ok(t))
.map_err(|e| ConfigFileError::from(e))
.map_err(ConfigFileError::from)
}

fn default_scheme() -> String {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fn main() {
);
process::exit(1)
}
let sf = if cf_ss.is_ok() {
SharedSettings::from_args_with_defaults(&cli, &cf_ss.unwrap())
let sf = if let Ok(val) = cf_ss {
SharedSettings::from_args_with_defaults(&cli, &val)
} else {
SharedSettings::from_args(&cli)
};
Expand Down

0 comments on commit f1adca7

Please sign in to comment.