[][src]Function sentry_core::with_integration

pub fn with_integration<I, F, R>(f: F) -> R where
    I: Integration,
    F: FnOnce(&I, &Hub) -> R,
    R: Default

Looks up an integration on the current Hub.

Calls the given function with the requested integration instance when it is active on the currently active client. When multiple instances of the same integration are added, the function will be called with the first one.


use sentry::{ClientOptions, Integration};

struct MyIntegration(usize);
impl Integration for MyIntegration {}

let options = ClientOptions::default()

let _sentry = sentry::init(options);

let value = sentry::with_integration(|integration: &MyIntegration, _| integration.0);
assert_eq!(value, 10);