#![deny(missing_docs)]
#![feature(unsafe_destructor)]
#![feature(macro_rules)]
pub use current::Current;
use std::cell::RefCell;
mod current;
impl<F: 'static, T: Modifier<F>> Modifier<Current<F>> for T {
#[inline(always)]
fn modify(self, obj: &mut Current<F>) {
self.modify((*obj).deref_mut());
}
}
impl<T: Get<U>, U> Get<U> for Current<T> {
#[inline(always)]
fn get(&self) -> U {
(*self).deref().get()
}
}
impl<'a, T: Get<U>, U> Get<U> for &'a RefCell<T> {
#[inline(always)]
fn get(&self) -> U {
self.borrow().deref().get()
}
}
impl<'a, F, T: Modifier<F>> Modifier<&'a RefCell<F>> for T {
#[inline(always)]
fn modify(self, obj: &mut &'a RefCell<F>) {
self.modify(obj.borrow_mut().deref_mut())
}
}
pub trait Modifier<F> {
fn modify(self, &mut F);
}
pub trait Set<M> {
fn set(mut self, modifier: M) -> Self;
fn set_mut(&mut self, modifier: M) -> &mut Self;
}
impl<T, U: Modifier<T>> Set<U> for T {
#[inline(always)]
fn set(mut self, modifier: U) -> T {
modifier.modify(&mut self);
self
}
#[inline(always)]
fn set_mut(&mut self, modifier: U) -> &mut T {
modifier.modify(self);
self
}
}
pub trait Get<T> {
fn get(&self) -> T;
}