Skip to content

Commit 7b66941

Browse files
committed
Fix clippy warning
1 parent 5204933 commit 7b66941

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/manifest.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ pub fn split_input(
4444
prelude_items: &[String],
4545
input_id: &OsString,
4646
) -> MainResult<(String, String)> {
47+
fn contains_main_method(line: &str) -> bool {
48+
line.starts_with("fn main()")
49+
|| line.starts_with("pub fn main()")
50+
|| line.starts_with("async fn main()")
51+
|| line.starts_with("pub async fn main()")
52+
}
53+
4754
let template_buf;
4855
let (part_mani, source, template, sub_prelude) = match *input {
4956
Input::File(_, _, content, _) => {
@@ -52,12 +59,7 @@ pub fn split_input(
5259
let (manifest, source) =
5360
find_embedded_manifest(content).unwrap_or((Manifest::Toml(""), content));
5461

55-
let source = if source.lines().any(|line| {
56-
line.starts_with("fn main()")
57-
|| line.starts_with("pub fn main()")
58-
|| line.starts_with("async fn main()")
59-
|| line.starts_with("pub async fn main()")
60-
}) {
62+
let source = if source.lines().any(contains_main_method) {
6163
source.to_string()
6264
} else {
6365
format!("fn main() -> Result<(), Box<dyn std::error::Error+Sync+Send>> {{\n {{\n {} }}\n Ok(())\n}}", source)

0 commit comments

Comments
 (0)