Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -eu
shopt -s nullglob
readonly base_dir=/var/local/docker-registry
readonly output_dir=$(mktemp -d -t trace-images-XXXX)
readonly jq=/tmp/jq
readonly repository_dir=$base_dir/repositories
#![feature(coroutines, coroutine_trait)]
use snafu::prelude::*;
use std::{
ops::{Coroutine, CoroutineState},
pin::pin,
str,
};
#[derive(Debug, Copy, Clone)]
//! This crate provides types for UCD’s `Blocks.txt`.
pub struct Blocks {
ranges: Vec<(RangeInclusive<u32>, String)>,
}
impl Blocks {
pub fn block_of(&self, c: char) -> &str {
self.ranges
.binary_search_by(|(range, _)| {
#[derive(Debug, Snafu)]
#[snafu(module)]
enum Error { Alpha }

By default, should that generate

mod error {
@shepmaster
shepmaster / README.md
Last active March 11, 2020 05:21 — forked from kelcecil/README.md
Implementation of binary search tree in OCaml and Rust (modeled after the OCaml solution).

Here's two implementations of a binary search tree in OCaml and Rust. The Rust version was written to deliberately look as close to the OCaml as possible (and it'd get pretty close if I used match instead of OCaml's variants). I'm pretty sure my OCaml implementation is idiomatic, and I'd like some advice on what steps I'd probably take to make the Rust example more idiomatic. My objective is to talk about how close the examples can be to each other as well as how different the examples can be (hopefully demonstrating strengths for both.)

Any other thoughts or ideas are also helpful and super appreciated!

@shepmaster
shepmaster / playground.rs
Created January 19, 2020 04:13
Code shared from the Rust Playground
// This code was saved by an automated test for the Rust Playground
@shepmaster
shepmaster / playground.rs
Created January 19, 2020 02:49
Code shared from the Rust Playground
// This code was saved by an automated test for the Rust Playground
@shepmaster
shepmaster / playground.rs
Created January 18, 2020 19:04
Code shared from the Rust Playground
// This code was saved by an automated test for the Rust Playground
@shepmaster
shepmaster / playground.rs
Created January 18, 2020 18:44
Code shared from the Rust Playground
// This code was saved by an automated test for the Rust Playground
@shepmaster
shepmaster / playground.rs
Created December 19, 2019 04:21
Code shared from the Rust Playground
// This code was saved by an automated test for the Rust Playground