0

I've been experimenting with the Tokio libraries for playing with TCP servers and clients. A server is almost always constructed like so:

TcpServer::new(Http, addr)
    .serve(|| Ok(HelloWorld));

I'm curious to know what the || operator does and how it's used in this expression?

Here are some complete server examples based on Tokio MiniHTTP.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
nmurthy
  • 1,337
  • 1
  • 12
  • 24
  • It is a closure function. Is the confusion just that it's not obvious it is a function with no arguments, or are you unfamiliar with those? – loganfsmyth Jul 06 '17 at 22:32
  • That is actually a closure statement with an empty parameter list. – E_net4 Jul 06 '17 at 22:32

0 Answers0