rustfmt pass

This commit is contained in:
Paul Woolcock
2018-08-23 10:35:26 -04:00
parent d617d74fa4
commit 8636e690c3
18 changed files with 337 additions and 249 deletions
+15 -14
View File
@@ -2,9 +2,9 @@
use chrono::prelude::*;
use reqwest::multipart::Form;
use ::Result;
use std::path::Path;
use serde::de::{self, Deserialize, Deserializer, Unexpected};
use std::path::Path;
use Result;
/// A struct representing an Account.
#[derive(Debug, Clone, Deserialize)]
@@ -57,9 +57,7 @@ pub struct Source {
note: String,
}
fn string_or_bool<'de, D: Deserializer<'de>>(val: D)
-> ::std::result::Result<bool, D::Error>
{
fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bool, D::Error> {
#[derive(Clone, Debug, Deserialize)]
#[serde(untagged)]
pub enum BoolOrString {
@@ -68,16 +66,19 @@ fn string_or_bool<'de, D: Deserializer<'de>>(val: D)
}
Ok(match BoolOrString::deserialize(val)? {
BoolOrString::Bool(b) => b,
BoolOrString::Str(ref s) => {
if s == "true" {
true
} else if s == "false" {
false
} else {
return Err(de::Error::invalid_value(Unexpected::Str(s), &"true or false"));
}
BoolOrString::Bool(b) => b,
BoolOrString::Str(ref s) => {
if s == "true" {
true
} else if s == "false" {
false
} else {
return Err(de::Error::invalid_value(
Unexpected::Str(s),
&"true or false",
));
}
},
})
}
+1 -2
View File
@@ -6,7 +6,7 @@ pub struct Attachment {
/// ID of the attachment.
pub id: String,
/// The media type of an attachment.
#[serde(rename="type")]
#[serde(rename = "type")]
pub media_type: MediaType,
/// URL of the locally hosted version of the image.
pub url: String,
@@ -43,7 +43,6 @@ pub struct ImageDetails {
size: String,
/// The aspect ratio of the attachment.
aspect: f64,
}
/// The type of media attachment.
+4 -5
View File
@@ -18,7 +18,7 @@ use serde::Deserialize;
/// let client = Mastodon::from(data);
/// let statuses = client.statuses("user-id", None)?;
/// for status in statuses.items_iter() {
/// // do something with `status`
/// // do something with `status`
/// }
/// # Ok(())
/// # }
@@ -33,7 +33,7 @@ pub(crate) struct ItemsIter<'a, T: Clone + for<'de> Deserialize<'de>> {
impl<'a, T: Clone + for<'de> Deserialize<'de>> ItemsIter<'a, T> {
pub(crate) fn new(page: Page<'a, T>) -> ItemsIter<'a, T> {
ItemsIter {
page: page,
page,
buffer: vec![],
cur_idx: 0,
use_initial: true,
@@ -41,8 +41,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>> ItemsIter<'a, T> {
}
fn need_next_page(&self) -> bool {
self.buffer.is_empty() ||
self.cur_idx == self.buffer.len()
self.buffer.is_empty() || self.cur_idx == self.buffer.len()
}
fn fill_next_page(&mut self) -> Option<()> {
@@ -61,7 +60,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>> ItemsIter<'a, T> {
}
}
impl<'a, T: Clone+ for<'de> Deserialize<'de>> Iterator for ItemsIter<'a, T> {
impl<'a, T: Clone + for<'de> Deserialize<'de>> Iterator for ItemsIter<'a, T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
+19 -16
View File
@@ -3,10 +3,10 @@ pub mod attachment;
pub mod card;
pub mod context;
pub mod instance;
pub(crate) mod itemsiter;
pub mod list;
pub mod mention;
pub mod notification;
pub(crate) mod itemsiter;
pub mod relationship;
pub mod report;
pub mod search_result;
@@ -17,19 +17,22 @@ pub mod status;
pub struct Empty {}
pub mod prelude {
//! The purpose of this module is to alleviate imports of many common structs
//! by adding a glob import to the top of mastodon heavy modules:
pub use super::Empty;
pub use super::account::{Account, CredientialsBuilder, Source};
pub use super::attachment::{Attachment, MediaType};
pub use super::card::Card;
pub use super::context::Context;
pub use super::instance::*;
pub use super::list::List;
pub use super::mention::Mention;
pub use super::notification::Notification;
pub use super::relationship::Relationship;
pub use super::report::Report;
pub use super::search_result::SearchResult;
pub use super::status::{Application, Emoji, Status};
//! The purpose of this module is to alleviate imports of many common
//! structs by adding a glob import to the top of mastodon heavy
//! modules:
pub use super::{
account::{Account, CredientialsBuilder, Source},
attachment::{Attachment, MediaType},
card::Card,
context::Context,
instance::*,
list::List,
mention::Mention,
notification::Notification,
relationship::Relationship,
report::Report,
search_result::SearchResult,
status::{Application, Emoji, Status},
Empty,
};
}
+1 -2
View File
@@ -1,8 +1,7 @@
//! Module containing all info about notifications.
use super::{account::Account, status::Status};
use chrono::prelude::*;
use super::account::Account;
use super::status::Status;
/// A struct containing info about a notification.
#[derive(Debug, Clone, Deserialize)]
+1 -1
View File
@@ -1,7 +1,7 @@
//! Module containing all info relating to a status.
use chrono::prelude::*;
use super::prelude::*;
use chrono::prelude::*;
use status_builder::Visibility;
/// A status from the instance.