Skip to content

Instantly share code, notes, and snippets.

View japaric's full-sized avatar
🎯
focusing

Jorge Aparicio japaric

🎯
focusing
View GitHub Profile
@japaric
japaric / dot.rs
Created April 29, 2014 14:14
Vector dot product: BLAS accelerated implementation + naive implementation
use std::iter::AdditiveIterator;
use std::num::Zero;
#[link(name = "blas")]
extern {
fn ddot_(N: *int, x: *f64, inc_x: *int, y: *f64, inc_y: *int) -> f64;
fn sdot_(N: *int, x: *f32, inc_x: *int, y: *f32, inc_y: *int) -> f32;
}
trait VectorDot<T> {
@japaric
japaric / units-ng.rs
Created July 15, 2014 17:02
Phantom types for unit checking
#![feature(macro_rules)]
use time::traits::{Minute,Second};
use length::traits::Meter;
use prefix::traits::{Micro,Mili,Nano,Kilo};
mod traits {
pub trait Prefix {
fn symbol(_: Option<Self>) -> &'static str;
fn exponent(_: Option<Self>) -> int;
pub struct Bencher;
impl Bencher {
pub fn iter<T>(&mut self, _: || -> T) {}
}
enum Routine<'a> {
Function(Option<|&mut Bencher|:'a>),
ExternalProgram,
}
@japaric
japaric / stderr
Created October 7, 2014 01:40
Cargo test suite failed on ARM
/usr/local/bin/cargo test --target arm-unknown-linux-gnueabihf
Running target/arm-unknown-linux-gnueabihf/cargo-7107c6dcc9291e79
running 19 tests
test core::package_id_spec::tests::bad_parsing ... ok
test core::package_id::tests::invalid_version_handled_nicely ... ok
test core::package_id_spec::tests::matching ... ok
test core::package_id_spec::tests::good_parsing ... ok
test core::resolver::test::test_resolving_one_dep ... ok
test core::resolver::test::test_resolving_empty_dependency_list ... ok
@japaric
japaric / dstr.rs
Last active August 29, 2015 14:08
#![feature(macro_rules)]
#![no_implicit_prelude]
use std::iter::Iterator;
use std::option::{None, Option, Some};
use std::slice::ImmutableSlice;
use std::{iter, slice};
pub struct Str([u8]);
@japaric
japaric / with-6loc-patch.rs
Last active August 29, 2015 14:08
On top of Operator dispatch PR
fn main() {
let s: &[u8] = &[0u8, 1];
s == s; // OK
s == [0, 1]; // OK
[0, 1] == s;
//^~ error: mismatched types: expected `[_]`, found `&[u8]` (expected slice, found &-ptr)
@japaric
japaric / backtrace
Created November 3, 2014 17:01
SIGILL on run-pass tests
$ LD_LIBRARY_PATH=~/tmp/rust/build/x86_64-unknown-linux-gnu/stage2/lib gdb ./concat.stage2-x86_64-unknown-linux-gnu
Program received signal SIGILL, Illegal instruction.
#0 0x00007ffff7465df0 in oom::h93dfd3e3972e6f01uTa () from /home/japaric/tmp/rust/build/x86_64-unknown-linux-gnu/stage2/lib/librustrt-4e7c5e5c.so
#1 0x00007ffff744e291 in vec::Vec$LT$T$GT$::push_all::h13280501910359069037 () from /home/japaric/tmp/rust/build/x86_64-unknown-linux-gnu/stage2/lib/librustrt-4e7c5e5c.so
#2 0x00007ffff7452917 in unwind::begin_unwind_fmt::VecWriter$LT$$x27a$GT$.fmt..FormatWriter::write::ha595f73718a41d22vQd () from /home/japaric/tmp/rust/build/x86_64-unknown-linux-gnu/stage2/lib/librustrt-4e7c5e5c.so
#3 0x00007ffff74ad564 in fmt::Formatter$LT$$x27a$GT$::pad::hee6379fddecf9c14aMy () from /home/japaric/tmp/rust/build/x86_64-unknown-linux-gnu/stage2/lib/librustrt-4e7c5e5c.so
#4 0x00007ffff74a49ca in fmt::str.Show::fmt::he759648c8d60206aF4y () from /home/japaric/tmp/rust/build/x86_64-unknown-linux-gnu/stage2/lib/l
[package]
name = "map"
version = "0.0.0"
authors = ["Jorge Aparicio <[email protected]>"]
[dependencies.criterion]
git = "https://github.com/japaric/criterion.rs"
@japaric
japaric / Cargo.toml
Created November 24, 2014 14:01
Benchmarking lots of BufWriters
[package]
name = "serial"
version = "0.0.1"
authors = ["Jorge Aparicio <[email protected]>"]
[dependencies.criterion]
git = "https://github.com/japaric/criterion.rs"
[profile.test]
[package]
name = "serial"
version = "0.0.1"
authors = ["Jorge Aparicio <[email protected]>"]
[dependencies.criterion]
git = "https://github.com/japaric/criterion.rs"