Skip to content

Instantly share code, notes, and snippets.

#![feature(unsize)]
use std::iter::Iterator;
use std::marker::Unsize;
use std::fmt::{self, Debug, Display};
trait Heterogeneous<I: ?Sized> {
fn next(self: Box<Self>) -> Option<(Box<I>, Box<Heterogeneous<I>>)>;
fn count(&self) -> usize;
@zakarumych
zakarumych / type_match.cpp
Last active August 29, 2015 14:15
switch by argument type / inspired by Rust match
#include <boost/variant.hpp>
#include "type_match.h"
int main(int argc, char** argv) {
boost::variant<int, const char*> x(42);
x.apply_visitor(match(
[](const char* value) {
printf("%s\n", value); // won't be called cause x is int
},
[](int value) {