Created
November 15, 2024 18:53
-
-
Save LinuxIsCool/da3b185c0672111e366e758fcb198316 to your computer and use it in GitHub Desktop.
Function for building and running a rust script using local build directory
This file contains 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
function rustr | |
if test (count $argv) -ne 1 | |
echo "Usage: rustr <filename>" | |
return 1 | |
end | |
set filename $argv[1] | |
set output_file (string replace -r '\.rs$' '' $filename) | |
# Create the build directory if it doesn't exist | |
mkdir -p ./build | |
# Compile the file | |
rustc $filename -o ./build/$output_file | |
and ./build/$output_file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment