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
+3-8Lines changed: 3 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -112,20 +112,15 @@ If you want to make a script usable across platforms, use *both* a hashbang line
112
112
113
113
## Expressions
114
114
115
-
`rust-script` can also run pieces of Rust code directly from the command line. This is done by providing the `-e`/`--eval` option; this causes `rust-script` to interpret the `<script>` argument as source code *instead* of as a file path.
116
-
117
-
The - `-d`/`--dep` option can be used to specify dependencies to add before evaluating the expression.
118
-
119
-
120
-
For example, code can be executed from the command line in a number of ways:
115
+
Using the `-e`/`--eval` option a Rust expression can be evaluated directly, with optionally dependencies added using the `-d`/`--dep` option:
121
116
122
117
```sh
123
118
$ rust-script -e '1+2'
124
119
3
125
120
$ rust-script --dep time --expr "time::OffsetDateTime::now_utc().format(time::Format::Rfc3339).to_string()"`
126
121
"2020-10-28T11:42:10+00:00"
127
-
$ # Use a specific version of the time crate instead of latest:
0 commit comments