Skip to content

Commit ef6e6e5

Browse files
committed
style: fix all clippy lints
Suggestions were found by running cargo clippy --all-targets --all-features -- -D warnings using clippy 0.1.69 (84c898d 2023-04-16) Signed-off-by: Luke Hsiao <luke@hsiao.dev>
1 parent d01eca5 commit ef6e6e5

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

examples/read.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ fn main() {
1717
</feed>
1818
"#;
1919

20-
match atom_str.parse::<Feed>().unwrap() {
21-
Feed::Atom(atom_feed) => println!(
20+
if let Feed::Atom(atom_feed) = atom_str.parse::<Feed>().unwrap() {
21+
println!(
2222
"Atom feed first entry: {:?}",
2323
atom_feed.entries()[0].title()
24-
),
25-
_ => {}
24+
);
2625
};
2726

2827
let rss_str = r#"
@@ -41,8 +40,7 @@ fn main() {
4140
</rss>
4241
"#;
4342

44-
match rss_str.parse::<Feed>().unwrap() {
45-
Feed::RSS(rss_feed) => println!("RSS feed first entry: {:?}", rss_feed.items()[0].title()),
46-
_ => {}
43+
if let Feed::RSS(rss_feed) = rss_str.parse::<Feed>().unwrap() {
44+
println!("RSS feed first entry: {:?}", rss_feed.items()[0].title());
4745
};
4846
}

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl FromStr for Feed {
2323
impl ToString for Feed {
2424
fn to_string(&self) -> String {
2525
match self {
26-
&Feed::Atom(ref atom_feed) => atom_feed.to_string(),
27-
&Feed::RSS(ref rss_channel) => rss_channel.to_string(),
26+
Feed::Atom(atom_feed) => atom_feed.to_string(),
27+
Feed::RSS(rss_channel) => rss_channel.to_string(),
2828
}
2929
}
3030
}
@@ -44,7 +44,7 @@ mod test {
4444
let mut atom_string = String::new();
4545
file.read_to_string(&mut atom_string).unwrap();
4646
let feed = Feed::from_str(&atom_string).unwrap();
47-
assert!(feed.to_string().len() > 0);
47+
assert!(!feed.to_string().is_empty());
4848
}
4949

5050
// Source: https://github.com/frewsxcv/rust-rss/blob/master/src/lib.rs
@@ -54,7 +54,7 @@ mod test {
5454
let mut rss_string = String::new();
5555
file.read_to_string(&mut rss_string).unwrap();
5656
let rss = Feed::from_str(&rss_string).unwrap();
57-
assert!(rss.to_string().len() > 0);
57+
assert!(!rss.to_string().is_empty());
5858
}
5959

6060
// Source: https://github.com/vtduncan/rust-atom/blob/master/src/lib.rs
@@ -66,11 +66,11 @@ mod test {
6666

6767
let entry = atom_syndication::EntryBuilder::default()
6868
.title("My first post!")
69-
.content(
69+
.content(Some(
7070
atom_syndication::ContentBuilder::default()
71-
.value("This is my first post".to_string())
71+
.value(Some("This is my first post".to_string()))
7272
.build(),
73-
)
73+
))
7474
.build();
7575

7676
let feed = atom_syndication::FeedBuilder::default()
@@ -86,9 +86,9 @@ mod test {
8686
#[test]
8787
fn test_rss_to_string() {
8888
let item = rss::ItemBuilder::default()
89-
.title("My first post!".to_string())
90-
.link("http://myblog.com/post1".to_string())
91-
.description("This is my first post".to_string())
89+
.title(Some("My first post!".to_string()))
90+
.link(Some("http://myblog.com/post1".to_string()))
91+
.description(Some("This is my first post".to_string()))
9292
.build();
9393

9494
let channel = rss::ChannelBuilder::default()

0 commit comments

Comments
 (0)