Skip to content

Commit 7d0ab85

Browse files
committed
refactor: rename into_x to wrap_x
1 parent 17fe970 commit 7d0ab85

35 files changed

+117
-117
lines changed

src/api/auth/session.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infra::result::IntoResult;
1+
use crate::infra::result::WrapResult;
22
use anyhow::{anyhow, Result};
33
use home::home_dir;
44
use std::fs;
@@ -10,18 +10,18 @@ fn remove_pat(path: &Path) -> Result<()> {
1010
if metadata(path).is_ok() {
1111
remove_file(path)?;
1212
}
13-
().into_ok()
13+
().wrap_ok()
1414
}
1515

1616
fn save_pat(pat: &str, path: &Path) -> Result<()> {
1717
let mut file = File::create(path)?;
1818
file.write_all(pat.as_bytes())?;
19-
().into_ok()
19+
().wrap_ok()
2020
}
2121

2222
fn get_cfg_path() -> Result<PathBuf> {
2323
let home = home_dir().ok_or_else(|| anyhow!("Can not get home dir"))?;
24-
home.join(".cnbrc").into_ok()
24+
home.join(".cnbrc").wrap_ok()
2525
}
2626

2727
pub fn login(pat: &str) -> Result<PathBuf> {
@@ -31,7 +31,7 @@ pub fn login(pat: &str) -> Result<PathBuf> {
3131
remove_pat(cfg_path)?;
3232
save_pat(pat, cfg_path)?;
3333

34-
cfg_path.to_owned().into_ok()
34+
cfg_path.to_owned().wrap_ok()
3535
}
3636

3737
pub fn logout() -> Result<PathBuf> {
@@ -40,7 +40,7 @@ pub fn logout() -> Result<PathBuf> {
4040

4141
remove_pat(cfg_path)?;
4242

43-
cfg_path.to_owned().into_ok()
43+
cfg_path.to_owned().wrap_ok()
4444
}
4545

4646
pub fn get_pat() -> Result<String> {

src/api/fav/get_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::fav::Fav;
22
use crate::infra::http::{body_or_err, RequestBuilderExt};
33
use crate::infra::iter::IntoIteratorExt;
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use crate::infra::vec::VecExt;
77
use crate::openapi;
88
use anyhow::Result;
@@ -42,7 +42,7 @@ impl Fav {
4242

4343
json::deserialize::<Vec<FavEntry>>(&body)?
4444
.pop()
45-
.into_ok::<anyhow::Error>()
45+
.wrap_ok::<anyhow::Error>()
4646
})
4747
.join_all()
4848
.await

src/api/ing/get_comment_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::api::ing::Ing;
22
use crate::infra::http::{body_or_err, RequestBuilderExt};
33
use crate::infra::json;
4-
use crate::infra::result::IntoResult;
4+
use crate::infra::result::WrapResult;
55
use crate::openapi;
66
use anyhow::Result;
77
use serde::{Deserialize, Serialize};
@@ -43,6 +43,6 @@ impl Ing {
4343
json::deserialize::<Vec<IngCommentEntry>>(&body)?
4444
};
4545

46-
entry_vec.into_ok()
46+
entry_vec.wrap_ok()
4747
}
4848
}

src/api/ing/get_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::ing::{Ing, IngSendFrom, IngType};
22
use crate::infra::http::{body_or_err, RequestBuilderExt};
33
use crate::infra::iter::IntoIteratorExt;
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use crate::infra::vec::VecExt;
77
use crate::openapi;
88
use anyhow::Result;
@@ -61,7 +61,7 @@ impl Ing {
6161

6262
let body = body_or_err(resp).await?;
6363

64-
json::deserialize::<Vec<IngEntry>>(&body)?.pop().into_ok()
64+
json::deserialize::<Vec<IngEntry>>(&body)?.pop().wrap_ok()
6565
})
6666
.join_all()
6767
.await

src/api/news/get_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::news::News;
22
use crate::infra::http::{body_or_err, RequestBuilderExt};
33
use crate::infra::iter::IntoIteratorExt;
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use crate::openapi;
77
use anyhow::Result;
88
use serde::{Deserialize, Serialize};
@@ -50,7 +50,7 @@ impl News {
5050
entry
5151
};
5252

53-
entry.into_ok::<anyhow::Error>()
53+
entry.wrap_ok::<anyhow::Error>()
5454
})
5555
.join_all()
5656
.await

src/api/post/create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::post::Post;
22
use crate::blog_backend;
33
use crate::infra::http::{body_or_err, RequestBuilderExt};
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use anyhow::Result;
77
use serde_json::{json, Value};
88

@@ -30,6 +30,6 @@ impl Post {
3030
json["id"].as_u64().expect("as_u64 failed for `id`") as usize
3131
};
3232

33-
id.into_ok()
33+
id.wrap_ok()
3434
}
3535
}

src/api/post/get_comment_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::post::Post;
22
use crate::api::user::User;
33
use crate::infra::http::{body_or_err, RequestBuilderExt};
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use crate::openapi;
77
use anyhow::Result;
88
use serde::{Deserialize, Serialize};
@@ -41,6 +41,6 @@ impl Post {
4141
json::deserialize::<Vec<PostCommentEntry>>(&body)?
4242
};
4343

44-
entry_vec.into_ok()
44+
entry_vec.wrap_ok()
4545
}
4646
}

src/api/post/get_count.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::post::Post;
22
use crate::blog_backend;
33
use crate::infra::http::{body_or_err, RequestBuilderExt};
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use anyhow::Result;
77
use serde_json::Value;
88

@@ -26,6 +26,6 @@ impl Post {
2626
.expect("as_u64 failed for `postsCount`") as usize
2727
};
2828

29-
count.into_ok()
29+
count.wrap_ok()
3030
}
3131
}

src/api/post/get_meta_list.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::blog_backend;
44
use crate::infra::http::{body_or_err, RequestBuilderExt};
55
use crate::infra::iter::IntoIteratorExt;
66
use crate::infra::json;
7-
use crate::infra::result::IntoResult;
7+
use crate::infra::result::WrapResult;
88
use anyhow::Result;
99
use serde_json::Value;
1010

@@ -50,13 +50,13 @@ impl Post {
5050
entry
5151
};
5252

53-
entry.into_ok()
53+
entry.wrap_ok()
5454
})
5555
.join_all()
5656
.await
5757
.into_iter()
5858
.collect::<Result<Vec<_>>>();
5959

60-
(vec?, total_count).into_ok()
60+
(vec?, total_count).wrap_ok()
6161
}
6262
}

src/api/post/get_one.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::api::post::Post;
22
use crate::blog_backend;
33
use crate::infra::http::{body_or_err, RequestBuilderExt};
44
use crate::infra::json;
5-
use crate::infra::result::IntoResult;
5+
use crate::infra::result::WrapResult;
66
use anyhow::Result;
77
use serde::{Deserialize, Serialize};
88
use serde_json::Value;
@@ -53,6 +53,6 @@ impl Post {
5353
serde_json::from_value::<PostEntry>(json)?
5454
};
5555

56-
entry.into_ok()
56+
entry.wrap_ok()
5757
}
5858
}

0 commit comments

Comments
 (0)