This file contains 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
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=440c65898633c8dba89e0a036f049e95 | |
use std::ops::Deref; | |
use std::marker::PhantomData; | |
#[repr(transparent)] | |
struct Getter<A, T>(T, PhantomData<A>); | |
impl<A, T, U> Deref for Getter<A, (T, U)> { | |
type Target = Getter<A, U>; | |
fn deref(&self) -> &Self::Target { |
This file contains 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
retain_std u64 almost_kept | |
time: [123.44 us 127.97 us 134.19 us] | |
Found 14 outliers among 100 measurements (14.00%) | |
2 (2.00%) low mild | |
5 (5.00%) high mild | |
7 (7.00%) high severe | |
retain_early_drop u64 almost_kept | |
time: [98.345 us 100.49 us 103.22 us] | |
Found 15 outliers among 100 measurements (15.00%) |
This file contains 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
{ | |
inputs = { | |
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable; | |
flake-utils.url = github:numtide/flake-utils; | |
rust-overlay.url = github:oxalica/rust-overlay; | |
}; | |
outputs = { nixpkgs, flake-utils, rust-overlay, ... }: | |
flake-utils.lib.eachSystem ["x86_64-linux"] (system: let | |
pkgs = import nixpkgs { |
This file contains 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 brainfuck::{program::Program, tape}; // brainfuck = "0.2.1" | |
fn gen_printer(s: &str) -> String { | |
assert!(!s.is_empty()); | |
let s = s.as_bytes(); | |
let mut buf = "+".repeat(s[0] as usize) + "."; | |
for (&prev, &cur) in s.iter().zip(&s[1..]) { | |
if prev < cur { | |
buf += &"+".repeat((cur - prev) as usize); | |
} else if cur < prev { |
This file contains 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
module Main | |
import Printf | |
%default total | |
||| Define the "like" relationship on two `Format`. | |
||| | |
||| One format is "like" the other one iff the former with all non-format-specifier removed is | |
||| the same as the later. |
This file contains 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
-- https://www.json.org/json-en.html | |
{-# LANGUAGE OverloadedStrings #-} | |
import Data.Map.Strict (Map, fromList) | |
import qualified Data.Text as T | |
import Data.Char (isDigit, chr, isHexDigit) | |
import Control.Monad (ap) | |
import Control.Applicative (Alternative(..), optional) | |
newtype Parser a = Parser { runParser :: T.Text -> Either String (T.Text, a) } |
This file contains 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
time: 0.979; rss: 176MB parse_crate | |
time: 0.000; rss: 176MB attributes_injection | |
time: 0.000; rss: 176MB incr_comp_prepare_session_directory | |
time: 0.000; rss: 176MB incr_comp_garbage_collect_session_directories | |
time: 0.000; rss: 176MB recursion_limit | |
time: 0.000; rss: 176MB plugin_loading | |
time: 0.000; rss: 176MB plugin_registration | |
time: 0.028; rss: 178MB pre_AST_expansion_lint_checks | |
time: 0.000; rss: 178MB crate_injection | |
time: 0.991; rss: 373MB expand_crate |
This file contains 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
// statx-sys = "0.3.0" | |
// libc = "0.2.62" | |
// criterion = "0.3.0" | |
// | |
// Bench with file `a` but no file `b` in working dir. | |
#![feature(const_cstr_unchecked)] | |
use libc; | |
use statx_sys; | |
use std::{ffi::CStr, fs, mem}; | |
use criterion::*; |
NewerOlder