Skip to main content

if_mongo

Macro if_mongo 

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

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

The gate a declaration’s emitted MongoDB 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::mongo` is a module `ingraph` has only where MongoDB 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_mongo! {
  use ingraph::comparison::mongo::MongoScalarComparison;

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