Reputation: 9206
This code compiles fine:
Some(match head.path {
"/" => Hello,
"/num" => GetNum,
p if p.starts_with('/') => HelloName(p[1..].to_string()),
_ => PageNotFound
}, RecvMode::Buffered(1024), scope.now() + Duration::new(10, 0))
If I change it to
Some(Hello, RecvMode::Buffered(1024),
scope.now() + Duration::new(10, 0))
I get
error: this function takes 1 parameter but 3 parameters were supplied [E0061]
Why? Does match construction same semantics as
x>0?A:B
?
Function return value is declared as
Option<(Self, RecvMode, Time).
I was asked to provide MCVE, but I am not ready for that, that's why I'll give a link to sample, which I'm trying to change. To build it, add following dependencies to cargo.ml:
rotor = "0.6.3" rotor-http = "0.7.0"
Upvotes: 0
Views: 323
Reputation: 1306
The code from your question does not compile. In your sample on GitHub though you have the correct tuple-constructing syntax.
So for both your first and second example in the question: add parentheses around the tuple values to construct it:
Some((Hello, RecvMode::Buffered(1024),
scope.now() + Duration::new(10, 0)))
You want to pass a tuple to an Option-Enum, you have to first construct the tuple.
Upvotes: 2