Skip to content

Commit

Permalink
Merge pull request #93 from rust-syndication/fix-clippy-warnings
Browse files Browse the repository at this point in the history
fix clippy warnings
  • Loading branch information
andy128k committed Jun 7, 2020
2 parents 885e86a + 2036e7a commit 2663695
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Category {
/// assert_eq!(category.domain(), Some("http://example.com"));
/// ```
pub fn domain(&self) -> Option<&str> {
self.domain.as_ref().map(String::as_str)
self.domain.as_deref()
}

/// Set the domain of this category.
Expand Down
18 changes: 9 additions & 9 deletions src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Channel {
/// assert_eq!(channel.copyright(), Some("© 2017 John Doe"));
/// ```
pub fn copyright(&self) -> Option<&str> {
self.copyright.as_ref().map(String::as_str)
self.copyright.as_deref()
}

/// Set the copyright notice for this channel.
Expand Down Expand Up @@ -260,7 +260,7 @@ impl Channel {
/// assert_eq!(channel.managing_editor(), Some("johndoe@example.com"));
/// ```
pub fn managing_editor(&self) -> Option<&str> {
self.managing_editor.as_ref().map(String::as_str)
self.managing_editor.as_deref()
}

/// Set the email address for the managing editor of this channel.
Expand Down Expand Up @@ -293,7 +293,7 @@ impl Channel {
/// assert_eq!(channel.webmaster(), Some("johndoe@example.com"));
/// ```
pub fn webmaster(&self) -> Option<&str> {
self.webmaster.as_ref().map(String::as_str)
self.webmaster.as_deref()
}

/// Set the email address for webmaster of this channel.
Expand Down Expand Up @@ -325,7 +325,7 @@ impl Channel {
/// assert_eq!(channel.pub_date(), Some("Mon, 1 Jan 2017 12:00:00 GMT"));
/// ```
pub fn pub_date(&self) -> Option<&str> {
self.pub_date.as_ref().map(String::as_str)
self.pub_date.as_deref()
}

/// Set the publication date for the content of this channel as an RFC822 timestamp.
Expand Down Expand Up @@ -357,7 +357,7 @@ impl Channel {
/// assert_eq!(channel.last_build_date(), Some("Mon, 1 Jan 2017 12:00:00 GMT"));
/// ```
pub fn last_build_date(&self) -> Option<&str> {
self.last_build_date.as_ref().map(String::as_str)
self.last_build_date.as_deref()
}

/// Set the time that the content of this channel was last changed as an RFC822 timestamp.
Expand Down Expand Up @@ -426,7 +426,7 @@ impl Channel {
/// assert_eq!(channel.generator(), Some("Program Name"));
/// ```
pub fn generator(&self) -> Option<&str> {
self.generator.as_ref().map(String::as_str)
self.generator.as_deref()
}

/// Set a string indicating the program used to generate the channel.
Expand Down Expand Up @@ -458,7 +458,7 @@ impl Channel {
/// assert_eq!(channel.docs(), Some("https://cyber.harvard.edu/rss/rss.html"));
/// ```
pub fn docs(&self) -> Option<&str> {
self.docs.as_ref().map(String::as_str)
self.docs.as_deref()
}

/// Set a URL that points to the documentation of the RSS format used in this channel.
Expand Down Expand Up @@ -525,7 +525,7 @@ impl Channel {
/// assert_eq!(channel.ttl(), Some("60"));
/// ```
pub fn ttl(&self) -> Option<&str> {
self.ttl.as_ref().map(String::as_str)
self.ttl.as_deref()
}

/// Set the time to live of this channel. This indicates the number of minutes the
Expand Down Expand Up @@ -580,7 +580,7 @@ impl Channel {

/// Return the [PICS](https://www.w3.org/PICS/) rating for this channel.
pub fn rating(&self) -> Option<&str> {
self.rating.as_ref().map(String::as_str)
self.rating.as_deref()
}

/// Set the [PICS](https://www.w3.org/PICS/) rating for this channel.
Expand Down
3 changes: 1 addition & 2 deletions src/extension/itunes/itunes_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use quick_xml::Error as XmlError;
use quick_xml::Writer;

use crate::toxml::ToXml;
use std::ops::Deref;

/// A category for an iTunes podcast.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -72,7 +71,7 @@ impl ITunesCategory {
/// assert!(category.subcategory().is_some());
/// ```
pub fn subcategory(&self) -> Option<&ITunesCategory> {
self.subcategory.as_ref().map(|x| x.deref())
self.subcategory.as_deref()
}

/// Set the subcategory for this category.
Expand Down
18 changes: 9 additions & 9 deletions src/extension/itunes/itunes_channel_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.author(), Some("John Doe"));
/// ```
pub fn author(&self) -> Option<&str> {
self.author.as_ref().map(String::as_str)
self.author.as_deref()
}

/// Set the author of this podcast.
Expand Down Expand Up @@ -101,7 +101,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.block(), Some("Yes"));
/// ```
pub fn block(&self) -> Option<&str> {
self.block.as_ref().map(String::as_str)
self.block.as_deref()
}

/// Set whether the podcast should be blocked from appearing in the iTunes Store.
Expand Down Expand Up @@ -173,7 +173,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.image(), Some("http://example.com/artwork.png"));
/// ```
pub fn image(&self) -> Option<&str> {
self.image.as_ref().map(String::as_str)
self.image.as_deref()
}

/// Set the artwork URL for the podcast.
Expand Down Expand Up @@ -209,7 +209,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.explicit(), Some("Yes"));
/// ```
pub fn explicit(&self) -> Option<&str> {
self.explicit.as_ref().map(String::as_str)
self.explicit.as_deref()
}

/// Set whether the podcast contains explicit content.
Expand Down Expand Up @@ -247,7 +247,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.complete(), Some("Yes"));
/// ```
pub fn complete(&self) -> Option<&str> {
self.complete.as_ref().map(String::as_str)
self.complete.as_deref()
}

/// Set whether the podcast is complete and no new episodes will be posted.
Expand Down Expand Up @@ -281,7 +281,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.new_feed_url(), Some("http://example.com/feed"));
/// ```
pub fn new_feed_url(&self) -> Option<&str> {
self.new_feed_url.as_ref().map(String::as_str)
self.new_feed_url.as_deref()
}

/// Set the new feed URL for this podcast.
Expand Down Expand Up @@ -345,7 +345,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.subtitle(), Some("A podcast"));
/// ```
pub fn subtitle(&self) -> Option<&str> {
self.subtitle.as_ref().map(String::as_str)
self.subtitle.as_deref()
}

/// Set the description of this podcast.
Expand Down Expand Up @@ -377,7 +377,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.summary(), Some("A podcast"));
/// ```
pub fn summary(&self) -> Option<&str> {
self.summary.as_ref().map(String::as_str)
self.summary.as_deref()
}

/// Set the summary for this podcast.
Expand Down Expand Up @@ -411,7 +411,7 @@ impl ITunesChannelExtension {
/// assert_eq!(extension.keywords(), Some("technology"));
/// ```
pub fn keywords(&self) -> Option<&str> {
self.keywords.as_ref().map(String::as_str)
self.keywords.as_deref()
}

/// Set the keywords for this podcast.
Expand Down
20 changes: 10 additions & 10 deletions src/extension/itunes/itunes_item_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.author(), Some("John Doe"));
/// ```
pub fn author(&self) -> Option<&str> {
self.author.as_ref().map(String::as_str)
self.author.as_deref()
}

/// Set the author of this podcast episode.
Expand Down Expand Up @@ -99,7 +99,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.block(), Some("Yes"));
/// ```
pub fn block(&self) -> Option<&str> {
self.block.as_ref().map(String::as_str)
self.block.as_deref()
}

/// Set whether this podcast episode should be blocked from appearing in the iTunes Store.
Expand Down Expand Up @@ -134,7 +134,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.image(), Some("http://example.com/artwork.png"));
/// ```
pub fn image(&self) -> Option<&str> {
self.image.as_ref().map(String::as_str)
self.image.as_deref()
}

