Skip to content

Commit f6b8121

Browse files
committed
cargo clippy --fix
1 parent d7b1e50 commit f6b8121

File tree

6 files changed

+14
-27
lines changed

6 files changed

+14
-27
lines changed

examples/iterator_replace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
let doc = "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n";
2828
let orig = "my";
2929
let repl = "your";
30-
let html = replace_text(&doc, &orig, &repl);
30+
let html = replace_text(doc, orig, repl);
3131

3232
println!("{}", html);
3333
}

examples/sample.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn large() {
3838
let doc = "This is my input.\n\n1. Also [my](#) input.\n2. Certainly *my* input.\n";
3939
let orig = "my";
4040
let repl = "your";
41-
let html = replace_text(&doc, &orig, &repl);
41+
let html = replace_text(doc, orig, repl);
4242

4343
println!("{}", html);
4444
// Output:

examples/update-readme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4949

5050
if next_block_is_help_body {
5151
next_block_is_help_body = false;
52-
assert!(ncb.info == "" && ncb.literal.starts_with(HELP_START));
52+
assert!(ncb.info.is_empty() && ncb.literal.starts_with(HELP_START));
5353
let mut content = String::new();
5454
let mut cmd = std::process::Command::new("cargo");
5555
content.push_str(

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"cargo"
122122
"rustc"
123123
"rust-analyzer"
124+
"clippy"
124125
])
125126
pkgs.cargo-fuzz
126127
pkgs.python3

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ fn main() -> Result<(), Box<dyn Error>> {
369369
formatter(root, &options, &mut bw, &plugins)?;
370370
bw.flush()?;
371371
} else if cli.inplace {
372-
let output_filename = cli.files.unwrap().get(0).unwrap().clone();
372+
let output_filename = cli.files.unwrap().first().unwrap().clone();
373373
let mut bw = BufWriter::new(fs::File::create(output_filename)?);
374374
formatter(root, &options, &mut bw, &plugins)?;
375375
bw.flush()?;

src/tests/front_matter.rs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn round_trip_one_field() {
1010
let input = "---\nlayout: post\n---\nText\n";
1111
let root = parse_document(&arena, input, &options);
1212
let mut buf = Vec::new();
13-
format_commonmark(&root, &options, &mut buf).unwrap();
13+
format_commonmark(root, &options, &mut buf).unwrap();
1414
assert_eq!(&String::from_utf8(buf).unwrap(), input);
1515
}
1616

@@ -22,7 +22,7 @@ fn round_trip_wide_delimiter() {
2222
let input = "\u{04fc}\nlayout: post\n\u{04fc}\nText\n";
2323
let root = parse_document(&arena, input, &options);
2424
let mut buf = Vec::new();
25-
format_commonmark(&root, &options, &mut buf).unwrap();
25+
format_commonmark(root, &options, &mut buf).unwrap();
2626
assert_eq!(&String::from_utf8(buf).unwrap(), input);
2727
}
2828

@@ -105,9 +105,7 @@ fn trailing_space_open() {
105105
let root = parse_document(&arena, input, &options);
106106

107107
let found = root
108-
.descendants()
109-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
110-
.next();
108+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
111109

112110
assert!(found.is_none(), "no FrontMatter expected");
113111
}
@@ -122,9 +120,7 @@ fn leading_space_open() {
122120
let root = parse_document(&arena, input, &options);
123121

124122
let found = root
125-
.descendants()
126-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
127-
.next();
123+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
128124

129125
assert!(found.is_none(), "no FrontMatter expected");
130126
}
@@ -139,9 +135,7 @@ fn leading_space_close() {
139135
let root = parse_document(&arena, input, &options);
140136

141137
let found = root
142-
.descendants()
143-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
144-
.next();
138+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
145139

146140
assert!(found.is_none(), "no FrontMatter expected");
147141
}
@@ -156,9 +150,7 @@ fn trailing_space_close() {
156150
let root = parse_document(&arena, input, &options);
157151

158152
let found = root
159-
.descendants()
160-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
161-
.next();
153+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
162154

163155
assert!(found.is_none(), "no FrontMatter expected");
164156
}
@@ -173,9 +165,7 @@ fn second_line() {
173165
let root = parse_document(&arena, input, &options);
174166

175167
let found = root
176-
.descendants()
177-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
178-
.next();
168+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
179169

180170
assert!(found.is_none(), "no FrontMatter expected");
181171
}
@@ -190,9 +180,7 @@ fn fm_only_with_trailing_newline() {
190180
let root = parse_document(&arena, input, &options);
191181

192182
let found = root
193-
.descendants()
194-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
195-
.next();
183+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
196184

197185
assert!(found.is_some(), "front matter expected");
198186
}
@@ -207,9 +195,7 @@ fn fm_only_without_trailing_newline() {
207195
let root = parse_document(&arena, input, &options);
208196

209197
let found = root
210-
.descendants()
211-
.filter(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)))
212-
.next();
198+
.descendants().find(|n| matches!(n.data.borrow().value, NodeValue::FrontMatter(..)));
213199

214200
assert!(found.is_some(), "front matter expected");
215201
}

0 commit comments

Comments
 (0)