Function antithesis_sdk::antithesis_init

source ·
pub fn antithesis_init()
Expand description

Global initialization logic. Performs registration of the Antithesis assertion catalog. This should be invoked as early as possible during program execution. It is recommended to call it immediately in main.

If called more than once, only the first call will result in the assertion catalog being registered. If never called, the assertion catalog will be registered when it encounters the first assertion at runtime.

Example:

use std::env;
use serde_json::{json};
use antithesis_sdk::{antithesis_init, assert_unreachable};

fn main() {
    if (env::args_os().len() == 1888999778899) {
        assert_unreachable!("Unable to provide trillions of arguments", &json!({}));
    }
     
    // if antithesis_init() is omitted, the above unreachable will
    // not be reported
    antithesis_init();
}