Run rustfmt.

This commit is contained in:
Jordan Petridis
2017-12-09 05:57:16 +02:00
parent 5b19274e6a
commit b528c48e3b
10 changed files with 68 additions and 67 deletions
+5 -4
View File
@@ -198,9 +198,10 @@ pub fn update_none_to_played_now(parent: &Podcast) -> Result<usize> {
let epoch_now = Utc::now().timestamp() as i32;
con.transaction(|| -> Result<usize> {
Ok(diesel::update(
Episode::belonging_to(parent).filter(played.is_null()),
).set(played.eq(Some(epoch_now)))
.execute(&*con)?)
Ok(
diesel::update(Episode::belonging_to(parent).filter(played.is_null()))
.set(played.eq(Some(epoch_now)))
.execute(&*con)?,
)
})
}
+4 -5
View File
@@ -276,13 +276,12 @@ mod tests {
f2.get_episodes().unwrap()
};
eps1.into_par_iter()
.zip(eps2)
.into_par_iter()
.for_each(|(ep1, ep2): (Episode, Episode)| {
eps1.into_par_iter().zip(eps2).into_par_iter().for_each(
|(ep1, ep2): (Episode, Episode)| {
assert_eq!(ep1, ep2);
assert_eq!(ep1.id(), ep2.id());
assert_eq!(ep1.podcast_id(), ep2.podcast_id());
});
},
);
}
}
+1 -1
View File
@@ -37,6 +37,7 @@ extern crate diesel_migrations;
#[macro_use]
extern crate derive_builder;
extern crate ammonia;
extern crate chrono;
extern crate r2d2;
extern crate r2d2_diesel;
@@ -46,7 +47,6 @@ extern crate rfc822_sanitizer;
extern crate rss;
extern crate url;
extern crate xdg;
extern crate ammonia;
#[allow(missing_docs)]
pub mod dbqueries;
+3 -3
View File
@@ -342,9 +342,9 @@ impl<'a> Source {
let lmod = headers.get::<LastModified>();
// FIXME: This dsnt work most of the time apparently
if self.http_etag() != etag.map(|x| x.tag())
|| self.last_modified != lmod.map(|x| format!("{}", x))
{
if self.http_etag() != etag.map(|x| x.tag()) || self.last_modified != lmod.map(|x| {
format!("{}", x)
}) {
self.http_etag = etag.map(|x| x.tag().to_string().to_owned());
self.last_modified = lmod.map(|x| format!("{}", x));
self.save()?;
+20 -22
View File
@@ -62,19 +62,17 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result<NewEpisode> {
let length = item.enclosure().map(|x| x.length().parse().unwrap_or(0));
Ok(
NewEpisodeBuilder::default()
.title(title)
.uri(uri)
.description(description)
.length(length)
.published_date(pub_date)
.epoch(epoch)
.guid(guid)
.podcast_id(parent_id)
.build()
.unwrap()
)
Ok(NewEpisodeBuilder::default()
.title(title)
.uri(uri)
.description(description)
.length(length)
.published_date(pub_date)
.epoch(epoch)
.guid(guid)
.podcast_id(parent_id)
.build()
.unwrap())
}
@@ -278,9 +276,9 @@ mod tests {
let firstitem = channel.items().first().unwrap();
let descr = "Audit your network with a couple of easy commands on Kali Linux. Chris \
decides to blow off a little steam by attacking his IoT devices, Wes has \
the scope on Equifax blaming open source &amp; the Beard just saved the \
show. Its a really packed episode!";
decides to blow off a little steam by attacking his IoT devices, Wes has the \
scope on Equifax blaming open source &amp; the Beard just saved the show. \
Its a really packed episode!";
let i = new_episode(&firstitem, 0).unwrap();
assert_eq!(i.title(), Some("Hacking Devices with Kali Linux | LUP 214"));
@@ -321,9 +319,8 @@ mod tests {
let channel = Channel::read_from(BufReader::new(file)).unwrap();
let firstitem = channel.items().iter().nth(9).unwrap();
let descr = "This week we look at <a \
href=\"https://github.com/rust-lang/rfcs/pull/2094\" rel=\"noopener \
noreferrer\">RFC 2094</a> \"Non-lexical lifetimes\"";
let descr = "This week we look at <a href=\"https://github.com/rust-lang/rfcs/pull/2094\" \
rel=\"noopener noreferrer\">RFC 2094</a> \"Non-lexical lifetimes\"";
let i = new_episode(&firstitem, 0).unwrap();
assert_eq!(i.title(), Some("Episode #9 - A Once in a Lifetime RFC"));
@@ -344,9 +341,10 @@ mod tests {
let second = channel.items().iter().nth(8).unwrap();
let i2 = new_episode(&second, 0).unwrap();
let descr2 = "This week we look at <a href=\"https://github.com/rust-lang/rfcs/pull/2071\" \
rel=\"noopener noreferrer\">RFC 2071</a> \"Add impl Trait type alias and \
variable declarations\"";
let descr2 = "This week we look at <a \
href=\"https://github.com/rust-lang/rfcs/pull/2071\" rel=\"noopener \
noreferrer\">RFC 2071</a> \"Add impl Trait type alias and variable \
declarations\"";
assert_eq!(i2.title(), Some("Episode #8 - An Existential Crisis"));
assert_eq!(
i2.uri(),
+5 -4
View File
@@ -109,9 +109,10 @@ pub fn url_cleaner(s: &str) -> String {
// TODO: Docs
pub fn replace_extra_spaces(s: &str) -> String {
s.lines()
.map(|x| x.split_whitespace().collect::<Vec<_>>().join(" "))
.filter(|x| !x.is_empty())
.collect::<Vec<_>>().join("\n")
.map(|x| x.split_whitespace().collect::<Vec<_>>().join(" "))
.filter(|x| !x.is_empty())
.collect::<Vec<_>>()
.join("\n")
}
#[cfg(test)]
@@ -151,7 +152,7 @@ mod tests {
.unwrap()
.into_episode(&con)
.unwrap();
let mut ep1 = dbqueries::get_episode_from_uri(&con, "foo_bar").unwrap();
let mut ep2 = dbqueries::get_episode_from_uri(&con, "bar_baz").unwrap();
ep1.set_local_uri(Some(valid_path.to_str().unwrap()));