Skip to content

Instantly share code, notes, and snippets.

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/portage/generic/dev-lang/rust/rust-0.3.ebuild $
EAPI=4
DESCRIPTION="Rust a safe, concurrent, practical language"
HOMEPAGE="http://www.rust-lang.org"
SRC_URI="http://dl.rust-lang.org/dist/${P}.tar.gz"
import to_str::*;
class bf_stack {
priv {
let mut data : ~[int];
}
new() {
self.data = ~[0];
}
import io::*;
import to_str::*;
enum some_enum {
foo(~[some_enum]),
bar
}
impl to_str for some_enum {
fn to_str() -> str {
user@note ~/soft/mine/rust $ rustc example.rs && ./example
example.rs:13:32: 13:43 error: failed to find an implementation of interface core::to_str::to_str for some_enum
example.rs:13 foo(nest) { "foo" + nest.to_str() }
^~~~~~~~~~~
import io::*;
import to_str::*;
impl <T : to_str copy> of to_str for ~[mut T] {
fn to_str() -> str {
let tmp = copy self;
tmp.map(|x| { x.to_str() }).to_str()
}
}
@iamtakingiteasy
iamtakingiteasy / example.rs
Created July 15, 2012 20:44
lp internal error
import io::*;
import to_str::*;
impl <T : to_str copy> of to_str for @[mut T] {
fn to_str() -> str {
let tmp = self;
tmp.map(|x| { x.to_str() }).to_str()
}
}
import io::*;
import to_str::*;
impl <T : to_str copy> of to_str for @[mut T] {
fn to_str() -> str {
let tmp = self;
tmp.map(|x| { x.to_str() }).to_str()
}
}
@iamtakingiteasy
iamtakingiteasy / crunch.hs
Created August 22, 2012 13:58
Project euler haskell solutions
module Main where
import Data.Char
import Data.List
import Control.Monad
main :: IO ()
main = return ()
fibonacci :: [Integer]
void exploreLCG() {
uint64_t min = pow(10,1);
uint64_t max = pow(10,2);
auto f = computeLCG(min, max);
srand(time(0));
uint64_t terminator = min + (rand() % (max-min));
uint64_t x = f(terminator);
std::cout << x << "\n";
while (x != terminator) {
@iamtakingiteasy
iamtakingiteasy / bus_test.go
Created May 3, 2017 14:14
Simple go-ish message bus
package bus
import (
"fmt"
"testing"
)
type intMessage struct {
value int
}