This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MacBook-de-Geo:phpinclude geal$ cat Dockerfile | |
# -*- sh -*- | |
FROM base/archlinux | |
MAINTAINER Geoffroy Couprie, [email protected] | |
RUN echo -e "[multilib]\nInclude = /etc/pacman.d/mirrorlist" > /tmp/multilib | |
RUN cat /etc/pacman.conf /tmp/multilib > /tmp/pacman.conf | |
RUN mv /tmp/pacman.conf /etc/pacman.conf | |
RUN pacman -Syu --noconfirm | |
RUN pacman -S --noconfirm curl unzip lib32-zlib lib32-ncurses lib32-bzip2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn prod<'a,'b>(a:uint) -> Box<FnMut(&'b[u8]) -> &'b[u8] +'a> { | |
box move |&: input: &'b[u8]| -> &'b[u8] { | |
input.slice_from(a) | |
} | |
} | |
fn main() { | |
let mut a = prod(2); | |
println!("a1: {}", a("abcdefgh".as_bytes())); | |
// -> a1: [99, 100, 101, 102, 103, 104] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub type Fun<'a, I, O> = Box<FnMut(I) -> Res<'a, I, O> +'a>; | |
pub enum Res<'a, I, O> { | |
Done(I, O), | |
Incomplete(Fun<'a, I, O>) | |
} | |
pub trait FMap<I, O, N> { | |
fn fmap<'y,F: Fn(O) -> N>(&'y self, f: F) -> Res<'y, I, N>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub type Fun<'a> = Box<FnMut(u8) -> Res<'a> +'a>; | |
pub enum Res<'a> { | |
Done(u8, u8), | |
Incomplete(Fun<'a>) | |
} | |
pub trait FMap { | |
fn fmap<'y,F: Fn(u8) -> u8 + 'y>(&'y mut self, f: F) -> Res<'y>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub type Fun<'a> = Box<FnOnce(u8) -> Res<'a> +'a>; | |
pub enum Res<'a> { | |
Done(u8, u8), | |
Incomplete(Fun<'a>) | |
} | |
pub trait FMap { | |
fn fmap<'y,F: Fn(u8) -> u8 + 'y>(self, f: &'y F) -> Res<'y>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub type Fun<'a> = Box<FnOnce(u8) -> Res<'a> +'a>; | |
pub enum Res<'a> { | |
Done(u8, u8), | |
Incomplete(Fun<'a>) | |
} | |
pub trait FMap { | |
fn fmap<'y,F: Fn(u8) -> u8 + 'y>(self, f: &'y F) -> Res<'y>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub enum State { | |
A, | |
B(u8), | |
C(u8), | |
D | |
Error | |
} | |
enum Output { | |
X(u8), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What you need to write low level Rust code | |
* do not use cargo, use rustc directly to build your code | |
* you need to use a target.json file describing your target platform (example: https://github.com/hackndev/zinc/blob/master/thumbv6-none-eabi.json ). Pass it to rustc via --target=target.json | |
* you wan work without the standard library, by following those instructions: https://doc.rust-lang.org/book/no-stdlib.html | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub enum Err<'a,P=&'a[u8]> { | |
Code(u32), | |
Node(u32,Box<Err<'a>>), | |
Position(u32,P) | |
} | |
pub enum IResult<'a,I,O> { | |
Done(I,O), | |
Error(Err<'a>) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
extern crate test; | |
use test::Bencher; | |
#[macro_use] | |
extern crate nom; | |
use nom::IResult; | |
use std::env; | |
use std::fs::File; |