Skip to content

Instantly share code, notes, and snippets.

@larsbergstrom
Created April 26, 2014 15:12
Show Gist options
  • Select an option

  • Save larsbergstrom/11322558 to your computer and use it in GitHub Desktop.

Select an option

Save larsbergstrom/11322558 to your computer and use it in GitHub Desktop.
pub extern "C" fn display_callback() {
local_data::get(display_tls_key, |callback| {
callback.as_ref().map(|&ref cb| {
cb.call();
});
});
}
pub fn display_func(callback: ~DisplayCallback) {
local_data::set(display_tls_key, callback);
unsafe {
glutDisplayFunc(display_callback);
}
}
@larsbergstrom
Copy link
Author

/Users/larsberg/servo/src/support/glut/rust-glut/glut.rs:145:5: 145:20 error: instantiating a type parameter with an incompatible type `~glut::DisplayCallback<no-bounds>`, which does not fulfill `'static`
/Users/larsberg/servo/src/support/glut/rust-glut/glut.rs:145     local_data::get(display_tls_key, |callback| {
                                                                 ^~~~~~~~~~~~~~~
/Users/larsberg/servo/src/support/glut/rust-glut/glut.rs:153:5: 153:20 error: instantiating a type parameter with an incompatible type `~glut::DisplayCallback<no-bounds>`, which does not fulfill `'static`
/Users/larsberg/servo/src/support/glut/rust-glut/glut.rs:153     local_data::set(display_tls_key, callback);
                                                                 ^~~~~~~~~~~~~~~

@larsbergstrom
Copy link
Author

pub trait DisplayCallback { fn call(&self); }
local_data_key!(display_tls_key: ~DisplayCallback)

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