Skip to content

Commit 64a8033

Browse files
authored
Update README.md
1 parent 705db7b commit 64a8033

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ The latest stable version of Rust (1.47) is required.
3636
The primary use for `rust-script` is for running Rust source files as scripts. For example:
3737

3838
```sh
39-
$ echo 'fn main() { println!("Hello, World!"); }' > hello.rs
39+
$ echo 'println!("Hello, World!");' > hello.rs
4040
$ rust-script hello.rs
4141
Hello, World!
4242
$ rust-script hello # you can leave off the file extension
4343
Hello, World!
4444
```
4545

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.
4747

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:
4951

5052
```rust
5153
#!/usr/bin/env rust-script
@@ -75,15 +77,13 @@ fn main() {
7577
}
7678
```
7779

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:
7981

8082
```sh
8183
$ rust-script now
8284
Wed, 28 Oct 2020 00:38:45 +0100
8385
```
8486

85-
Subsequent runs will be a lot faster as `rust-script` reuses already built executables.
86-
8787
Useful command-line arguments:
8888

8989
- `--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
194194
195195
Please report all issues on [the GitHub issue tracker](https://github.com/fornwall/rust-script/issues).
196196
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

Comments
 (0)