Skip to content

Commit

Permalink
Formatted with rustfmt-nightly 0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
James Hurst committed Jun 24, 2017
1 parent 0bba52e commit 5a5812c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 85 deletions.
5 changes: 2 additions & 3 deletions src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ impl ToXml for Content {
writer.write_event(Event::Start(element))?;

if let Some(ref value) = self.value {
writer.write_event(
Event::Text(BytesText::borrowed(value.as_bytes())),
)?;
writer
.write_event(Event::Text(BytesText::borrowed(value.as_bytes())))?;
}

writer.write_event(Event::End(BytesEnd::borrowed(name)))?;
Expand Down
37 changes: 16 additions & 21 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,26 +496,24 @@ impl FromXml for Entry {
b"title" => entry.title = atom_text(reader)?.unwrap_or_default(),
b"updated" => entry.updated = atom_text(reader)?.unwrap_or_default(),
b"author" => {
entry.authors.push(
Person::from_xml(reader, element.attributes())?,
)
entry
.authors
.push(Person::from_xml(reader, element.attributes())?)
}
b"category" => {
entry.categories.push(Category::from_xml(
reader,
element.attributes(),
)?)
entry
.categories
.push(Category::from_xml(reader, element.attributes())?)
}
b"contributor" => {
entry.contributors.push(Person::from_xml(
reader,
element.attributes(),
)?)
entry
.contributors
.push(Person::from_xml(reader, element.attributes())?)
}
b"link" => {
entry.links.push(
Link::from_xml(reader, element.attributes())?,
)
entry
.links
.push(Link::from_xml(reader, element.attributes())?)
}
b"published" => entry.published = atom_text(reader)?,
b"rights" => entry.rights = atom_text(reader)?,
Expand Down Expand Up @@ -556,18 +554,15 @@ impl FromXml for Entry {
impl ToXml for Entry {
fn to_xml<W: Write>(&self, writer: &mut Writer<W>) -> Result<(), XmlError> {
let name = b"entry";
writer.write_event(
Event::Start(BytesStart::borrowed(name, name.len())),
)?;
writer
.write_event(Event::Start(BytesStart::borrowed(name, name.len())))?;
writer.write_text_element(b"title", &*self.title)?;
writer.write_text_element(b"id", &*self.id)?;
writer.write_text_element(b"updated", &*self.updated)?;
writer.write_objects_named(&self.authors, "author")?;
writer.write_objects(&self.categories)?;
writer.write_objects_named(
&self.contributors,
"contributor",
)?;
writer
.write_objects_named(&self.contributors, "contributor")?;
writer.write_objects(&self.links)?;

if let Some(ref published) = self.published {
Expand Down
5 changes: 2 additions & 3 deletions src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,8 @@ impl ToXml for Extension {
writer.write_event(Event::Start(element))?;

if let Some(value) = self.value.as_ref() {
writer.write_event(
Event::Text(BytesText::borrowed(value.as_bytes())),
)?;
writer
.write_event(Event::Text(BytesText::borrowed(value.as_bytes())))?;
}

for extension in self.children.values().flat_map(|extensions| extensions) {
Expand Down
33 changes: 12 additions & 21 deletions src/feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,39 +641,32 @@ impl FromXml for Feed {
b"id" => feed.id = atom_text(reader)?.unwrap_or_default(),
b"updated" => feed.updated = atom_text(reader)?.unwrap_or_default(),
b"author" => {
feed.authors.push(
Person::from_xml(reader, element.attributes())?,
)
feed.authors
.push(Person::from_xml(reader, element.attributes())?)
}
b"category" => {
feed.categories.push(Category::from_xml(
reader,
element.attributes(),
)?)
feed.categories
.push(Category::from_xml(reader, element.attributes())?)
}
b"contributor" => {
feed.contributors.push(Person::from_xml(
reader,
element.attributes(),
)?)
feed.contributors
.push(Person::from_xml(reader, element.attributes())?)
}
b"generator" => {
feed.generator =
Some(Generator::from_xml(reader, element.attributes())?)
}
b"icon" => feed.icon = atom_text(reader)?,
b"link" => {
feed.links.push(
Link::from_xml(reader, element.attributes())?,
)
feed.links
.push(Link::from_xml(reader, element.attributes())?)
}
b"logo" => feed.logo = atom_text(reader)?,
b"rights" => feed.rights = atom_text(reader)?,
b"subtitle" => feed.subtitle = atom_text(reader)?,
b"entry" => {
feed.entries.push(
Entry::from_xml(reader, element.attributes())?,
)
feed.entries
.push(Entry::from_xml(reader, element.attributes())?)
}
n => {
if let Some((ns, name)) = extension_name(element.name()) {
Expand Down Expand Up @@ -717,10 +710,8 @@ impl ToXml for Feed {
writer.write_text_element(b"updated", &*self.updated)?;
writer.write_objects_named(&self.authors, "author")?;
writer.write_objects(&self.categories)?;
writer.write_objects_named(
&self.contributors,
"contributor",
)?;
writer
.write_objects_named(&self.contributors, "contributor")?;

if let Some(ref generator) = self.generator {
writer.write_object(generator)?;
Expand Down
5 changes: 2 additions & 3 deletions src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ impl ToXml for Generator {
}

writer.write_event(Event::Start(element))?;
writer.write_event(Event::Text(
BytesText::borrowed(self.value.as_bytes()),
))?;
writer
.write_event(Event::Text(BytesText::borrowed(self.value.as_bytes())))?;
writer.write_event(Event::End(BytesEnd::borrowed(name)))?;

Ok(())
Expand Down
5 changes: 2 additions & 3 deletions src/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ impl ToXmlNamed for Person {
N: AsRef<[u8]>,
{
let name = name.as_ref();
writer.write_event(
Event::Start(BytesStart::borrowed(name, name.len())),
)?;
writer
.write_event(Event::Start(BytesStart::borrowed(name, name.len())))?;
writer.write_text_element(b"name", &*self.name)?;

if let Some(ref email) = self.email {
Expand Down
38 changes: 16 additions & 22 deletions src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,32 +443,29 @@ impl FromXml for Source {
b"title" => source.title = atom_text(reader)?.unwrap_or_default(),
b"updated" => source.updated = atom_text(reader)?.unwrap_or_default(),
b"author" => {
source.authors.push(Person::from_xml(
reader,
element.attributes(),
)?)
source
.authors
.push(Person::from_xml(reader, element.attributes())?)
}
b"category" => {
source.categories.push(Category::from_xml(
reader,
element.attributes(),
)?)
source
.categories
.push(Category::from_xml(reader, element.attributes())?)
}
b"contributor" => {
source.contributors.push(Person::from_xml(
reader,
element.attributes(),
)?)
source
.contributors
.push(Person::from_xml(reader, element.attributes())?)
}
b"generator" => {
source.generator =
Some(Generator::from_xml(reader, element.attributes())?)
}
b"icon" => source.icon = atom_text(reader)?,
b"link" => {
source.links.push(
Link::from_xml(reader, element.attributes())?,
)
source
.links
.push(Link::from_xml(reader, element.attributes())?)
}
b"logo" => source.logo = atom_text(reader)?,
b"rights" => source.rights = atom_text(reader)?,
Expand All @@ -491,18 +488,15 @@ impl FromXml for Source {
impl ToXml for Source {
fn to_xml<W: Write>(&self, writer: &mut Writer<W>) -> Result<(), XmlError> {
let name = b"source";
writer.write_event(
Event::Start(BytesStart::borrowed(name, name.len())),
)?;
writer
.write_event(Event::Start(BytesStart::borrowed(name, name.len())))?;
writer.write_text_element(b"title", &*self.title)?;
writer.write_text_element(b"id", &*self.id)?;
writer.write_text_element(b"updated", &*self.updated)?;
writer.write_objects_named(&self.authors, "author")?;
writer.write_objects(&self.categories)?;
writer.write_objects_named(
&self.contributors,
"contributor",
)?;
writer
.write_objects_named(&self.contributors, "contributor")?;

if let Some(ref generator) = self.generator {
writer.write_object(generator)?;
Expand Down
8 changes: 2 additions & 6 deletions src/toxml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,8 @@ impl<W: Write> WriterExt for Writer<W> {
T: AsRef<[u8]>,
{
let name = name.as_ref();
self.write_event(
Event::Start(BytesStart::borrowed(name, name.len())),
)?;
self.write_event(
Event::Text(BytesText::borrowed(text.as_ref())),
)?;
self.write_event(Event::Start(BytesStart::borrowed(name, name.len())))?;
self.write_event(Event::Text(BytesText::borrowed(text.as_ref())))?;
self.write_event(Event::End(BytesEnd::borrowed(name)))?;
Ok(())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ fn content_text_xhtml() {
let content = feed.entries().first().unwrap().content().unwrap();
assert_eq!(
content.value(),
Some(
"<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>Entry content</p></div>",
)
Some("<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>Entry content</p></div>",)
);
assert_eq!(content.content_type(), Some("xhtml"));
}

0 comments on commit 5a5812c

Please sign in to comment.