Skip to main content

if_postgres

Macro if_postgres 

Source
macro_rules! if_postgres {
    ($($item:tt)*) => { ... };
}
Expand description

Expand the tokens where ingraph was built with PostgreSQL, and to nothing where it was not.

The gate a declaration’s emitted PostgreSQL impls ride, spent by hand. A per-backend half the derive cannot write — a composite comparison, a conversion only the declaring crate knows — is written beside the emission and rides the same gate, because a #[cfg] written where that half lives asks a different question: see the crate note’s four gates.

The tokens are slurped rather than parsed, so they may name types this build does not have.

§Examples

// `comparison::sql::postgres` is a module `ingraph` has only where PostgreSQL is compiled in,
// and a shut gate discards these tokens before anything in them has to resolve — so this is one
// compilation in every build, carrying no `#[cfg]` of its own.
ingraph::if_postgres! {
  use ingraph::comparison::sql::postgres::ScalarComparison;

  let column = ScalarComparison::<i64>::new();
  assert!(column.is_empty());
}