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 = "trace" | |
version = "0.0.1" | |
authors = ["Till Hoeppner <till@hoeppner.ws>"] | |
[lib] | |
name = "trace" | |
path = "src/lib.rs" | |
plugin = 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
/// How can I elegantly make this work? | |
/// play.rust-lang.org didn't seem to be able to *share* right now, so I used gist... | |
#[allow(dead_code)] | |
trait D { | |
fn d(&mut self) {} | |
} | |
#[deriving(Show)] | |
struct 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
/// Never really tested this... | |
#[inline(always)] | |
fn set_bit<T: One + BitOr<T, T> + BitAnd<T, T> + Shl<T, T> + Not<T>>(val: T, bit: T, on: bool) -> T { | |
if on { val | one::<T>() << bit } else { val & !(one::<T>() << bit) } | |
} |
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
#[derive(Show, PartialEq, Eq, Hash, Clone)] | |
pub struct Message { | |
pub prefix: Option<String>, | |
pub command: String, | |
pub content: Vec<String>, | |
pub suffix: Option<String> | |
} | |
impl Message { | |
pub fn new(prefix: Option<String>, command: String, content: Vec<String>, suffix: Option<String>) -> Message { |
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
#V4L2/CTRL/0.0.2 | |
APP{"guvcview 2.0.1"} | |
# control data | |
#Brightness | |
ID{0x00980900};CHK{-100:100:1:0}=VAL{0} | |
#Contrast | |
ID{0x00980901};CHK{0:30:1:15}=VAL{15} | |
#Saturation | |
ID{0x00980902};CHK{0:48:1:32}=VAL{35} | |
#Hue |
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/bash | |
echo ' | |
#![feature(core)] | |
use std::num::Float; | |
fn is_prime(i: i32) -> bool { | |
for j in 2..(i as f32).sqrt() as i32 + 1 { | |
unsafe { std::intrinsics::assume(j != 0) } | |
if i % j == 0 { | |
return false; | |
} |
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() { | |
for i in 1..101 { | |
match (i % 3, i % 5) { | |
(0, 0) => println!("Fizzbuzz"), | |
(0, _) => println!("Fizz"), | |
(_, 0) => println!("Buzz"), | |
_ => println!("{}", i), | |
} | |
} | |
} |
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::io::{ BufReader, BufReadExt }; | |
use std::fs; | |
fn main() { | |
let file = BufReader::new(fs::File::open("./Cargo.toml").unwrap()); | |
for line in file.lines() { | |
println!("{}", line.unwrap()); | |
} | |
} |
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::io::{ self, BufReader, BufRead }; | |
fn main() { | |
let input = BufReader::new(io::stdin()); | |
let mut buffer = String::new(); | |
for line in input.lines() { | |
match line { | |
Ok(l) => buffer.push_str(&l), | |
Err(e) => panic!(e) | |
} |
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::io::{ self, BufReader, BufRead }; | |
fn main() { | |
let input = BufReader::new(io::stdin()); | |
let mut buffer = String::new(); | |
for line in input.lines() { | |
match line { | |
Ok(l) => buffer.push_str(&l), | |
Err(e) => panic!(e) | |
} |
OlderNewer