Skip to content

Instantly share code, notes, and snippets.

View sunaemon's full-sized avatar

sunaemon sunaemon

  • Tokyo
View GitHub Profile
@qnighy
qnighy / rust-patterns.md
Last active March 20, 2024 03:33
Rustのパターンっぽいやつメモ

パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。

ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。

  • crate splitting
    • でかいcrateを分割して、見通しを良くする・再コンパイルの分量を削減する・並列コンパイルを可能にする
  • 親玉crate(全てにdependする)と殿crate(全てにdependされる)があることが多いので、だいたい束みたいな形になる。
@qnighy
qnighy / noncomm_ring.als
Created August 15, 2013 08:30
非可換環を探す
sig R {
plus : R -> one R,
opp : R,
mult : R -> one R
}
one sig O extends R {}
one sig I extends R {}
fact Rplus_abelian {
all x,y,z : R | x.plus[y].plus[z] = x.plus[y.plus[z]]