For example, let's say there's an HTTP server handler that must send each header line first, and finally send a body. So you should:
conn.send_header("HTTP/1.1 200 OK");
conn.send_header("Connection: Close");
conn.send_header("Content-type: text/html");
conn.send_body("Hello, world!");
In Rust, you can construct the API so that you cannot call `send_body` before any occurrences of `send_header`. So if you do: conn.send_body("I'm sent first!");
conn.send_header("Content-type: text/html");
you will get a compile error. This greatly reduces the risk of having incorrect logic in your program. In this case Rust helps ensuring our intention: `send_body` can only be the last call of the request handler. I consider this a good example of expressiveness of Rust (and affine types).