From c7f8c7e985173e504191b95286f53e0927db2d78 Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Wed, 9 Mar 2016 21:27:17 +0100 Subject: [ci skip] Remove accidentally commited scratch files --- src/lambda.rs | 18 --------------- src/lazy.rs | 74 ----------------------------------------------------------- warning.rs | 11 --------- 3 files changed, 103 deletions(-) delete mode 100644 src/lambda.rs delete mode 100644 src/lazy.rs delete mode 100644 warning.rs diff --git a/src/lambda.rs b/src/lambda.rs deleted file mode 100644 index cf7b1ec..0000000 --- a/src/lambda.rs +++ /dev/null @@ -1,18 +0,0 @@ -// I'm only a little sorry for this. - -// Inline definition of anonymous functions. Examples: -// l!(42;) -// l!(i32 := 42) -// l!(i: i32 := i + 42) -// l!(i: i32, j: i32 -> i32 := i + j) -#[macro_export] -macro_rules! l { - ($body: expr) => ({ fn f() { $body } f }); - ($res: ty := $body: expr) => ({ fn f() -> $res { $body } f }); - ($($n: ident: $t: ty),+ := $body: expr) => ({ - fn f($($n: $t),+) { $body } f - }); - ($($n: ident: $t: ty),+ -> $res: ty := $body: expr) => ({ - fn f($($n: $t),+) -> $res { $body } f - }) -} diff --git a/src/lazy.rs b/src/lazy.rs deleted file mode 100644 index b4f801b..0000000 --- a/src/lazy.rs +++ /dev/null @@ -1,74 +0,0 @@ -#![macro_escape] - -use std::ptr; -use std::cell::UnsafeCell; -use std::ops::Deref; -use std::boxed::FnBox; - -pub enum State { - Evaluated(V), - Evaluating, - Unevaluated(Box V>) -} - -pub struct Lazy { - state: UnsafeCell>, -} - -impl Lazy { - pub fn new(f: Box V>) -> Lazy { - Lazy { state: UnsafeCell::new(State::Unevaluated(f)) } - } - - pub fn ready(v: V) -> Lazy { - Lazy { state: UnsafeCell::new(State::Evaluated(v)) } - } - - pub fn force(&mut self) { - self.value(); - } - - pub fn unwrap(self) -> V { - unsafe { - match self.state.into_inner() { - State::Unevaluated(f) => f(), - State::Evaluating => panic!("Illegal state, can't call unwrap during evaluation"), - State::Evaluated(v) => v - } - } - } - - pub fn value(&self) -> &V { - unsafe { - let state = self.state.get(); - match *state { - State::Evaluated(ref v) => v, - State::Evaluating => panic!("Illegal state, can't call value during evaluation"), - State::Unevaluated(_) => { - if let State::Unevaluated(f) = ptr::replace(state, State::Evaluating) { - ptr::replace(state, State::Evaluated(f())); - } - if let State::Evaluated(ref v) = *state { return v } - unreachable!() - } - } - } - } -} - -impl Deref for Lazy { - type Target = V; - fn deref(&self) -> &V { self.value() } -} - -#[macro_export] -macro_rules! lazy { - (@as_expr $val: expr) => { $val }; - ($($val: tt)*) => { Lazy::new(Box::new(move || lazy![@as_expr { $($val)* }])) }; -} - -#[macro_export] -macro_rules! eager { - (@as_expr $val: expr) => { $val }; - ($($val: tt)*) => { Lazy::<_>::ready(eager![@as_expr { $($val)* }]) }; -} diff --git a/warning.rs b/warning.rs deleted file mode 100644 index a71bc3f..0000000 --- a/warning.rs +++ /dev/null @@ -1,11 +0,0 @@ -use std::iter; - -fn main() { - let mut v = (0..20) - .map(|_| iter::empty::<()>()) - .collect::>(); - - for i in 1..8 { - v.remove(i + 1); - } -} -- cgit v1.2.3