Skip to content

Instantly share code, notes, and snippets.

@bvssvni
bvssvni / gist:9674632
Last active December 23, 2023 22:56
A Rust Chain Macro
//! Chain macro in Rust
//!
//! A typical usage is to avoid nested match expressions.
//!
//! Supports:
//! - Pattern matching
//! - Or expressions (A | B => ...)
//! - Guarded statements (x if <cond> => ...)
//! - Implicit else (requires all arms to return same type)
/// Phantom type for step 1.
pub enum Step1 {}
/// Phantom type for step 2.
pub enum Step2 {}
/// Contains data we set step by step.
pub struct Data<'a> {
/// 'a' is set in the first step.
a: Option<int>,
@gongo
gongo / json-reformat.el
Last active June 11, 2020 00:48
見づらい JSON 文字列を雰囲気見やすくする elisp です http://gongo.hatenablog.com/entry/2012/02/10/222051
;;; json-reformat --- Reformat tool for JSON
;; Author: Wataru MIYAGUNI <gonngo@gmail.com>
;; Keywords: json
;; Copyright (c) 2012 Wataru MIYAGUNI
;;
;; MIT License
;;
;; Permission is hereby granted, free of charge, to any person obtaining