Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Burka durka

View GitHub Profile
@insaneinside
insaneinside / draft.markdown
Created Sep 13, 2017
Whole-Crate Test-Case Reduction with C-Reduce
View draft.markdown

Whole-Crate Test-Case Reduction with C-Reduce

Sometimes, when working on a complex piece of software — or even a simple program or library with a non-trivial number of moving parts — you run into an issue and have absolutely no idea how to reduce your code to the minimum necessary in order to reproduce the error.

For the past several months I've been blocked by some trait-resolution errors in Symtern, my general-purpose interner crate. I knew the errors were somehow related to

View Rust Thread Safety.md

Justification of Send and Sync rules

T: Sync ⟺ &T: Send

Explanation

Consider a value a: T. Assume T: Sync. Then, to access a on multiple threads, it must be possible to send a reference to another thread, thus &T: Send. Therefore, T: Sync ⟹ &T: Send. Assume &T: Send. Sending &a: &T to another thread means a can be accessed concurrently, thus T: Sync is required. Therefore, &T: Send ⟹ T: Sync.

Proof

View enumdiscr.rs
//! ```cargo
//! [dependencies]
//! custom_derive = "*"
//! ```
#[macro_use] extern crate custom_derive;
macro_rules! DiscriminantEnum {
// public entry points
@durka
durka / munch.rs
Created Jul 22, 2015 — forked from anonymous/playground.rs
Simple TT muncher
View munch.rs
// switch to nightly and uncomment these for debugging
//#![feature(trace_macros)]
//trace_macros!(true);
/// Trick the macro parser into outputting an item without checking its syntax
macro_rules! as_item( ($i:item) => ($i) );
macro_rules! foo(
// first rule: define the invocation syntax and call myself again with some
// easily parseable parameters (notice everything is bracketed)
@14427
14427 / hkt.rs
Last active Aug 19, 2021
Higher-kinded type trait
View hkt.rs
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
View find_homebrew-installed-w-options.sh
#!/bin/bash
# assign env var, if set
HB="${HOMEBREW_PREFIX:=/usr/local}"
find -L "${HB}/opt" -name 'INSTALL_RECEIPT.json' -maxdepth 2 -print > /tmp/homebrew-installed.txt
printf '' > /tmp/homebrew-installed-w-options.txt
NAME=''
@killercup
killercup / pandoc.css
Created Jul 3, 2013
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
View pandoc.css
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}