1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-03 04:34:21 -05:00

Replace need for drop_types_in_const with lazy_static

This commit is contained in:
Manish Goregaokar 2017-01-06 15:31:12 -08:00
parent 800b65622c
commit ee5a9f1338
4 changed files with 13 additions and 10 deletions

1
Cargo.lock generated
View file

@ -10,6 +10,7 @@ dependencies = [
"font 0.1.0",
"gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.6.1 (git+https://github.com/jwilm/glutin?rev=af7fe340bd4a2af53ea521defcb4f377cdc588cf)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"notify 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -17,6 +17,7 @@ notify = "2.6"
bitflags = "*"
font = { path = "./font" }
errno = "0.1.6"
lazy_static = "0.2.2"
parking_lot = { version = "0.3.1", features = ["nightly"] }
serde = "0.8"
serde_yaml = "0.5"

View file

@ -16,7 +16,6 @@
#![feature(range_contains)]
#![feature(inclusive_range_syntax)]
#![feature(inclusive_range)]
#![feature(drop_types_in_const)]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", deny(clippy))]
@ -36,6 +35,8 @@ extern crate copypasta;
extern crate errno;
extern crate font;
extern crate glutin;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate mio;
extern crate notify;

View file

@ -14,6 +14,7 @@
use std::convert::From;
use std::fmt::{self, Display};
use std::ops::Deref;
use std::sync::Mutex;
use gl;
use glutin;
@ -26,13 +27,13 @@ use glutin;
///
/// This will fail horribly if more than one window is created. Don't do that :)
fn window_resize_handler(width: u32, height: u32) {
unsafe {
RESIZE_CALLBACK.as_ref().map(|func| func(width, height));
}
RESIZE_CALLBACK.lock().unwrap().as_ref().map(|func| (*func)(width, height));
}
/// The resize callback invoked by `window_resize_handler`
static mut RESIZE_CALLBACK: Option<Box<Fn(u32, u32)>> = None;
lazy_static! {
/// The resize callback invoked by `window_resize_handler`
static ref RESIZE_CALLBACK: Mutex<Option<Box<Fn(u32, u32) + 'static + Send>>> = Mutex::new(None);
}
/// Window errors
#[derive(Debug)]
@ -238,10 +239,9 @@ impl Window {
///
/// This method takes self mutably to ensure there's no race condition
/// setting the callback.
pub fn set_resize_callback<F: Fn(u32, u32) + 'static>(&mut self, func: F) {
unsafe {
RESIZE_CALLBACK = Some(Box::new(func));
}
pub fn set_resize_callback<F: Fn(u32, u32) + 'static + Send>(&mut self, func: F) {
let mut guard = RESIZE_CALLBACK.lock().unwrap();
*guard = Some(Box::new(func));
}
pub fn inner_size_pixels(&self) -> Option<Size<Pixels<u32>>> {