/// Set the artwork URL for this podcast episode.
Expand Down Expand Up @@ -168,7 +168,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.duration(), Some("1:00"));
/// ```
pub fn duration(&self) -> Option<&str> {
self.duration.as_ref().map(String::as_str)
self.duration.as_deref()
}

/// Set the duration of this podcast episode.
Expand Down Expand Up @@ -206,7 +206,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.explicit(), Some("Yes"));
/// ```
pub fn explicit(&self) -> Option<&str> {
self.explicit.as_ref().map(String::as_str)
self.explicit.as_deref()
}

/// Set whether this podcast episode contains explicit content.
Expand Down Expand Up @@ -244,7 +244,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.closed_captioned(), Some("Yes"));
/// ```
pub fn closed_captioned(&self) -> Option<&str> {
self.closed_captioned.as_ref().map(String::as_str)
self.closed_captioned.as_deref()
}

/// Set whether this podcast episode contains embedded closed captioning.
Expand Down Expand Up @@ -278,7 +278,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.order(), Some("1"));
/// ```
pub fn order(&self) -> Option<&str> {
self.order.as_ref().map(String::as_str)
self.order.as_deref()
}

/// Set the value used to override the default sorting order for episodes.
Expand Down Expand Up @@ -310,7 +310,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.subtitle(), Some("An episode"));
/// ```
pub fn subtitle(&self) -> Option<&str> {
self.subtitle.as_ref().map(String::as_str)
self.subtitle.as_deref()
}

