File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ pub fn split_input(
44
44
prelude_items : & [ String ] ,
45
45
input_id : & OsString ,
46
46
) -> 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
+
47
54
let template_buf;
48
55
let ( part_mani, source, template, sub_prelude) = match * input {
49
56
Input :: File ( _, _, content, _) => {
@@ -52,12 +59,7 @@ pub fn split_input(
52
59
let ( manifest, source) =
53
60
find_embedded_manifest ( content) . unwrap_or ( ( Manifest :: Toml ( "" ) , content) ) ;
54
61
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) {
61
63
source. to_string ( )
62
64
} else {
63
65
format ! ( "fn main() -> Result<(), Box<dyn std::error::Error+Sync+Send>> {{\n {{\n {} }}\n Ok(())\n }}" , source)
You can’t perform that action at this time.
0 commit comments