Clippy stuff

This commit is contained in:
Mahesh Bansod 2021-10-23 21:46:39 +05:30
parent b220ea7b65
commit 19ef4c4d03
5 changed files with 10 additions and 19 deletions

View File

@ -5,7 +5,7 @@ pub struct MyFriendlyError(SocialvoidError);
impl std::convert::From<SocialvoidError> for MyFriendlyError {
fn from(err: SocialvoidError) -> Self {
Self(err.into())
Self(err)
}
}

View File

@ -115,10 +115,7 @@ async fn main() {
setup_sessions(&config, &mut sv, &mut current_session).await;
match field {
ProfileField::Pic => {
if value.is_none() {
println!("You need to specify the path to the picture to upload");
} else {
let filepath = value.unwrap();
if let Some(filepath) = value {
match sv.set_profile_picture(filepath).await {
Ok(doc) => {
println!("Profile picture updated successfully.\n{:?}", doc);
@ -130,6 +127,8 @@ async fn main() {
);
}
}
} else {
println!("You need to specify the path to the picture to upload");
}
}
}

View File

@ -25,7 +25,7 @@ pub async fn setup_sessions(config: &Config, sv: &mut sv_client::Client, sesh_ke
}
}
if sv.sessions.len() == 0 {
if sv.sessions.is_empty() {
sv.new_session()
.await
.expect("Couldn't create a new session.");

View File

@ -37,7 +37,7 @@ pub async fn new_with_defaults() -> Result<Client, SocialvoidError> {
async fn make_cdn_client_from(
rpc_client: &socialvoid_rawclient::Client,
) -> Result<socialvoid_rawclient::CdnClient, SocialvoidError> {
let server_info = help::get_server_information(&rpc_client).await?;
let server_info = help::get_server_information(rpc_client).await?;
Ok(socialvoid_rawclient::CdnClient::with_cdn_url(
server_info.cdn_server,

View File

@ -149,20 +149,20 @@ Display Picture: {}",
self.last_name
.as_ref()
.map(|x| format!("Last Name: {}", x))
.unwrap_or(String::from("[No last name set]")),
.unwrap_or_else(|| String::from("[No last name set]")),
self.name,
self.biography
.as_ref()
.map(|x| format!("Biography: {}", x))
.unwrap_or(String::from("[No biography set]")),
.unwrap_or_else(|| String::from("[No biography set]")),
self.location
.as_ref()
.map(|x| format!("Location: {}", x))
.unwrap_or(String::from("[No location set]")),
.unwrap_or_else(|| String::from("[No location set]")),
self.url
.as_ref()
.map(|x| format!("URL: {}", x))
.unwrap_or(String::from("[No URL set]")),
.unwrap_or_else(|| String::from("[No URL set]")),
self.followers_count,
self.following_count,
if self.display_picture_sizes.is_empty() {
@ -175,11 +175,3 @@ Display Picture: {}",
)
}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}