# Rust Scripting

**URL:** <https://internals.rust-lang.org/t/rust-scripting/12400>\
**Category:** language design\
**Created:** [May 21, 2020, 7:55pm UTC](https://internals.rust-lang.org/t/rust-scripting/12400 "2020-05-21T19:55:40Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mbrubeck](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mbrubeck/32/174_2.png) [@mbrubeck](https://internals.rust-lang.org/u/mbrubeck)\
**Post date:** [May 21, 2020, 10:19pm UTC](https://internals.rust-lang.org/t/rust-scripting/12400/6 "2020-05-21T22:19:07Z")

</div>

`cargo-script` or a similar tool could be extended to auto-generate a `main` wrapper if the script does not already contain a `main` function. This is what `rustdoc` already does for running code found in doc comments.

> <https://github.com/DanielKeep/cargo-script/issues/65>
>
> It would be nice to be able to write a script like:
> \#!/usr/bin/env run-cargo-script
> println!("1 + 1 = {}", 1 + 1);
> Rust's doctests...

On a separate note, with my moderator’s hat on: @redradist, please note that the bar for changes to the Rust is very high. Before posting proposals, please consider looking more closely at alternatives and prior work, including ways of solving the problem outside of the core language. Thanks!

---

_[View the full topic](https://internals.rust-lang.org/t/rust-scripting/12400)._
