Skip to content

Instantly share code, notes, and snippets.

View ucarion's full-sized avatar
💭

Ulysse Carion ucarion

💭
View GitHub Profile
@ucarion
ucarion / llvm_fun.rs
Created July 1, 2016 01:01
A miniature LLVM-based compiler
#![feature(plugin)]
#![plugin(peg_syntax_ext)]
extern crate llvm_sys as llvm;
use std::ptr;
use std::ffi::CString;
use std::collections::HashMap;
use llvm::prelude::*;
@ucarion
ucarion / -
Created September 20, 2015 01:38
Compiling lcs v0.1.0 (file:///Users/ulyssecarion/rust/rust-lcs)
src/lib.rs:26:14: 26:47 error: the trait `core::cmp::Eq` is not implemented for the type `T` [E0277]
src/lib.rs:26 self.backtrack(a, b, a.len(), b.len())
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:26:14: 26:47 help: run `rustc --explain E0277` to see a detailed explanation
src/lib.rs:26:14: 26:47 error: the trait `core::cmp::Eq` is not implemented for the type `T` [E0277]
src/lib.rs:26 self.backtrack(a, b, a.len(), b.len())
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:26:14: 26:47 help: run `rustc --explain E0277` to see a detailed explanation
error: aborting due to previous error
@ucarion
ucarion / -
Created September 20, 2015 01:38
Compiling lcs v0.1.0 (file:///Users/ulyssecarion/rust/rust-lcs)
Build failed, waiting for other jobs to finish...
fn backtrack<'a, T>(&self, a: &'a [T], b: &'a [T], i: usize, j: usize) -> Vec<&'a T>
where T: Eq {
if i == 0 || j == 0 {
vec![]
} else if a[i] == b[j] {
let mut prefix_lcs = self.backtrack(a, b, i - 1, j - 1);
prefix_lcs.push(&a[i]);
prefix_lcs
https://gist.github.com/0513b84bd3981d34cb88
@ucarion
ucarion / rust
Created September 20, 2015 01:34
fn backtrack<'a, T>(&self, a: &'a [T], b: &'a [T], i: usize, j: usize) -> Vec<&'a T>
where T: Eq {
if i == 0 || j == 0 {
vec![]
} else if a[i] == b[j] {
let mut prefix_lcs = self.backtrack(a, b, i - 1, j - 1);
prefix_lcs.push(&a[i]);
prefix_lcs
@ucarion
ucarion / rust
Created September 20, 2015 01:34
https://gist.github.com/b22eb3d132441a4e5b19
@ucarion
ucarion / -
Created September 20, 2015 01:33
fn backtrack<'a, T>(&self, a: &'a [T], b: &'a [T], i: usize, j: usize) -> Vec<&'a T>
where T: Eq {
if i == 0 || j == 0 {
vec![]
} else if a[i] == b[j] {
let mut prefix_lcs = self.backtrack(a, b, i - 1, j - 1);
prefix_lcs.push(&a[i]);
prefix_lcs
use std::io::{self, Read, Write};
use std::net::Shutdown;
use hyper::net::{HttpConnector, NetworkConnector, HttpStream};
fn fetch_http(host: &str, port: u16, scheme: &str, data: &[u8]) -> io::Result<Vec<u8>> {
let mut connector = HttpConnector(None);
let mut stream = connector.connect(host, port, scheme).unwrap();
println!("{:?}", stream);
Compiling net_replayer v0.0.1 (file:///Users/ulyssecarion/rust/net_replayer)
src/lib.rs:4:1: 4:5 src/lib.rs:4:1: 4:5 error: error: expected item, found `asdf`
expected item, found `asdf`src/lib.rs
:4 asdf--
src/lib.rs:4 asdf--
^~~~
^~~~
Build failed, waiting for other jobs to finish...
Could not compile `net_replayer`.