Skip to content

Commit

Permalink
根据 clippy 建议进行修改:
Browse files Browse the repository at this point in the history
1. core.rs 173 行,to_owned() may be inefficient。这里其实不需要
   to_owned,所有权拿走就行。
2. login.rs 117 行,to_owned() may be inefficient, 这里建议用
   clone_into(),因为私有的 clone_into() 可能可以避免拷贝。但这里其实是一样的,而且 clone_into 接口使用麻烦,但为了抑制 clippy 建议,这里直接用 clone() 了。
3. post.rs 858 行,建议同上。但这里仍没有区别,而且在这里对 JsonValue 的字段使用 clone_into 在这里非常麻烦,需要做相当多的转换,直接用 clone() 抑制 clippy 的 warn 建议。
  • Loading branch information
Shapooo committed Jul 9, 2024
1 parent c5cfda4 commit c8e0fea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl Core {
}
TaskResponse::InProgress(ratio, msg) => {
self.ratio = ratio;
self.message = msg.to_owned()
self.message = msg;
}
TaskResponse::Finished(web_total, db_total) => {
self.ratio = 1.;
Expand Down
2 changes: 1 addition & 1 deletion src/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Loginator {
self.qrid = json["data"]["qrid"]
.as_str()
.expect("qrcode id get failed")
.to_owned();
.into();
let img = self.client.get(img_url).send()?.bytes()?;
let img = Reader::new(Cursor::new(img))
.with_guessed_format()?
Expand Down
2 changes: 1 addition & 1 deletion src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ impl Post {
};
post["id"] = Value::Number(serde_json::Number::from(id));
post["mblogid"] = post["bid"].take();
post["text_raw"] = post["text"].to_owned();
post["text_raw"] = post["text"].clone();
post["favorited"] = Value::Bool(true);
if let Value::Array(arr) = post["url_objects"].take() {
post["url_struct"] = Value::Array(
Expand Down

0 comments on commit c8e0fea

Please sign in to comment.