Skip to content

Instantly share code, notes, and snippets.

Created September 27, 2015 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5046901cdbccf409e9ff to your computer and use it in GitHub Desktop.
Save anonymous/5046901cdbccf409e9ff to your computer and use it in GitHub Desktop.
Shared via Rust Playground
fn main() {
swizzle_gen();
}
fn swizzle_gen() {
swizzle_gen0("x");
swizzle_gen0("y");
swizzle_gen0("z");
swizzle_gen0("w");
}
fn swizzle_gen0(c0: &str) {
println!("{}", c0);
swizzle_gen1(c0, "x");
swizzle_gen1(c0, "y");
swizzle_gen1(c0, "z");
swizzle_gen1(c0, "w");
}
fn swizzle_gen1(c0: &str, c1: &str) {
println!("{}{}", c0, c1);
swizzle_gen2(c0, c1, "x");
swizzle_gen2(c0, c1, "y");
swizzle_gen2(c0, c1, "z");
swizzle_gen2(c0, c1, "w");
}
fn swizzle_gen2(c0: &str, c1: &str, c2: &str) {
println!("{}{}{}", c0, c1, c2);
swizzle_gen3(c0, c1, c2, "x");
swizzle_gen3(c0, c1, c2, "y");
swizzle_gen3(c0, c1, c2, "z");
swizzle_gen3(c0, c1, c2, "w");
}
fn swizzle_gen3(c0: &str, c1: &str, c2: &str, c3: &str) {
println!("{}{}{}{}", c0, c1, c2, c3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment