Skip to content

Instantly share code, notes, and snippets.

/*!
this module implements the AES algorithm completely in software without using any table lookups or
other timing dependant mechanisms. This module actually contains two seperate implementations - an
implementation that works on a single block at a time and a second implementation that processes 8
blocks in parallel. Some block encryption modes really only work if you are processing a single
blocks (CFB, OFB, and CBC encryption for example) while other modes are trivially parallelizable
(CTR and CBC decryption). Processing more blocks at once allows for greater efficiency, especially
when using wide registers, such as the XMM registers available in x86 processors.
@DaGenix
DaGenix / gist:6288591
Created August 20, 2013 23:19
This doesn't work for me
use std::unstable::simd::u32x4;
static test: u32x4 = u32x4(0, 0, 0, 0);
fn main() {
}
@DaGenix
DaGenix / gist:5898568
Created July 1, 2013 05:35
call twice thing
fn call(f: &fn()) {
f();
}
fn call_twice(f: &fn()) {
call(f);
call(f);
}
fn main() {
fn test() -> (u32, u32) {
return (0, 0,);
}
fn main() {
let mut X0 = 0u32;
let mut X1 = 0u32;
(X0, X1) = test();
}
@DaGenix
DaGenix / gist:5895932
Created June 30, 2013 16:53
Seemingly incorrect use of uninitialized variable error
fn test() -> (u32, u32) {
return (0, 0,);
}
fn main() {
let mut X0: u32;
let mut X1: u32;
(X0, X1) = test();
}
struct Works {
val: int
}
impl Works {
fn fn1(&mut self) {
// This seems to work perfectly fine
self.fn2(&const self.val);
}
fn fn2(&mut self, x: &const int) {
@DaGenix
DaGenix / gist:5793174
Created June 16, 2013 19:49
Short (possibly invalid) program that makes the rust compiler crash with an assertion
trait Printable {
fn print(&self);
}
fn test(o: &[~Printable]) {
for o.each |&p| {
p.print();
}
}
@DaGenix
DaGenix / gist:5545095
Last active December 17, 2015 03:39
Rust code that won't compile
// This code works fine
fn get(f: ~fn() -> int) -> ~fn() -> int {
|| {
f()
}
}
fn main() {
get(|| {8})();
}