macro_rules! repr_bound {
(
// e.g. `pub MyReprs<T: Foo + Bar> [ Spam<T>, Eggs ]`
$vis:vis $repr_traits:ident
$(<
$($gen:tt $(: $b:tt $(+ $bs:tt)* )? ),+
>)?
[
$($msg:ty),+
]
) => { ... };
}
Expand description
The repr_bound
macro creates a type alias that can be used as bound for the generic
wire type, instead of listing all messages used by the protocol.
§Example
#![feature(trait_alias)]
use async_session_types::*;
struct Foo(pub u8);
struct Bar(pub String);
repr_bound! { FooBarReprs [Foo, Bar] }
type Server = Recv<Foo, Send<Bar, Eps>>;
fn server<R: FooBarReprs>(c: Chan<Server, (), R>) -> SessionResult<()> {
unimplemented!()
}
Note that there’s no comma after the last item!
Requires #![feature(trait_alias)]
.