diff options
author | Martin Ashby <martin@ashbysoft.com> | 2022-10-09 13:06:52 +0100 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2022-10-09 13:06:52 +0100 |
commit | 4374e88f587d6e7a0135011a8d7e2d904e9369df (patch) | |
tree | cf3633d5fcb35f39a481570ced4da95d771b6e6d | |
download | rust-quine-main.tar.gz rust-quine-main.tar.bz2 rust-quine-main.tar.xz rust-quine-main.zip |
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | main.rs | 1 | ||||
-rwxr-xr-x | run.sh | 8 |
4 files changed, 20 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..23b9f74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +quine +main2.rs +quine2 +main3.rs diff --git a/README.md b/README.md new file mode 100644 index 0000000..16577ea --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# quine + +A simple [quine](https://en.wikipedia.org/wiki/Quine_%28computing%29) in rust. + +## usage + +Rust compiler must be installed. md5sum program also required for run script to check the generated sources are the same
\ No newline at end of file @@ -0,0 +1 @@ +fn main() { const PGRM : &str = "fn main() { const PGRM : &str = \"%s\"; println!(\"{}\", PGRM.replacen(\"%s\", &PGRM.escape_default().to_string(), 1)); }"; println!("{}", PGRM.replacen("%s", &PGRM.escape_default().to_string(), 1)); } @@ -0,0 +1,8 @@ +# Run it once, +rustc -o quine main.rs +./quine > main2.rs +# Run it from the generated sources +rustc -o quine2 main2.rs +./quine2 > main3.rs +# Check it's the same every time +md5sum main.rs main2.rs main3.rs
\ No newline at end of file |