SHARE
TWEET

Untitled

a guest Apr 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// Taken from "Programming Rust" by Jim Blandy and Jason Orendorff
  2.  
  3. // Expressions that don’t finish normally are assigned the special type ! ,
  4. // and they’re exempt from the rules about types having to match.
  5. // You can see ! in the function signature of `std::process::exit()`:
  6. fn exit(code: i32) -> !
  7.  
  8. // The ! means that exit() never returns. It’s a divergent function.
  9. // You can write divergent functions of your own using the same syntax,
  10. // and this is perfectly natural in some cases:
  11. fn serve_forever(socket: ServerSocket, handler: ServerHandler) -> ! {
  12.   socket.listen();
  13.   loop {
  14.     let s = socket.accept();
  15.     handler.handle(s);
  16.   }
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top