This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{cell::RefCell, marker::PhantomData, mem, rc::Rc}; | |
use thiserror::Error; | |
#[derive(Debug, Copy, Clone, Eq, PartialEq, Error)] | |
pub enum AccessError { | |
#[error("frozen value accessed outside of enclosing scope")] | |
Expired, | |
#[error("already borrowed incompatibly")] | |
BadBorrow, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
use failure::{Error, Fail}; | |
/// Wraps an `Error` in a type that displays the full cause chain of that error and all available | |
/// backtraces. | |
pub struct DisplayErrorCauses(pub Error); | |
/// Wraps any `Fail` type in a type that displays its full cause chain and all available backtraces. | |
pub struct DisplayFailureCauses<F: Fail>(pub F); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{iter, slice, vec}; | |
use std::iter::FromIterator; | |
/// A unique identifier with an associated usize index. Indexes are valued proportional to the | |
/// number of indexes allocated, are reused after being freed, and do not grow without bound. When | |
/// an index is re-used, an associated "generation" is incremented, so that within the life of a | |
/// single allocator, no two GenerationalIndex values will ever be equal. Since the indexes do not | |
/// grow without bound, GenerationalIndex values are particularly suited to being stored by their | |
/// index in extremely fast contiguous arrays. | |
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::path::PathBuf; | |
use std::collections::{BTreeMap, HashMap, HashSet}; | |
use std::thread; | |
use std::os::raw::c_void; | |
use std::rc::Rc; | |
use std::cell::{Cell, RefCell}; | |
use std::i16; | |
use std::time::Instant; | |
use failure::{err_msg, Error}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hook(args) | |
print("greetings from lua") | |
for _, v in pairs(args) do | |
print(v) | |
end | |
return 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rlua; | |
use std::env; | |
use std::fs::File; | |
use std::io::Read; | |
use rlua::prelude::*; | |
fn main() { | |
let mut args = env::args(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::result::Result; | |
use std::thread::{spawn, JoinHandle}; | |
use std::sync::{Arc, Mutex}; | |
use std::sync::mpsc::{sync_channel, channel, SyncSender, Receiver, TryRecvError, RecvTimeoutError}; | |
use std::boxed::FnBox; | |
use std::time::Duration; | |
/// Holds a piece of data in a particular thread and produces promises that are executed on that | |
/// thread only. Useful for paralellization or concurrency with types that do not implement Send. | |
pub struct ThreadWorker<T> { |