Skip to content

Commit 87c8b26

Browse files
authored
Update README.md
1 parent 00b139d commit 87c8b26

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

docs/README.md

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,35 @@ Hello, World!
4646

4747
The output of Cargo will be hidden unless compilation fails.
4848

49-
`rust-script` will also look for embedded dependency and manifest information in the script. For example, all of the following are equivalent:
50-
51-
- `now.crs` (code block manifest with UNIX hashbang and `.crs` extension):
52-
53-
```rust
54-
#!/usr/bin/env rust-script
55-
//! This is a regular crate doc comment, but it also contains a partial
56-
//! Cargo manifest. Note the use of a *fenced* code block, and the
57-
//! `cargo` "language".
58-
//!
59-
//! ```cargo
60-
//! [dependencies]
61-
//! time = "0.1.25"
62-
//! ```
63-
fn main() {
64-
println!("{}", time::now().rfc822z());
65-
}
66-
```
67-
68-
- `now.rs` (dependency-only, short-hand manifest):
69-
70-
```rust
71-
// cargo-deps: time="0.1.25"
72-
// You can also leave off the version number, in which case, it's assumed
73-
// to be "*". Also, the `cargo-deps` comment *must* be a single-line
74-
// comment, and it *must* be the first thing in the file, after the
75-
// hashbang.
76-
// Multiple dependencies should be separated by commas:
77-
// cargo-deps: time="0.1.25", libc="0.2.5"
78-
fn main() {
79-
println!("{}", time::now().rfc822z());
80-
}
81-
```
49+
`rust-script` will also look for embedded dependency and manifest information in the script using one of two syntaxes as shown by the below two equivalent `now.rs` variants:
50+
51+
```rust
52+
#!/usr/bin/env rust-script
53+
//! This is a regular crate doc comment, but it also contains a partial
54+
//! Cargo manifest. Note the use of a *fenced* code block, and the
55+
//! `cargo` "language".
56+
//!
57+
//! ```cargo
58+
//! [dependencies]
59+
//! time = "0.1.25"
60+
//! ```
61+
fn main() {
62+
println!("{}", time::now().rfc822z());
63+
}
64+
```
65+
66+
```rust
67+
// cargo-deps: time="0.1.25"
68+
// You can also leave off the version number, in which case, it's assumed
69+
// to be "*". Also, the `cargo-deps` comment *must* be a single-line
70+
// comment, and it *must* be the first thing in the file, after the
71+
// hashbang.
72+
// Multiple dependencies should be separated by commas:
73+
// cargo-deps: time="0.1.25", libc="0.2.5"
74+
fn main() {
75+
println!("{}", time::now().rfc822z());
76+
}
77+
```
8278

8379
On running either of these, `rust-script` will generate a Cargo package, build it, and run the result. The output may look something like:
8480

0 commit comments

Comments
 (0)