Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement