Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwpl/75ed3361f7e1173e0763989ab36df641 to your computer and use it in GitHub Desktop.
Save gwpl/75ed3361f7e1173e0763989ab36df641 to your computer and use it in GitHub Desktop.
Rust session Illustrate Value change in vector
#If you run in terminal multiplexxer...
# (or code editor and terminal to see complile+run output)
# like screen or tmux,
# you may want in one to have
$ $EDITOR l1.rs
# and in another:
echo l1.rs | entr -cs 'rustc l1.rs && ./l1'
# this will automatically, every time you save file: clear terminal, compile and run
$ echo $PS1mini
\[\033[01;37m\]$\[\]
$ PS1=$PS1mini # let's make prompt minimal to copy and paste
$ cat > l1.rs <<ENDL
> fn main() {
> let mut v = vec![0, 1, 2, 3];
> v[1] = 11;
> println!("v={:?}", v);
> }
> ENDL
$ rustc l1.rs && ./l1
v=[0, 11, 2, 3]
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment