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
#![cfg(test)] | |
#![feature(test)] | |
extern crate test; | |
use test::bench::{black_box, Bencher}; | |
fn concat_to_owned_push(a: &str, b: &str) -> String { | |
let mut s = a.to_owned(); | |
s.push_str(b); | |
s |
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 std::marker::PhantomData; | |
use std::fmt; | |
// Marker types for specifying the side of the first item and the previously | |
// added item | |
struct Left; | |
struct Right; | |
struct Empty; | |
struct AlternatingVec<L, R, P = Empty, S = Empty> { |
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
[package] | |
name = "lukas_threads" | |
version = "0.1.0" | |
authors = ["Peter Hall <peterjoel@gmail.com>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
audio_thread_priority = "0.15.0" |
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
struct A; | |
struct B(A); | |
fn d<T>(t: T) { | |
match std::mem::size_of_val(&t) { | |
n if n < 2 => print!("{}", n), | |
_ => print!("2"), | |
} | |
} |
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
trait Trait { | |
fn p(&self); | |
} | |
macro_rules! m { | |
($v: expr, $t: ty, $n: literal) => { | |
impl Trait for $t { | |
fn p(&self) { | |
print!($n); | |
} |
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
[package] | |
name = "serdebug" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
serde = { version = "1.0.91", features = ["derive"] } | |
serde_json = "1.0.39" |
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
[package] | |
name = "serde_fix_s" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
serde = { version = "1.0.91", features = ["derive"] } | |
[dev-dependencies] | |
serde_test = "1" |
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
[package] | |
name = "camelkebab" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
Inflector = "0.11.4" |
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
fn main() { | |
println!("type = {:?}", debug::type_name::<String>()); | |
let v = vec![Some(Box::new(|s: i32| println!("{:?}", s)))]; | |
println!("type = {:?}", debug::type_name_of_val(&v)); | |
} |
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
#![feature(test)] | |
extern crate test; | |
use std::cmp::min; | |
use std::collections::HashSet; | |
pub fn distribute_candies_loop_with_capacity(candies: Vec<i32>) -> i32 { | |
let sister_candies = (candies.len() / 2) as i32; | |
let mut kind = 0; | |
use std::collections::HashSet; | |
let mut candies_kinds = HashSet::with_capacity(candies.len()); |
NewerOlder