Skip to content

Instantly share code, notes, and snippets.


Hero Bird Robbepop

View GitHub Profile
Kestrer /
Created Oct 17, 2020
A guide on how to write hygienic Rust macros

How to Write Hygienic Rust Macros

Macro hygiene is the concept of macros that work in all contexts; they don't affect and aren't affected by anything around them. Ideally all macros would be fully hygienic, but there are lots of pitfalls and traps that make it all too easy to accidentally write unhygienic macros. This guide attempts to provide a comprehensive resource for writing the most hygienic macros.

Understanding the Module System

First, a little aside on the details of Rust's module system, and specifically paths; it is

kmcallister / .travis.yml
Created Jun 6, 2017
travis setup for clippy (untested)
View .travis.yml
language: rust
- stable
- beta
- nightly
- cargo build --verbose
- cargo test --verbose
- if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo install clippy && cargo clippy; fi
Robbepop / .rustfmt.toml
Created Mar 16, 2017
.rustfmt.toml with all configs, descriptions, parameters and defaults for version 0.7.1 of rustfmt.
View .rustfmt.toml
# ----------------------------------------------------------------------------------
# r u s t f m t - C O N F I G
# ==================================================================================
# Version: 0.7.1
# Author : Robbepop <>
# A predefined .rustfmt.toml file with all configuration options and their
# associated description, possible values and default values for use in other
# projects.
lichray /
Last active Apr 22, 2020
Factory function of std::array
#include <array>
#include <functional>
template <typename... T>
using common_type_t = typename std::common_type<T...>::type;
template <typename T>
using remove_cv_t = typename std::remove_cv<T>::type;
template <bool, typename T, typename... U>