Skip to content

Instantly share code, notes, and snippets.

use itertools::zip;
use std::ops::{BitXor, BitXorAssign};
pub fn xor<T>(x: &[T], y: &[T]) -> Vec<T>
where T: BitXor<Output=T> + Copy {
zip(x, y).map(|(a, b)| *a ^ *b).collect()
}
pub fn xor_with<T>(x: &mut [T], y: &[T])
where T: BitXorAssign + Copy {
@mbrubeck
mbrubeck / lib.rs
Last active July 19, 2018 16:05 — forked from pftbest/lib.rs
#![feature(test)]
extern crate test;
trait Max2 {
type Item;
fn max_by_key2<B: Ord, F>(self, f: F) -> Option<Self::Item> where
Self: Sized,
F: FnMut(&Self::Item) -> B;
}
[package]
name = "foo"
version = "0.1.0"
authors = ["Matt Brubeck <[email protected]>"]
edition = "2018"
[dependencies]
[build-dependencies]
smallvec = "0.6"
[package]
name = "pb"
version = "0.1.0"
authors = ["Matt Brubeck <[email protected]>"]
edition = "2018"
[[bin]]
name = "pb"
path = "main.rs"
test basic::get_100_std::header_map ... bench: 623 ns/iter (+/- 145)
test basic::get_100_std::order_map_fnv ... bench: 613 ns/iter (+/- 244)
test basic::get_100_std::order_map_seahash ... bench: 1,511 ns/iter (+/- 237)
test basic::get_100_std::std_map_fnv ... bench: 393 ns/iter (+/- 27)
test basic::get_100_std::vec_map ... bench: 2,628 ns/iter (+/- 147)
test basic::get_10_custom_short::header_map ... bench: 103 ns/iter (+/- 12)
test basic::get_10_custom_short::order_map_fnv ... bench: 97 ns/iter (+/- 13)
test basic::get_10_custom_short::order_map_seahash ... bench: 259 ns/iter (+/- 34)
test basic::get_10_custom_short::std_map_fnv ... bench: 91 ns/iter (+/- 10)
test basic::get_10_custom_short::vec_map ... bench: 389 ns/iter (+/- 32)
test header_map order_map_fnv std_map_fnv order_map_seahash vec_map
get_100_std 623 613 393 1,511 2,628
get_10_custom_short 103 97 91 259 389
get_10_of_20_std 54 52 39 114 42
hn_hdrs_set_11_get_with_miss 774 739 771 1,062 735
hn_hdrs_set_8_get_many 664 680 701 912 470
hn_hdrs_set_8_get_miss 502 543 616 593 373
insert_100_custom_headers 6,331 5,924 14,043 6,900 28,461
insert_4_std_get_30 381 360 460 580 357
insert_500_custom_headers 30,174 26,153 54,672 32,465 568,644
#![allow(dead_code)]
use chrono::prelude::*;
use chrono::Duration;
use redux_rs::{Store, Subscription};
use std::boxed::Box;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
struct State {
date: Date<Utc>,