Below is my understanding of affine types and how they help us in Rust (unsure if I got this right - please correct if I am talking nonsense).
The issue is... How can we use the power of a type system so a compiler will block us from doing this wrong sequence of calls?
FILE *fp = NULL;
fclose(fp);
fp = fopen("...");
An idea is to "mirror" the states that the file variable goes through (unused/closed, opened) in the type system: