Skip to content

Instantly share code, notes, and snippets.

@LinuxIsCool
Created November 15, 2024 18:53
Show Gist options
  • Save LinuxIsCool/da3b185c0672111e366e758fcb198316 to your computer and use it in GitHub Desktop.
Save LinuxIsCool/da3b185c0672111e366e758fcb198316 to your computer and use it in GitHub Desktop.
Function for building and running a rust script using local build directory
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