Skip to content

Instantly share code, notes, and snippets.

@porglezomp
Last active March 3, 2022 09:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porglezomp/68f4d9e7be29b758284a7b897269c718 to your computer and use it in GitHub Desktop.
Save porglezomp/68f4d9e7be29b758284a7b897269c718 to your computer and use it in GitHub Desktop.
Creating a Rust hello world in 0x a presses.

This is a Rust "Hello World" program in 0x A presses.

$ vim hello.rs
$ rustc --test hello.rs
$ ./hello --quiet
Hello, World!

If you don't know, [the A Button Challenge] is a Mario 64 speedrun category in which runners attempt to use the A button (the jump button!) as few times as possible. Make sure you watch the classic Watch for Rolling Rocks - 0.5x A Presses video linked above in order to understand.

This project is TJ "Henry" Yoshi approved:

Nice - TJ "Henry" Yoshi (@tj99er) https://twitter.com/tj99er/status/1185701669696204800

use std::io::Write;
#[test]
fn hello() {
// Ensure we don't need to use the compiler option to
// show the test output, which uses the forbidden letter.
let mut out = std::fs::File::open("/dev/stdout").expect("stdout");
// Overwrite the undesired output to hide it.
write!(out, "\x1b[2\x41
\x1b[1\x41\r").expect("reset");
// Lets print! We need to use expect since the other
// one uses the letter which is not permitted.
writeln!(out, "Hello, World!").expect("write");
// Exit not so the test runner doesn't print more output.
std::process::exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment