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
extern crate rand; | |
use rand::Rng; | |
const WIDTH : usize = 80; | |
const HEIGH : usize = 40; | |
const SIZE : usize = WIDTH * HEIGH; | |
type MatrixLine = [bool; WIDTH]; |
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::cell::Cell; | |
#[derive(Debug)] | |
struct Ab { | |
a: i32, | |
b: i32, | |
cache: Cell<Option<i32>> | |
} | |
impl Ab { |
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 A { | |
fn a(&self); | |
} | |
trait B { | |
fn b(&self); | |
} | |
trait C { | |
fn c(&self); |
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
extern crate hyper; | |
extern crate tokio_core; | |
extern crate hyper_tls; | |
extern crate futures; | |
extern crate serde_json; | |
extern crate serde; | |
#[macro_use] | |
extern crate serde_derive; | |
use hyper::header; |
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
macro_rules! list_enum { | |
( $type:ident, { $($el:ident),* } ) => { | |
#[derive(Debug,Clone,Copy)] | |
enum $type{ | |
$($el),* | |
} | |
impl $type { | |
pub fn list() -> &'static[$type] { | |
const LIST : &'static[$type] = &[$($type::$el),*]; |
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::time::Duration; | |
use std::time::Instant; | |
// Executes `func` and logs warning or error message if it takes longer than specified. | |
pub fn log_exec<F, T>(label: &str, warn_millis: u64, error_millis: u64, func: F) -> T where F: FnOnce() -> T { | |
let warn_duration = Duration::from_millis(warn_millis); | |
let error_duration = Duration::from_millis(error_millis); | |
let start = Instant::now(); | |
let output = func(); |
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
require "securerandom" | |
require "digest/md5" | |
require "benchmark" | |
data1 = SecureRandom.random_bytes(5 * 1024 * 1024) | |
data2 = data1.dup | |
N = 500 | |
Benchmark.bm do |x| |
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
language: rust | |
rust: | |
- stable | |
install: | |
- rustup component add rustfmt-preview | |
- rustup component add clippy-preview | |
script: | |
- cargo fmt -- --check | |
- touch ./src/main.rs && cargo clippy -- -D warnings | |
- cargo test |
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
import { throwError, of, interval, Observable } from 'rxjs'; | |
import { take, filter, map, concatMap, catchError } from 'rxjs/operators'; | |
import { httpPoll, isNotReady } from './http-poll'; | |
function buildError(code) { | |
return { | |
error: { | |
errors: [{ code }] | |
} |
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
#!/bin/sh | |
PLAYGROUNDS_DIR="/tmp/rust-playgrounds" | |
TIMESTAMP=$(date +"%Y%m%d%H%M%S") | |
PROJECT_DIR="${PLAYGROUNDS_DIR}/playground${TIMESTAMP}" | |
cargo new $PROJECT_DIR | |
cd $PROJECT_DIR | |
# Add dependencies |