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
Copy file name to clipboardExpand all lines: docs/README.md
+29-33Lines changed: 29 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -46,39 +46,35 @@ Hello, World!
46
46
47
47
The output of Cargo will be hidden unless compilation fails.
48
48
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/envrust-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
-
fnmain() {
64
-
println!("{}", time::now().rfc822z());
65
-
}
66
-
```
67
-
68
-
- `now.rs` (dependency-only, short-handmanifest):
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
-
fnmain() {
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/envrust-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
+
fnmain() {
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
+
fnmain() {
75
+
println!("{}", time::now().rfc822z());
76
+
}
77
+
```
82
78
83
79
On running either of these, `rust-script` will generate a Cargo package, build it, and run the result. The output may look something like:
0 commit comments