Skip to content

Commit

Permalink
Reformatted with rustfmt 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
James Hurst committed Jun 24, 2017
1 parent a6cffbe commit f3a3de8
Show file tree
Hide file tree
Showing 22 changed files with 1,222 additions and 880 deletions.
12 changes: 9 additions & 3 deletions benches/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ use test::Bencher;
#[bench]
fn read_rss2sample(b: &mut Bencher) {
let input: &[u8] = include_bytes!("../tests/data/rss2sample.xml");
b.iter(|| { let _ = Channel::read_from(input).expect("failed to parse feed"); });
b.iter(|| {
let _ = Channel::read_from(input).expect("failed to parse feed");
});
}

#[bench]
fn read_itunes(b: &mut Bencher) {
let input: &[u8] = include_bytes!("../tests/data/itunes.xml");
b.iter(|| { let _ = Channel::read_from(input).expect("failed to parse feed"); });
b.iter(|| {
let _ = Channel::read_from(input).expect("failed to parse feed");
});
}

#[bench]
fn read_dublincore(b: &mut Bencher) {
let input: &[u8] = include_bytes!("../tests/data/dublincore.xml");
b.iter(|| { let _ = Channel::read_from(input).expect("failed to parse feed"); });
b.iter(|| {
let _ = Channel::read_from(input).expect("failed to parse feed");
});
}
12 changes: 9 additions & 3 deletions benches/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,25 @@ use test::Bencher;
fn write_rss2sample(b: &mut Bencher) {
let input: &[u8] = include_bytes!("../tests/data/rss2sample.xml");
let channel = Channel::read_from(input).expect("failed to parse feed");
b.iter(|| { let _ = channel.write_to(sink()).expect("failed to write"); });
b.iter(|| {
let _ = channel.write_to(sink()).expect("failed to write");
});
}

#[bench]
fn write_itunes(b: &mut Bencher) {
let input: &[u8] = include_bytes!("../tests/data/itunes.xml");
let channel = Channel::read_from(input).expect("failed to parse feed");
b.iter(|| { let _ = channel.write_to(sink()).expect("failed to write"); });
b.iter(|| {
let _ = channel.write_to(sink()).expect("failed to write");
});
}

#[bench]
fn write_dublincore(b: &mut Bencher) {
let input: &[u8] = include_bytes!("../tests/data/dublincore.xml");
let channel = Channel::read_from(input).expect("failed to parse feed");
b.iter(|| { let _ = channel.write_to(sink()).expect("failed to write"); });
b.iter(|| {
let _ = channel.write_to(sink()).expect("failed to write");
});
}
24 changes: 14 additions & 10 deletions src/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ impl Category {
}

impl FromXml for Category {
fn from_xml<R: ::std::io::BufRead>(reader: &mut Reader<R>,
mut atts: Attributes)
-> Result<Self, Error> {
fn from_xml<R: ::std::io::BufRead>(
reader: &mut Reader<R>,
mut atts: Attributes,
) -> Result<Self, Error> {
let mut domain = None;

for attr in atts.with_checks(false) {
Expand All @@ -92,9 +93,9 @@ impl FromXml for Category {
let content = element_text(reader)?.unwrap_or_default();

Ok(Category {
name: content,
domain: domain,
})
name: content,
domain: domain,
})
}
}

Expand All @@ -106,8 +107,9 @@ impl ToXml for Category {
element.push_attribute(("domain", &**domain));
}
writer.write_event(Event::Start(element))?;
writer
.write_event(Event::Text(BytesText::borrowed(self.name.as_bytes())))?;
writer.write_event(
Event::Text(BytesText::borrowed(self.name.as_bytes())),
)?;
writer.write_event(Event::End(BytesEnd::borrowed(name)))?;
Ok(())
}
Expand Down Expand Up @@ -151,7 +153,8 @@ impl CategoryBuilder {
/// .name("Podcast");
/// ```
pub fn name<S>(mut self, name: S) -> CategoryBuilder
where S: Into<String>
where
S: Into<String>,
{
self.name = name.into();
self
Expand All @@ -168,7 +171,8 @@ impl CategoryBuilder {
/// .domain("http://www.example.com".to_string());
/// ```
pub fn domain<V>(mut self, domain: V) -> CategoryBuilder
where V: Into<Option<String>>
where
V: Into<Option<String>>,
{
self.domain = domain.into();
self
Expand Down

0 comments on commit f3a3de8

Please sign in to comment.