/// Set the description of this podcast episode.
Expand Down Expand Up @@ -342,7 +342,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.summary(), Some("An episode"));
/// ```
pub fn summary(&self) -> Option<&str> {
self.summary.as_ref().map(String::as_str)
self.summary.as_deref()
}

/// Set the summary for this podcast episode.
Expand Down Expand Up @@ -376,7 +376,7 @@ impl ITunesItemExtension {
/// assert_eq!(extension.keywords(), Some("technology"));
/// ```
pub fn keywords(&self) -> Option<&str> {
self.keywords.as_ref().map(String::as_str)
self.keywords.as_deref()
}

/// Set the keywords for this podcast episode.
Expand Down
4 changes: 2 additions & 2 deletions src/extension/itunes/itunes_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl ITunesOwner {
/// assert_eq!(owner.name(), Some("John Doe"));
/// ```
pub fn name(&self) -> Option<&str> {
self.name.as_ref().map(String::as_str)
self.name.as_deref()
}

/// Set the name of this person.
Expand Down Expand Up @@ -70,7 +70,7 @@ impl ITunesOwner {
/// assert_eq!(owner.email(), Some("johndoe@example.com"));
/// ```
pub fn email(&self) -> Option<&str> {
self.email.as_ref().map(String::as_str)
self.email.as_deref()
}

/// Set the email of this person.
Expand Down
4 changes: 2 additions & 2 deletions src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Extension {

/// Return the text content of this extension.
pub fn value(&self) -> Option<&str> {
self.value.as_ref().map(String::as_str)
self.value.as_deref()
}

/// Set the text content of this extension.
Expand Down Expand Up @@ -98,7 +98,7 @@ impl ToXml for Extension {
writer.write_event(Event::Text(BytesText::from_escaped(value.as_bytes())))?;
}

for extension in self.children.values().flat_map(|extensions| extensions) {
for extension in self.children.values().flatten() {
extension.to_xml(writer)?;
}

Expand Down
6 changes: 3 additions & 3 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Image {
/// image.set_width("80".to_string());
/// assert_eq!(image.width(), Some("80"));
pub fn width(&self) -> Option<&str> {
self.width.as_ref().map(String::as_str)
self.width.as_deref()
}

/// Set the width of this image.
Expand Down Expand Up @@ -182,7 +182,7 @@ impl Image {
/// assert_eq!(image.height(), Some("31"));
/// ```
pub fn height(&self) -> Option<&str> {
self.height.as_ref().map(String::as_str)
self.height.as_deref()
}

/// Set the height of this image.
Expand Down Expand Up @@ -216,7 +216,7 @@ impl Image {
/// assert_eq!(image.description(), Some("Example Title"));
/// ```
pub fn description(&self) -> Option<&str> {
self.description.as_ref().map(String::as_str)
self.description.as_deref()
}

/// Set the title for the link formed around this image.
Expand Down
Loading

0 comments on commit 2663695

Please sign in to comment.