Ok so the list is linear sure, but how can the compiler statically verify that the list will be empty when the program terminates?
The emptying could be in a completely different function, called under some arbitrarily complex condition.
The emptying could be in a completely different function, called under some arbitrarily complex condition.
1. drop_into(list, func): It consumes the list, calling the given `func` for each element.
2. expect_empty(list): Consumes the list, panicking if the list isn't empty.
fn expect_empty(list) {
drop_into(list, () => panic());
}
(pardon my made up syntax)If you want to discourage runtime checks, you could even make the programmer do the above themselves since it's a one-liner anyway.