forked from MightyPork/elefren-fork
fix clippy lints
This commit is contained in:
+1
-14
@@ -130,7 +130,7 @@ impl<'a> TryInto<App> for AppBuilder<'a> {
|
||||
type Error = Error;
|
||||
|
||||
fn try_into(self) -> Result<App> {
|
||||
Ok(self.build()?)
|
||||
self.build()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,19 +188,6 @@ mod tests {
|
||||
builder.build().expect("no client-name");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_app_try_into_app() {
|
||||
let app = App {
|
||||
client_name: "foo-test".to_string(),
|
||||
redirect_uris: "http://example.com".to_string(),
|
||||
scopes: Scopes::all(),
|
||||
website: None,
|
||||
};
|
||||
let expected = app.clone();
|
||||
let result = app.try_into().expect("Couldn't make App into App");
|
||||
assert_eq!(expected, result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_app_builder_try_into_app() {
|
||||
let mut builder = App::builder();
|
||||
|
||||
+1
-1
@@ -20,5 +20,5 @@ pub fn authenticate(registration: Registered) -> Result<Mastodon> {
|
||||
let mut input = String::new();
|
||||
stdin.read_line(&mut input)?;
|
||||
let code = input.trim();
|
||||
Ok(registration.complete(code)?)
|
||||
registration.complete(code)
|
||||
}
|
||||
|
||||
+4
-4
@@ -356,11 +356,11 @@ impl MastodonClient for Mastodon {
|
||||
|
||||
if ids.len() == 1 {
|
||||
url += "id=";
|
||||
url += &ids[0];
|
||||
url += ids[0];
|
||||
} else {
|
||||
for id in ids {
|
||||
url += "id[]=";
|
||||
url += &id;
|
||||
url += id;
|
||||
url += "&";
|
||||
}
|
||||
url.pop();
|
||||
@@ -391,13 +391,13 @@ impl MastodonClient for Mastodon {
|
||||
/// Get all accounts that follow the authenticated user
|
||||
fn follows_me(&self) -> Result<Page<Account>> {
|
||||
let me = self.verify_credentials()?;
|
||||
Ok(self.followers(&me.id)?)
|
||||
self.followers(&me.id)
|
||||
}
|
||||
|
||||
/// Get all accounts that the authenticated user follows
|
||||
fn followed_by_me(&self) -> Result<Page<Account>> {
|
||||
let me = self.verify_credentials()?;
|
||||
Ok(self.following(&me.id)?)
|
||||
self.following(&me.id)
|
||||
}
|
||||
|
||||
/// returns events that are relevant to the authorized user, i.e. home
|
||||
|
||||
+2
-2
@@ -134,7 +134,7 @@ macro_rules! route_v2 {
|
||||
|
||||
let url = format!(concat!("/api/v2/", $url, "?{}"), &qs);
|
||||
|
||||
Ok(self.get(self.route(&url))?)
|
||||
self.get(self.route(&url))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ macro_rules! route {
|
||||
|
||||
let url = format!(concat!("/api/v1/", $url, "?{}"), &qs);
|
||||
|
||||
Ok(self.get(self.route(&url))?)
|
||||
self.get(self.route(&url))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ pub trait MastodonClient {
|
||||
unimplemented!("This method was not implemented");
|
||||
}
|
||||
/// GET /api/v1/search
|
||||
fn search<'a>(&self, q: &'a str, resolve: bool) -> Result<SearchResult> {
|
||||
fn search(&self, q: &'_ str, resolve: bool) -> Result<SearchResult> {
|
||||
unimplemented!("This method was not implemented");
|
||||
}
|
||||
/// GET /api/v2/search
|
||||
fn search_v2<'a>(&self, q: &'a str, resolve: bool) -> Result<SearchResultV2> {
|
||||
fn search_v2(&self, q: &'_ str, resolve: bool) -> Result<SearchResultV2> {
|
||||
unimplemented!("This method was not implemented");
|
||||
}
|
||||
/// POST /api/v1/follows
|
||||
|
||||
@@ -125,15 +125,15 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_from_file() {
|
||||
let builder = MediaBuilder::from_file("/fake/file/path.png".into());
|
||||
let builder = MediaBuilder::from_file("/fake/file/path.png");
|
||||
|
||||
assert_eq!(builder.filename, None);
|
||||
assert_eq!(builder.mimetype, None);
|
||||
assert_eq!(builder.filename, Some("path.png".to_string()));
|
||||
assert_eq!(builder.mimetype, Some("image/png".to_string()));
|
||||
assert_eq!(builder.description, None);
|
||||
assert_eq!(builder.focus, None);
|
||||
|
||||
if let MediaBuilderData::File(f) = builder.data {
|
||||
assert_eq!(f, "/fake/file/path.png");
|
||||
assert_eq!(f.display().to_string().as_str(), "/fake/file/path.png");
|
||||
} else {
|
||||
panic!("Unable to destructure MediaBuilder.data into a filepath");
|
||||
}
|
||||
|
||||
+1
-1
@@ -204,7 +204,7 @@ fn get_links(response: &Response) -> Result<(Option<Url>, Option<Url>)> {
|
||||
if let Some(link_header) = response.headers().get(LINK) {
|
||||
let link_header = link_header.to_str()?;
|
||||
let link_header = link_header.as_bytes();
|
||||
let link_header: Link = parsing::from_raw_str(&link_header)?;
|
||||
let link_header: Link = parsing::from_raw_str(link_header)?;
|
||||
for value in link_header.values() {
|
||||
if let Some(relations) = value.rel() {
|
||||
if relations.contains(&RelationType::Next) {
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ impl Registered {
|
||||
|
||||
let mut builder = MastodonBuilder::new();
|
||||
builder.client(self.client.clone()).data(data);
|
||||
Ok(builder.build()?)
|
||||
builder.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -53,17 +53,17 @@ pub struct StatusesRequest<'a> {
|
||||
exclude_reblogs: bool,
|
||||
}
|
||||
|
||||
impl<'a> Into<Option<StatusesRequest<'a>>> for &'a mut StatusesRequest<'a> {
|
||||
fn into(self) -> Option<StatusesRequest<'a>> {
|
||||
impl<'a> From<&'a mut StatusesRequest<'a>> for Option<StatusesRequest<'a>> {
|
||||
fn from(req: &'a mut StatusesRequest<'a>) -> Option<StatusesRequest<'a>> {
|
||||
Some(StatusesRequest {
|
||||
only_media: self.only_media,
|
||||
exclude_replies: self.exclude_replies,
|
||||
pinned: self.pinned,
|
||||
max_id: self.max_id.clone(),
|
||||
since_id: self.since_id.clone(),
|
||||
limit: self.limit,
|
||||
min_id: self.min_id.clone(),
|
||||
exclude_reblogs: self.exclude_reblogs,
|
||||
only_media: req.only_media,
|
||||
exclude_replies: req.exclude_replies,
|
||||
pinned: req.pinned,
|
||||
max_id: req.max_id.clone(),
|
||||
since_id: req.since_id.clone(),
|
||||
limit: req.limit,
|
||||
min_id: req.min_id.clone(),
|
||||
exclude_reblogs: req.exclude_reblogs,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ impl FromStr for Scopes {
|
||||
fn from_str(s: &str) -> Result<Scopes, Self::Err> {
|
||||
let mut set = HashSet::new();
|
||||
for scope in s.split_whitespace() {
|
||||
let scope = Scope::from_str(&scope)?;
|
||||
let scope = Scope::from_str(scope)?;
|
||||
set.insert(scope);
|
||||
}
|
||||
Ok(Scopes { scopes: set })
|
||||
@@ -792,7 +792,7 @@ mod tests {
|
||||
("push", Scope::Push),
|
||||
];
|
||||
for (source, expected) in &tests {
|
||||
let result = Scope::from_str(source).expect(&format!("Couldn't parse '{}'", &source));
|
||||
let result = Scope::from_str(source).unwrap_or_else(|_| panic!("Couldn't parse '{}'", &source));
|
||||
assert_eq!(result, *expected);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user