Skip to content

Instantly share code, notes, and snippets.

View Marwes's full-sized avatar

Markus Westerlind Marwes

View GitHub Profile
@Marwes
Marwes / gist:7c0b3468d0cae972a2b4
Created June 13, 2015 18:47
Benchmark for rust deriving
#![feature(test, rand)]
extern crate rand;
extern crate test;
use rand::{Rand, Rng, SeedableRng, XorShiftRng};
#[derive(PartialEq, PartialOrd)]
enum Test {
Variant1,
Variant2,
Variant3,
extern crate combine;
use combine::{
between,
chainl1,
choice,
char,
digit,
letter,
many,
many1,
@Marwes
Marwes / combine_http_parser.rs
Last active August 29, 2015 14:27 — forked from m4rw3r/combine_http_parser.rs
Version of the attoparsec example using the parser combinator Combine.
extern crate combine;
use combine::*;
use combine::combinator::take_while1;
use std::fs::File;
use std::env;
#[derive(Debug)]
@Marwes
Marwes / compile-fail.json
Created October 29, 2016 16:07
compile-fail spans with macros
{
"message": "cannot infer an appropriate lifetime for lifetime parameter `'vm` due to conflicting requirements",
"code": {
"code": "E0495",
"explanation": null
},
"level": "error",
"spans": [
{
"file_name": "<gluon_vm macros>",
@Marwes
Marwes / main.rs
Last active July 4, 2017 15:30 — forked from Xanewok/main.rs
extern crate languageserver_types as ls_types;
pub trait Request {
type Param;
type Result;
// Has to be a method as associated constants are unstable
fn method(&self) -> &'static str;
}
struct RequestStruct<Params> {
@Marwes
Marwes / parser.rs
Last active July 20, 2017 18:12 — forked from MaikKlein/parser.rs
use ast::*;
use std::str::FromStr;
grammar;
pub Entry: () = {
"#" "[" "entry" "]" => (),
};
pub Statement: Statement<'input> = {
"let" <var:Variable> "=" <init_expr: Expr> ";"
use serde::{Deserialize, Deserializer, Serialize, Serializer};
pub struct Readable<T: ?Sized>(T);
pub struct Compact<T: ?Sized>(T);
pub trait Configure {
fn readable(&self) -> Readable<&Self> {
Readable(self)
}
fn compact(&self) -> Compact<&Self> {
@Marwes
Marwes / cargo_test.txt
Created March 15, 2018 17:50 — forked from boxofrox/cargo_test.txt
simple shell parser in Rust using combine crate (not working)
$ cargo test
Compiling csvmap v0.1.0 (file:///home/charetjc/files/development/rust/tinker/csvmap)
Finished dev [unoptimized + debuginfo] target(s) in 2.34 secs
Running target/debug/deps/csvmap-cdc7458d4bf17d5e
running 5 tests
test tests::can_parse ... ok
test tests::can_parse_single_quoted_shell_arg ... ok
test tests::can_parse_double_quoted_shell_arg ... ok
test tests::can_parse_any_shell_arg ... FAILED
@Marwes
Marwes / try_gluon.glu
Created September 29, 2018 13:36
Gluon code shared from try_gluon
let de @ { Deserialize, ? } = import! std.json.de
let ser @ { Serialize, ? } = import! std.json.ser
let { Result } = import! std.result
#[derive(Serialize, Deserialize)]
type Vec = { x : Float, y : Float, name : Option String }
match de.deserialize de.deserializer r#"{ "x": 123, "y": 456.78, "name": null }"# with
| Err err -> err
| Ok v ->
@Marwes
Marwes / Cargo.toml
Last active December 11, 2019 09:44 — forked from huin/Cargo.toml
Userdata type unknown by name in Gluon
[package]
name = "gluon_userdata"
version = "0.1.0"
edition = "2018"
[dependencies]
gluon = "0.13.1"
gluon_codegen = "0.13.1"
gluon_vm = "0.13.1"