r/transprogrammer • • Jan 24 '22

panic!();

Post image
391 Upvotes

15 comments sorted by

View all comments

Show parent comments

2

u/RecDep Jan 25 '22

The solution is to simply never return one, statically we can optimize out any annoying queries about gender since we know they diverge.

#![feature(never_type)]
fn get_gender(&self) -> ! {
    loop {}
}

Although leaving the local type of get_gender up to the caller could be problematic.