Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Taken from "Programming Rust" by Jim Blandy and Jason Orendorff
- // Expressions that don’t finish normally are assigned the special type ! ,
- // and they’re exempt from the rules about types having to match.
- // You can see ! in the function signature of `std::process::exit()`:
- fn exit(code: i32) -> !
- // The ! means that exit() never returns. It’s a divergent function.
- // You can write divergent functions of your own using the same syntax,
- // and this is perfectly natural in some cases:
- fn serve_forever(socket: ServerSocket, handler: ServerHandler) -> ! {
- socket.listen();
- loop {
- let s = socket.accept();
- handler.handle(s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement