Skip to content

Commit f756117

Browse files
committed
refactor: simplify impl
1 parent c80b2a2 commit f756117

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/infra/infer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// Use this to infer type for val, as same as type ascription
2+
pub const fn infer<T>(val: T) -> T {
3+
val
4+
}

src/infra/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod fp;
22
pub mod http;
3+
pub mod infer;
34
pub mod iter;
45
pub mod json;
56
pub mod option;

src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ use crate::api::user::User;
1414
use crate::args::parser::no_operation;
1515
use crate::args::{parser, Args};
1616
use crate::infra::fp::currying::eq;
17+
use crate::infra::infer::infer;
1718
use crate::infra::iter::IntoIteratorExt;
1819
use crate::infra::option::OptionExt;
1920
use crate::infra::result::IntoResult;
2021
use anyhow::Result;
21-
use clap::CommandFactory;
2222
use clap::Parser;
23+
use clap::{Command, CommandFactory};
2324
use colored::Colorize;
2425
use std::env;
2526

@@ -164,10 +165,8 @@ async fn main() -> Result<()> {
164165
display::list_news(style, time_style, &news_vec, rev)?
165166
}
166167

167-
_ if no_operation(&args) => {
168-
Args::command().print_help()?;
169-
return ().into_ok();
170-
}
168+
_ if no_operation(&args) =>
169+
infer::<Command>(Args::command()).render_help().to_string(),
171170
_ => "Invalid usage, follow '--help' for more information".to_owned()
172171
};
173172

0 commit comments

Comments
 (0)