pub struct Optional[T] {
mut:
	value T
	some  bool
}

pub struct Foo {
	foo int
}

pub fn (f Foo) new_some[T](value T) Optional[T] {
	return Optional{
		value: value
		some: true
	}
}

pub fn (f Foo) some[T](opt Optional[T]) bool {
	return opt.some
}

pub fn (f Foo) get[T](opt Optional[T]) T {
	return opt.value
}

pub fn (f Foo) set[T](mut opt Optional[T], value T) {
	opt.value = value
	opt.some = true
}

fn main() {
	foo := Foo{}
	mut o := foo.new_some[int](23)
	println(foo.some[int](o))
	assert foo.some[int](o) == true
	foo.set[int](mut o, 42)
	println(foo.get[int](o))
	assert foo.get[int](o) == 42
}
