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
.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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='' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! ```cargo | |
//! [dependencies] | |
//! custom_derive = "*" | |
//! ``` | |
#[macro_use] extern crate custom_derive; | |
macro_rules! DiscriminantEnum { | |
// public entry points |
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