Skip to main content

assert_api_compatible

Macro assert_api_compatible 

Source
macro_rules! assert_api_compatible {
    (($($old_ep:ty),+ $(,)?), $new_api:ty) => { ... };
    (@expand $counter:expr; $new_api:ty; $head:ty $(, $rest:ty)*) => { ... };
}
Expand description

Verify at compile time that every endpoint in the old API exists in the new API (type equality on the full endpoint type).

This macro generates a const block with trait bounds that fail to compile if any endpoint from the first argument is missing in the second.

§Usage

// List the endpoints that must be preserved, and the new API tuple.
assert_api_compatible!(
    (EndpointA, EndpointB),
    (EndpointA, EndpointB, EndpointC)
);
// Compile error if NewApi is missing EndpointA or EndpointB.

If an endpoint was intentionally removed or replaced, omit it from the first argument — list only the endpoints that must be preserved.