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(trace_macros)] | |
trace_macros!(true); | |
/// Piano numbers | |
#[derive(Debug)] | |
struct S<T>(T); | |
trait ToInt {fn to_int(self) -> i32;} | |
impl ToInt for i32 {fn to_int(self) -> i32 {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
use std::mem::{replace}; | |
#[derive(Clone, Debug)] | |
struct HasDrop(i32); | |
impl Drop for HasDrop { | |
fn drop(&mut self) { | |
println!("Dropping {}!", self.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
#![feature(trace_macros)] | |
#![feature(log_syntax)] | |
//trace_macros!(true); | |
macro_rules! id {($e : expr) => ($e)} | |
macro_rules! vecc {($($t:tt)*) => (Vecc{v:vec!($($t)*)})} | |
macro_rules! mdo { |
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() { | |
use std::borrow::Cow; | |
#[allow(dead_code)] | |
fn abs_all(input: &mut Cow<[i32]>) { | |
for i in 0..input.len() { | |
let v = input[i]; | |
if v < 0 { | |
// clones into a vector the first time (if not already owned) | |
input.to_mut()[i] = -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
use std::borrow::Cow; | |
use std::sync::Arc; | |
fn fizz_buzz(i: i32) -> Cow<'static, str> { | |
if i % 15 == 0 { | |
"FizzBuzz".into() | |
} else if i % 5 == 0 { | |
"Buzz".into() | |
} else if i % 3 == 0 { | |
"Fizz".into() |
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::iter::FromIterator; | |
enum List { Nil, Cons{value: i32, next: Box<List>}} | |
fn main() { | |
let v = vec![1, 5, 3, 8, 12, 56, 1230, 2, 1]; | |
//let root: List = v.iter().cloned().collect(); | |
let root = List::from_iter(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(trace_macros)] | |
#![feature(log_syntax)] | |
//trace_macros!(true); | |
macro_rules! id {($e : expr) => ($e)} | |
macro_rules! vecc {($($t:tt)*) => (Vecc{v:vec!($($t)*)})} | |
macro_rules! mdo { |
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
#![allow(dead_code, unused_variables)] | |
struct PrimeList { | |
primes: Vec<i32>, | |
} | |
/// Basically the same as | |
/// self.primes.iter().cloned().chain(self) on a PrimeList | |
struct PrimeIter<'a> { | |
primes: &'a mut PrimeList, |
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
// ==UserScript== | |
// @name Keybr github | |
// @namespace https://github.com/anka-213 | |
// @version 0.1 | |
// @description Type a github repo using keybr.com | |
// @author You | |
// @match http://www.keybr.com/* | |
// @grant unsafeWindow | |
// ==/UserScript== | |
/* jshint -W097, esnext:true */ |
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
[ 9861.810] | |
X.Org X Server 1.16.0 | |
Release Date: 2014-07-16 | |
[ 9861.810] X Protocol Version 11, Revision 0 | |
[ 9861.810] Build Operating System: Linux 3.15.5-2-ARCH x86_64 | |
[ 9861.810] Current Operating System: Linux hjulle-arch 3.15.8-1-ARCH #1 SMP PREEMPT Fri Aug 1 08:51:42 CEST 2014 x86_64 | |
[ 9861.810] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux_ root=UUID=ff8f26b9-4592-44b5-a10a-c8b4ebd9d446 rw rootflags=subvol=arch quiet nouveaufb fbcon=scrollback:1024k resume=/dev/disk/by-uuid/765e6360-9a02-478c-8582-4e175cff35e9 | |
[ 9861.810] Build Date: 31 July 2014 11:53:19AM | |
[ 9861.810] | |
[ 9861.810] Current version of pixman: 0.32.6 |