You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ rust-script hello # you can leave off the file extension
43
43
Hello, World!
44
44
```
45
45
46
-
The output of Cargo will be hidden unless compilation fails.
46
+
Under the hood, a Cargo project will be generated and built (with the Cargo output hidden unless compilation fails or the `-o`/`--cargo-output` option is used). The first invocation of the script will be slower as the script is compiled - subsequent invocations of unmodified scripts will be fast as the built executable is cached.
47
47
48
-
`rust-script` will also look for embedded dependency and manifest information in the script as shown by the below two equivalent `now.rs` variants:
48
+
As seen from the above example, using a `fn main() {}` function is not required. If not present, the script file will be wrapped in a `fn main() { ... }` block.
49
+
50
+
`rust-script` will look for embedded dependency and manifest information in the script as shown by the below two equivalent `now.rs` variants:
49
51
50
52
```rust
51
53
#!/usr/bin/envrust-script
@@ -75,15 +77,13 @@ fn main() {
75
77
}
76
78
```
77
79
78
-
On running either of these, `rust-script` will generate a Cargo package, build it, and run the result. The output may look something like:
80
+
The output from running one of the above scripts may look something like:
79
81
80
82
```sh
81
83
$ rust-script now
82
84
Wed, 28 Oct 2020 00:38:45 +0100
83
85
```
84
86
85
-
Subsequent runs will be a lot faster as `rust-script` reuses already built executables.
86
-
87
87
Useful command-line arguments:
88
88
89
89
-`--bench`: Compile and run benchmarks. Requires a nightly toolchain.
@@ -194,4 +194,4 @@ In addition, there are three built-in templates: `expr`, `loop`, and `loop-count
194
194
195
195
Please report all issues on [the GitHub issue tracker](https://github.com/fornwall/rust-script/issues).
196
196
197
-
Run with the `RUST_LOG=rust_script=trace` environment variable set to see verbose log output if necessary.
197
+
If relevant, run with the `RUST_LOG=rust_script=trace` environment variable set to see verbose log output and attach that output to an issue.
0 commit comments