Skip to content

Instantly share code, notes, and snippets.

View pythonesque's full-sized avatar

Joshua Yanovski pythonesque

  • Lanetix
  • San Francisco, CA
View GitHub Profile
@pythonesque
pythonesque / main.rs
Created November 25, 2014 07:41 — forked from TheNeikos/main.rs
#![feature(if_let)]
extern crate arena;
use arena::TypedArena;
use std::cell::Cell;
use std::fmt;
type NodeRef<'a, T> = Cell<Option<&'a Node<'a, T>>>;
#![feature(rustc_private,std_misc)]
extern crate arena;
use arena::TypedArena;
use std::cell::Cell;
use std::collections::hash_map::Entry as h;
use std::collections::HashMap;
use std::default::Default;
use std::fmt;
#![feature(unsafe_destructor)]
use rooted::{RcSend, Root};
use std::fmt;
use std::rc::Rc;
mod rooted {
use std::collections::trie_map::{mod, TrieMap};
use std::fmt;
use std::kinds::marker;
#![feature(if_let)]
use nomove::{freeze, freeze_box, FreezeSlice, NoMoveGuard};
use std::cell::Cell;
mod nomove {
pub struct NoMoveGuard<T> {
pub data: T,
no_copy: ::std::kinds::marker::NoCopy,
}
use std::collections::{dlist, DList, HashSet, Deque};
use std::hash::Hash;
use std::iter;
use std::default::Default;
pub struct LinkedHashSet<'a, T: 'a> where T: Hash + Eq {
// Important: HashSet must come after DList, since destructors run in
// reverse order. Otherwise we'd have use after free (potentially).
element_list: DList<T>,
element_set: HashSet<&'a T>,
@pythonesque
pythonesque / syncsend.markdown
Last active August 29, 2015 14:08
Improve the Send trait.
  • Start Date: 2014-11-10
  • RFC PR: (leave this empty)
  • Rust Issue: (leave this empty)

Summary

I propose altering the Send trait as proposed by RFC #17 as follows:

  • Remove the implicit 'static bound from Send.
#![feature(macro_rules)]
extern crate collections;
extern crate sync;
use std::sync::{Arc, Mutex, RWLock, RWLockReadGuard};
use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicUint, Ordering, Relaxed, SeqCst};
use std::ptr;
use std::ptr::{RawMutPtr};
use std::slice::Items;
#![feature(unsafe_destructor)]
/*
For safety, here are some guarantees we need fulfilled for allocated types for
an allocator of size class <M, N, O>.
* <T>::Size < M
e.g. consider 1-sized struct aligned at 4096.
#![feature(if_let)]
extern crate arena;
extern crate rustc;
use arena::Arena;
use rustc::util::nodemap::FnvHashMap;
use std::any::{Any, AnyRefExt};
use std::cell::RefCell;
use std::collections::hashmap;
pub mod bitmap {
pub type ColorComponent = u8;
#[deriving(Clone, Default, Eq, PartialEq)]
pub struct Pixel {
pub r: ColorComponent,
pub g: ColorComponent,
pub b: ColorComponent,
}