<_>::v::<_>

A fun little piece of Rust artwork.

Following on from someone’s discovery that <_>::method() is valid, I got thinking about the left‐swimming and right‐swimming turbofishes, and decided that making an owl’s face out of it, <_>::v::<_>, should be possible. Here’s what I came up with:

<_>::v::<_>, the owl is sleeping soundly. Playground link

type O = u8;

trait V {
	fn v<T: Default>() -> (T, Self);
}

impl V for O {
	fn v<T: Default>() -> (T, Self) {
		(T::default(), 0)
	}
}

fn main() {
	let owl = <_>::v::<_>;

	println!("{:?}", owl() as (O, O));
}

When you call the owl, it wakes up.

(0, 0)

(Fun fact: the artwork of the awakened owl happened by accident. For inference to work, I needed both the Self type and one generic type to be in the return type, so (Self, T) was the obvious type to use. Then, integers seemed the natural types to implement things on, and zero is the easiest number to use. And so I ended up with (0, 0), which I then realised was a picture in itself! The O type alias is then just to mix things up a bit. Empty tuples would work as well, yielding ((), ()), but that didn’t feel quite as nice.)

Changelog