Skip to content

Instantly share code, notes, and snippets.

fn main() {
println!("Hello, world!");
}
use failure::Fail;
#[derive(Debug, Fail)]
#[fail(display = "Hello World")]
struct MyError;
fn main() {
let err: Result<(), MyError> = Err(MyError);
println!("{}", err.unwrap_err());
}
@iopq
iopq / simple.rs
Last active December 15, 2018 05:37
#[macro_use]
extern crate failure;
use failure::Fail;
#[derive(Debug, Fail)]
#[fail(display = "my error")]
struct MyError;
#[derive(Debug, Fail)]
extern crate core;
extern crate html5ever;
#[macro_use]
extern crate string_cache;
#[macro_use]
extern crate tendril;
use html5ever::parse_document;
use html5ever::rcdom::{Element, Handle, RcDom};
@iopq
iopq / lib.rs
Created September 7, 2016 21:33
//does the monoid operation on the slice of tuples if the closure evaluates to true
fn accumulate<'a, T: Monoid>(tuples: &[(&'a str, &Fn(i32) -> bool)], i: i32) -> Option<T>
where &'a str: Into<T> {
tuples.iter()
.filter(|&&(_,include_fn)| include_fn(i))
.map(first)
.fold(None, |acc, concat_str| acc.op(Some(concat_str.into())))
}
@iopq
iopq / lib.rs
Created September 7, 2016 21:28
//does the monoid operation on the slice of tuples if the closure evaluates to true
fn accumulate<'a, T: Monoid>(tuples: &[(&'a str, &Fn(i32) -> bool)], i: i32) -> Option<T>
where &'a str: Into<T> {
tuples.iter()
.filter(|&&(_,include_fn)| include_fn(i))
.map(first)
.fold(None, |acc, concat_str| acc.op(Some(concat_str.into())))
}
@iopq
iopq / lib.rs
Created September 7, 2016 21:02
//! The `fizzbuzz` crate provides the way to get a customizable fizzbuzz implementation
//!
//! # Examples
//!
//! ```
//! let mut acc = "".to_string();
//! for i in 1..16 {
//! acc = acc + &*fizzbuzz::cowbuzz(&[
//! ("Fizz", &|i: i32| i % 3 == 0),
//! ("Buzz", &|i: i32| i % 5 == 0),
//#include <cuda_runtime.h>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <iostream>
#include <stdio.h>
[package]
name = "leaf-examples"
description = "Examples for the Machine Learning Framework 'Leaf'"
version = "0.1.0"
authors = ["Michael Hirn <[email protected]>",
"Maximilian Goisser <[email protected]>"]
[dependencies]
csv = "0.14"
# cuticula = "0.1.4"