making clippy happy
This commit is contained in:
+1
-1
@@ -126,7 +126,7 @@ impl<'a> AppBuilder<'a> {
|
||||
.redirect_uris
|
||||
.unwrap_or_else(|| "urn:ietf:wg:oauth:2.0:oob".into())
|
||||
.into(),
|
||||
scopes: self.scopes.unwrap_or_else(|| Scopes::read_all()),
|
||||
scopes: self.scopes.unwrap_or_else(Scopes::read_all),
|
||||
website: self.website.map(|s| s.into()),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ pub(crate) struct Credentials {
|
||||
mod fields_attributes_ser {
|
||||
use super::*;
|
||||
use serde::ser::{SerializeMap, Serializer};
|
||||
pub(crate) fn ser<S>(attrs: &Vec<MetadataField>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
pub(crate) fn ser<S>(attrs: &[MetadataField], serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::entities::{notification::Notification, status::Status};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
/// Events that come from the /streaming/user API call
|
||||
pub enum Event {
|
||||
/// Update event
|
||||
|
||||
@@ -81,10 +81,8 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>, H: HttpSend> Iterator for ItemsIt
|
||||
}
|
||||
Some(self.page.initial_items[idx].clone())
|
||||
} else {
|
||||
if self.need_next_page() {
|
||||
if self.fill_next_page().is_none() {
|
||||
return None;
|
||||
}
|
||||
if self.need_next_page() && self.fill_next_page().is_none() {
|
||||
return None;
|
||||
}
|
||||
let idx = self.cur_idx;
|
||||
self.cur_idx += 1;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use envy;
|
||||
|
||||
use crate::{data::Data, Result};
|
||||
|
||||
/// Attempts to deserialize a Data struct from the environment
|
||||
|
||||
+1
-3
@@ -4,8 +4,6 @@ use std::{
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use serde_json;
|
||||
|
||||
use crate::{data::Data, Result};
|
||||
|
||||
/// Attempts to deserialize a Data struct from a string
|
||||
@@ -48,7 +46,7 @@ pub fn to_vec(data: &Data) -> Result<Vec<u8>> {
|
||||
pub fn to_writer<W: Write>(data: &Data, writer: W) -> Result<()> {
|
||||
let mut buf_writer = BufWriter::new(writer);
|
||||
let vec = to_vec(data)?;
|
||||
buf_writer.write(&vec)?;
|
||||
buf_writer.write_all(&vec)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ pub fn to_vec(data: &Data) -> Result<Vec<u8>> {
|
||||
pub fn to_writer<W: Write>(data: &Data, writer: W) -> Result<()> {
|
||||
let mut buf_writer = BufWriter::new(writer);
|
||||
let vec = to_vec(data)?;
|
||||
buf_writer.write(&vec)?;
|
||||
buf_writer.write_all(&vec)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -69,7 +69,7 @@
|
||||
unused_import_braces,
|
||||
unused_qualifications
|
||||
)]
|
||||
#![allow(broken_intra_doc_links)]
|
||||
#![cfg_attr(feature = "nightly", allow(broken_intra_doc_links))]
|
||||
|
||||
use std::{borrow::Cow, io::BufRead, ops};
|
||||
|
||||
@@ -254,9 +254,9 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
||||
let status = response.status();
|
||||
|
||||
if status.is_client_error() {
|
||||
return Err(Error::Client(status.clone()));
|
||||
return Err(Error::Client(status));
|
||||
} else if status.is_server_error() {
|
||||
return Err(Error::Server(status.clone()));
|
||||
return Err(Error::Server(status));
|
||||
}
|
||||
|
||||
deserialise(response)
|
||||
@@ -270,9 +270,9 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
||||
let status = response.status();
|
||||
|
||||
if status.is_client_error() {
|
||||
return Err(Error::Client(status.clone()));
|
||||
return Err(Error::Client(status));
|
||||
} else if status.is_server_error() {
|
||||
return Err(Error::Server(status.clone()));
|
||||
return Err(Error::Server(status));
|
||||
}
|
||||
|
||||
deserialise(response)
|
||||
@@ -286,9 +286,9 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
||||
let status = response.status();
|
||||
|
||||
if status.is_client_error() {
|
||||
return Err(Error::Client(status.clone()));
|
||||
return Err(Error::Client(status));
|
||||
} else if status.is_server_error() {
|
||||
return Err(Error::Server(status.clone()));
|
||||
return Err(Error::Server(status));
|
||||
}
|
||||
|
||||
deserialise(response)
|
||||
@@ -627,7 +627,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
||||
.multipart(form_data),
|
||||
)?;
|
||||
|
||||
let status = response.status().clone();
|
||||
let status = response.status();
|
||||
|
||||
if status.is_client_error() {
|
||||
return Err(Error::Client(status));
|
||||
@@ -675,7 +675,7 @@ impl<R: EventStream> Iterator for EventReader<R> {
|
||||
loop {
|
||||
if let Ok(line) = self.0.read_message() {
|
||||
let line = line.trim().to_string();
|
||||
if line.starts_with(":") || line.is_empty() {
|
||||
if line.starts_with(':') || line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
lines.push(line);
|
||||
@@ -773,7 +773,7 @@ impl<H: HttpSend> MastodonBuilder<H> {
|
||||
pub fn build(self) -> Result<Mastodon<H>> {
|
||||
Ok(if let Some(data) = self.data {
|
||||
Mastodon {
|
||||
client: self.client.unwrap_or_else(|| Client::new()),
|
||||
client: self.client.unwrap_or_else(Client::new),
|
||||
http_sender: self.http_sender,
|
||||
data,
|
||||
}
|
||||
|
||||
+3
-3
@@ -79,7 +79,7 @@ macro_rules! paged_routes {
|
||||
|
||||
let qs_data = Data {
|
||||
$(
|
||||
$param: $param,
|
||||
$param,
|
||||
)*
|
||||
_marker: ::std::marker::PhantomData,
|
||||
};
|
||||
@@ -125,7 +125,7 @@ macro_rules! route_v2 {
|
||||
|
||||
let qs_data = Data {
|
||||
$(
|
||||
$param: $param,
|
||||
$param,
|
||||
)*
|
||||
_marker: ::std::marker::PhantomData,
|
||||
};
|
||||
@@ -168,7 +168,7 @@ macro_rules! route {
|
||||
|
||||
let qs_data = Data {
|
||||
$(
|
||||
$param: $param,
|
||||
$param,
|
||||
)*
|
||||
_marker: ::std::marker::PhantomData,
|
||||
};
|
||||
|
||||
+3
-3
@@ -59,7 +59,7 @@ macro_rules! pages {
|
||||
/// page: RefCell<Option<OwnedPage<Status, HttpSender>>>,
|
||||
/// }
|
||||
/// let client = Mastodon::from(data);
|
||||
/// let home = client.get_home_timeline()?.to_owned();
|
||||
/// let home = client.get_home_timeline()?.into_owned();
|
||||
/// let tl = HomeTimeline {
|
||||
/// client,
|
||||
/// page: RefCell::new(Some(home)),
|
||||
@@ -148,7 +148,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>, H: HttpSend> Page<'a, T, H> {
|
||||
/// page: RefCell<Option<OwnedPage<Status, HttpSender>>>,
|
||||
/// }
|
||||
/// let client = Mastodon::from(data);
|
||||
/// let home = client.get_home_timeline()?.to_owned();
|
||||
/// let home = client.get_home_timeline()?.into_owned();
|
||||
/// let tl = HomeTimeline {
|
||||
/// client,
|
||||
/// page: RefCell::new(Some(home)),
|
||||
@@ -156,7 +156,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>, H: HttpSend> Page<'a, T, H> {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn to_owned(self) -> OwnedPage<T, H> {
|
||||
pub fn into_owned(self) -> OwnedPage<T, H> {
|
||||
OwnedPage::from(self)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ use crate::{
|
||||
Result,
|
||||
};
|
||||
|
||||
const DEFAULT_REDIRECT_URI: &'static str = "urn:ietf:wg:oauth:2.0:oob";
|
||||
const DEFAULT_REDIRECT_URI: &str = "urn:ietf:wg:oauth:2.0:oob";
|
||||
|
||||
/// Handles registering your mastodon app to your instance. It is recommended
|
||||
/// you cache your data struct to avoid registering on every run.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::errors::Error;
|
||||
use serde::Serialize;
|
||||
use serde_qs;
|
||||
use std::{borrow::Cow, convert::Into};
|
||||
|
||||
mod bool_qs_serialize {
|
||||
@@ -59,7 +58,7 @@ impl<'a> Into<Option<StatusesRequest<'a>>> for &'a mut StatusesRequest<'a> {
|
||||
pinned: self.pinned,
|
||||
max_id: self.max_id.clone(),
|
||||
since_id: self.since_id.clone(),
|
||||
limit: self.limit.clone(),
|
||||
limit: self.limit,
|
||||
min_id: self.min_id.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -193,8 +193,8 @@ impl UpdateCredsRequest {
|
||||
avatar: self.avatar.clone(),
|
||||
header: self.avatar.clone(),
|
||||
source: Some(UpdateSource {
|
||||
privacy: self.privacy.clone(),
|
||||
sensitive: self.sensitive.clone(),
|
||||
privacy: self.privacy,
|
||||
sensitive: self.sensitive,
|
||||
}),
|
||||
fields_attributes: self.field_attributes.clone(),
|
||||
})
|
||||
|
||||
+1
-2
@@ -217,8 +217,7 @@ impl Scopes {
|
||||
let newset: HashSet<_> = self
|
||||
.scopes
|
||||
.union(&other.scopes)
|
||||
.into_iter()
|
||||
.map(|s| *s)
|
||||
.copied()
|
||||
.collect();
|
||||
Scopes {
|
||||
scopes: newset,
|
||||
|
||||
@@ -242,10 +242,10 @@ impl StatusBuilder {
|
||||
status: self.status.clone(),
|
||||
in_reply_to_id: self.in_reply_to_id.clone(),
|
||||
media_ids: self.media_ids.clone(),
|
||||
sensitive: self.sensitive.clone(),
|
||||
sensitive: self.sensitive,
|
||||
spoiler_text: self.spoiler_text.clone(),
|
||||
visibility: self.visibility.clone(),
|
||||
language: self.language.clone(),
|
||||
visibility: self.visibility,
|
||||
language: self.language,
|
||||
content_type: self.content_type.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user