Generate an unused enum variant to fix a compiler error

Previously if you made a service with a single rpc it would generate an error
because of a redundant match statement.
This commit is contained in:
Adam Wright
2016-01-09 14:12:37 -08:00
parent 3bf2d1f16d
commit 5e34e32094

View File

@@ -40,6 +40,7 @@ extern crate log;
#[macro_export]
macro_rules! rpc_service { ($server:ident:
$( $fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty;)*) => {
#[allow(dead_code)]
mod $server {
use std::net::{
TcpStream,
@@ -102,6 +103,7 @@ macro_rules! rpc_service { ($server:ident:
$(
$fn_name($out),
)*
Impossible,
}
#[doc="The client stub that makes RPC calls to the server."]
@@ -120,9 +122,10 @@ macro_rules! rpc_service { ($server:ident:
$(
pub fn $fn_name(&self, $($arg: $in_),*) -> Result<$out> {
let reply = try!((self.0).rpc(&Request::$fn_name($($arg),*)));
match reply {
Reply::$fn_name(reply) => Ok(reply),
_ => Err(Error::InternalError),
if let Reply::$fn_name(reply) = reply {
Ok(reply)
} else {
Err(Error::InternalError)
}
}
)*