Notes on adding Constraint Kinds to Rust
a trait can be thought of as a type operator generating a "constraint" - what in Rust would usually be called a bound. For example:
// Declares a new item `Foo` with kind `type -> constraint`
trait Foo { }
# Viktor Dukhovni's (@vdukhovni) slow rebase, made faster by bisecting, sort of | |
# | |
# fastrebase BRANCH_TO_REBASE ONTO | |
function fastrebase { | |
typeset b N | |
if (($# > 0)) && [[ $1 = -h || $1 = --help ]]; then | |
printf 'Usage: fastrebase BRANCH_TO_REBASE ONTO_HEAD\n' | |
printf ' fastrebase # to continue after resolving conflicts\n' | |
printf '\n\tfastrebase is a shell function that uses the following\n' |
#!/usr/bin/env python | |
# Takes the output of `cargo +nightly build -Z unstable-options --build-plan` and produces | |
# a graphviz .dot file. | |
from __future__ import print_function, unicode_literals | |
import sys | |
import json | |
with open(sys.argv[1]) as f: |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#ifdef _MSC_VER | |
#include <intrin.h> /* for rdtscp and clflush */ | |
#pragma optimize("gt",on) | |
#else | |
#include <x86intrin.h> /* for rdtscp and clflush */ | |
#endif |
// ==UserScript== | |
// @name unfix-all-the-toolbars | |
// @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such. | |
// @namespace http://inf.ufrgs.br/~vbuaraujo/ | |
// @include * | |
// @version 1.2 | |
// @grant none | |
// ==/UserScript== | |
[dependencies] | |
parking_lot_core = "0.1" |
extern { | |
fn magic() -> i32; | |
} | |
#[no_mangle] | |
pub extern fn calc(a: i32, b: i32) -> i32 { | |
a + b + unsafe{magic()} + 10000 | |
} |
#![feature(lang_items)] | |
#![no_std] | |
#[no_mangle] | |
pub fn add_one(x: i32) -> i32 { | |
x + 1 | |
} | |
// needed for no_std |
// Did you ever want to have a compile-time evaluated string and didn't | |
// want to use so called "procedural macros" because it's too easy to | |
// have that with those? Well, now you can. | |
// | |
// ... Oh, right, there is a small catch. The computation has to be in | |
// Brainfuck. But I mean, it's Turing complete, so you can do any | |
// computation you like, so it's not a big deal, is it? | |
// | |
// Scroll down to the end to see usage, but essentially this file | |
// defines `bf!` macro to which you can pass whatever Brainfuck code |
" when triggering this command, vim will grab your path and line location and pass it along | |
map <Leader>el :call RemoteSendCommand(TestLineCommand(expand("%:p"), line(".")))<CR> | |
" because I'm mostly writing Elixir and making heavy use of the REPL while writing my tests, | |
" I made a specific command to user with Mix, the Elixir task utility | |
" But I'm sure you could get this to work with vim-test or something like that | |
function! TestLineCommand(path, line_number) | |
let cmd = join(["mix test --only", " line:", a:line_number, " ", a:path], "") | |
return cmd | |
endfunction |