I think there is no language level feature in Rust to prevent TTCTTOU. TTCTTOU can happen in both c++ and rust.
for example:
let f = File::open("username.txt");
/*what if the file is deleted here?*/
let mut f = match f {
Ok(file) => /*what if the file is deleted here?*/ file,
Err(e) => return Err(e),
};
/*what if the file is deleted here*/
I mean even if you write it like: let f = File::open("username.txt")?;it looks atomic, it is not.
the c++ example, on the other hand, can do a filtering too, using:
http://www.cplusplus.com/reference/fstream/ifstream/is_open/
I mean Rust forces you to do error handling, which is nice. But that's not enough for preventing TTCTTOU. I don't think the first example is a strong argument.