No more glob imports in the register_tile! macro

This commit is contained in:
Brooks J Rady 2021-01-11 16:05:55 +00:00
parent 4592f12349
commit 1275a9e73a
2 changed files with 4 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mosaic-tile" name = "mosaic-tile"
version = "0.3.0" version = "0.3.1"
authors = ["Brooks J Rady <b.j.rady@gmail.com>"] authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
edition = "2018" edition = "2018"
description = "A small client-side library for writing mosaic plugins (tiles)" description = "A small client-side library for writing mosaic plugins (tiles)"

View File

@ -12,11 +12,8 @@ pub trait MosaicTile {
#[macro_export] #[macro_export]
macro_rules! register_tile { macro_rules! register_tile {
($t:ty) => { ($t:ty) => {
use mosaic_tile::*;
use std::cell::RefCell;
thread_local! { thread_local! {
static STATE: RefCell<$t> = RefCell::new(Default::default()); static STATE: std::cell::RefCell<$t> = std::cell::RefCell::new(Default::default());
} }
fn main() { fn main() {
@ -35,14 +32,14 @@ macro_rules! register_tile {
#[no_mangle] #[no_mangle]
pub fn handle_key() { pub fn handle_key() {
STATE.with(|state| { STATE.with(|state| {
state.borrow_mut().handle_key(get_key()); state.borrow_mut().handle_key($crate::get_key());
}); });
} }
#[no_mangle] #[no_mangle]
pub fn handle_global_key() { pub fn handle_global_key() {
STATE.with(|state| { STATE.with(|state| {
state.borrow_mut().handle_global_key(get_key()); state.borrow_mut().handle_global_key($crate::get_key());
}); });
} }
}; };