Skip to content

Commit 2c92368

Browse files
committed
refactor: rm unnecessary try block
1 parent e332ef2 commit 2c92368

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/main.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ async fn main() -> Result<()> {
6363
quiet.not().then(|| display::logout(style, cfg_path));
6464
}
6565
_ if parser::user_info(&args) => {
66-
let user_info = try {
67-
User::new(pat?).get_info().await?
68-
};
66+
let user_info = User::new(pat?).get_info().await;
6967
foe.then(|| panic_if_err(&user_info));
7068
quiet.not().then(|| display::user_info(style, &user_info));
7169
}
@@ -103,19 +101,19 @@ async fn main() -> Result<()> {
103101
quiet.not().then(|| display::comment_ing(style, &content));
104102
}
105103
_ if let Some(id) = parser::show_post(&args) => {
106-
let entry = try { Post::new(pat?).get_one(id).await? };
104+
let entry = Post::new(pat?).get_one(id).await;
107105
foe.then(|| panic_if_err(&entry));
108106
quiet.not().then(|| display::show_post(style, &entry));
109107
}
110108
_ if let Some(id) = parser::show_post_meta(&args) => {
111-
let entry = try { Post::new(pat?).get_one(id).await? };
109+
let entry = Post::new(pat?).get_one(id).await;
112110
foe.then(|| panic_if_err(&entry));
113111
quiet.not().then(|| display::show_post_meta(style, &entry));
114112
}
115113
_ if let Some((skip, take)) = parser::list_post(&args) => {
116-
let result = try { Post::new(pat?).get_meta_list(skip, take).await? };
117-
foe.then(|| panic_if_err(&result));
118-
quiet.not().then(|| display::list_post(style, &result, rev));
114+
let meta_vec = Post::new(pat?).get_meta_list(skip,take).await;
115+
foe.then(|| panic_if_err(&meta_vec));
116+
quiet.not().then(|| display::list_post(style, &meta_vec, rev));
119117
}
120118
_ if let Some(id) = parser::delete_post(&args) => {
121119
let id = try {
@@ -126,24 +124,22 @@ async fn main() -> Result<()> {
126124
quiet.not().then(|| display::delete_post(style, &id));
127125
}
128126
_ if let Some((kw, skip, take)) = parser::search_post(&args) => {
129-
let result = try { Post::new(pat?).search(skip, take, kw).await? };
127+
let result = Post::new(pat?).search(skip, take, kw).await;
130128
foe.then(|| panic_if_err(&result));
131129
quiet.not().then(|| display::search_post(style, &result, rev));
132130
}
133131
_ if let Some((title, body, publish)) = parser::create_post(&args) => {
134-
let id = try { Post::new(pat?).create(title, body, publish).await? };
132+
let id = Post::new(pat?).create(title, body, publish).await;
135133
foe.then(|| panic_if_err(&id));
136134
quiet.not().then(|| display::create_post(style, &id));
137135
}
138136
_ if let Some((id, title, body, publish)) = parser::update_post(&args) => {
139-
let id = try { Post::new(pat?).update(id, title, body, publish).await? };
137+
let id = Post::new(pat?).update(id, title, body, publish).await;
140138
foe.then(|| panic_if_err(&id));
141139
quiet.not().then(|| display::update_post(style, &id));
142140
}
143141
_ if let Some((skip, take)) = parser::list_news(&args) => {
144-
let news_vec = try {
145-
News::new(pat?).get_list(skip, take).await?
146-
};
142+
let news_vec = News::new(pat?).get_list(skip, take).await;
147143
foe.then(|| panic_if_err(&news_vec));
148144
quiet.not().then(|| display::list_news(style, &news_vec, rev));
149145
}

0 commit comments

Comments
 (0)