Skip to content

Commit

Permalink
fmt code
Browse files Browse the repository at this point in the history
  • Loading branch information
RocsSun committed Jan 24, 2024
1 parent f18a785 commit 571bac6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
28 changes: 14 additions & 14 deletions src/apis/ing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct IngContent {

impl Default for IngContent {
fn default() -> Self {
IngContent {
Self {
content: "".to_string(),
is_private: true,
lucky: false,
Expand All @@ -48,7 +48,7 @@ impl Default for IngContent {

impl Default for IngSendFrom {
fn default() -> Self {
return IngSendFrom::Cli;
Self::Cli
}
}

Expand All @@ -67,12 +67,12 @@ pub struct QeurySet {

impl Default for QeurySet {
fn default() -> Self {
return Self {
Self {
r#type: QueryIngType::default(),
page_index: 1,
page_size: 10,
tag: "".to_string(),
};
}
}
}

Expand All @@ -99,7 +99,7 @@ pub enum QueryIngType {

impl Default for QueryIngType {
fn default() -> Self {
return Self::All;
Self::All
}
}

Expand All @@ -119,16 +119,16 @@ impl From<u8> for QueryIngType {
}

impl QueryIngType {
fn as_u8(&self) -> u8 {
const fn as_u8(&self) -> u8 {
match self {
QueryIngType::Following => 1,
QueryIngType::My => 4,
QueryIngType::All => 5,
QueryIngType::RecentComment => 6,
QueryIngType::MyComment => 7,
QueryIngType::Tag => 10,
QueryIngType::Mention => 14,
QueryIngType::Comment => 13,
Self::Following => 1,
Self::My => 4,
Self::All => 5,
Self::RecentComment => 6,
Self::MyComment => 7,
Self::Tag => 10,
Self::Mention => 14,
Self::Comment => 13,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/apis/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct OauthTokenReq {

impl OauthTokenReq {
pub fn new(client_id: String, client_secret: String, code: String) -> Self {
OauthTokenReq {
Self {
cc: ClientCredentialsReq {
client_id,
client_secret,
Expand Down Expand Up @@ -107,14 +107,14 @@ pub struct RefreshTokenReq {

impl RefreshTokenReq {
pub fn new(client_id: String, client_secret: String, refresh_token: String) -> Self {
return RefreshTokenReq {
Self {
cc: ClientCredentialsReq {
client_id,
client_secret,
grant_type: "refresh_token".to_string(),
},
refresh_token,
};
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/args/parser/ing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ pub fn query(args: &Args) -> Option<QueryIng> {
global_opt: _,
} => QueryIng {
r#type: r#type.clone(),
page_index: page_index.clone(),
page_size: page_size.clone(),
page_index: *page_index,
page_size: *page_size,
tag: tag.clone(),
id: id.clone(),
},
Expand Down Expand Up @@ -126,8 +126,8 @@ pub fn create_ing(args: &Args) -> Option<CreateIng> {
global_opt: _,
} => CreateIng {
content: content.clone(),
private: private.clone(),
lucky: lucky.clone(),
private: *private,
lucky: *lucky,
tag: tag.clone(),
},
_ => return None,
Expand Down
5 changes: 2 additions & 3 deletions src/logic/ing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ pub async fn get_ings_and_comments(
.map(|x| x.unwrap())
.collect::<Vec<IngEntry>>();

return get_ing_comments(t, a).await;
get_ing_comments(t, a).await
} else {
let a = iq(t, &q.into())
.await?
.into_iter()
.map(|x| x.into())
.collect::<Vec<api::ing::get_list::IngEntry>>();
return get_ing_comments(t, a).await;
get_ing_comments(t, a).await
}
}

Expand Down

0 comments on commit 571bac6

Please sign in to comment.