Last active
May 14, 2025 13:49
-
-
Save badboy/222302b6b40ba6afc412 to your computer and use it in GitHub Desktop.
Poor dev's Rust Compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
println!("Hello World!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requires `jq`, because I am lazy | |
# jq: https://stedolan.github.io/jq/ | |
[ $# -ne 1 ] && echo "Usage: $(basename $0) file.rs" && exit | |
echo "{\"channel\":\"stable\",\"crateType\":\"bin\",\"mode\":\"debug\",\"tests\":false,\"code\":\"$(sed -e 's/"/\\"/g' -e 's/$/\\n/g' $1|tr -d '\n')\"}" \ | |
| curl -skH"Content-Type:application/json" https://play.rust-lang.org/execute -d@- \ | |
| jq .stdout \ | |
| sed -e 's/^"//' -e 's/"$//' -e 's/\\n/\n/g' | sed '/^$/d' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[ $# -ne 1 ] && echo "Usage: $(basename $0) file.rs" && exit | |
echo "{\"channel\":\"stable\",\"crateType\":\"bin\",\"mode\":\"debug\",\"tests\":false,\"code\":\"$(sed -e 's/"/\\"/g' -e 's/$/\\n/g' $1|tr -d '\n')\"}" | curl -skH"Content-Type:application/json" https://play.rust-lang.org/execute -d@- | jq .stdout | sed -e 's/^"//' -e 's/"$//' -e 's/\\n/\n/g' | sed '/^$/d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also compress line
2
like this: