Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko
Created June 12, 2018 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitsuhiko/08420503db1b40aef2611ff447013b38 to your computer and use it in GitHub Desktop.
Save mitsuhiko/08420503db1b40aef2611ff447013b38 to your computer and use it in GitHub Desktop.
#[derive(Clone)]
pub struct Scope {
pub(crate) fingerprint: Option<Arc<Vec<Cow<'static, str>>>>,
pub(crate) transaction: Option<Arc<String>>,
pub(crate) breadcrumbs: im::Vector<Breadcrumb>,
pub(crate) user: Option<Arc<User>>,
pub(crate) extra: im::HashMap<String, Value>,
pub(crate) tags: im::HashMap<String, String>,
pub(crate) contexts: im::HashMap<String, Option<Context>>,
pub(crate) scope_processors: im::Vector<Box<FnMut(&mut Event) + Sync + Send>>,
}
/// Registers a processing function with the scope.
pub fn add_scope_processor<F: FnMut(&mut Event) + Sync + Send>(&mut self, f: F) {
self.scope_processors = self.scope_processors.push_back(Box::new(f));
}
error[E0277]: the trait bound `std::boxed::Box<F>: im::shared::Shared<std::boxed::Box<for<'r, 's> std::ops::FnMut(&'r mut sentry_types::protocol::v7::Event<'s>) + std::marker::Sync + std::marker::Send>>` is not satisfied
--> src/scope/real.rs:234:55
|
234 | self.scope_processors = self.scope_processors.push_back(Box::new(f));
| ^^^^^^^^^ the trait `im::shared::Shared<std::boxed::Box<for<'r, 's> std::ops::FnMut(&'r mut sentry_types::protocol::v7::Event<'s>) + std::marker::Sync + std::marker::Send>>` is not implemented for `std::boxed::Box<F>`
|
= help: consider adding a `where std::boxed::Box<F>: im::shared::Shared<std::boxed::Box<for<'r, 's> std::ops::FnMut(&'r mut sentry_types::protocol::v7::Event<'s>) + std::marker::Sync + std::marker::Send>>` bound
@JJJollyjim
Copy link

JJJollyjim commented Jun 12, 2018

I think it's

pub fn add_scope_processor<F: FnMut(&mut Event) + Sync + Send>(&mut self, f: F)
  where std::boxed::Box<F>: im::shared::Shared<std::boxed::Box<for<'r, 's> std::ops::FnMut(&'r mut sentry_types::protocol::v7::Event<'s>) + std::marker::Sync + std::marker::Send>>
{
    self.scope_processors = self.scope_processors.push_back(Box::new(f));
}

@JJJollyjim
Copy link

JJJollyjim commented Jun 12, 2018

you can probably remove some of the qualified trait/struct names there to make it less verbose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment