Skip to content

Instantly share code, notes, and snippets.

Alexis Beingessner Gankra

Block or report user

Report or block Gankra

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Gankra
Gankra / gist:481ca253d89cfea60dbe
Last active Aug 29, 2015
Simple Compilable Rust Example
View gist:481ca253d89cfea60dbe
struct SomeStruct{
data: uint
}
impl SomeStruct{
fn setData (&mut self, value: uint) {
self.data = value
}
fn getData (&self) -> uint {
View gist:b918e7ab9117de26eb22
//multiplicative range to keep neighbours beyond nearest neighbour
var rangeSensitivity = Math.sqrt(1.8); //a bit less than sqrt(2), basically a magic number
//main function
GridThing.doMap = function(collection){
var graph = new Graph();
//unimportant construction of points
buildGrid(graph);
View gist:c1df6776093e04be342b
use std::ptr::RawPtr;
type NodeRef<T> = Option<Box<Node<T>>>;
type NodeBackRef<T> = *mut Node<T>;
struct Node<T> {
left: NodeRef<T>,
right: NodeRef<T>,
parent: NodeBackRef<T>,
value: T,
View gist:8046d0bdd82a482e4350
use std::ptr::RawPtr;
type NodeRef<T> = Option<Box<Node<T>>>;
type NodeBackRef<T> = *mut Node<T>;
struct Node<T> {
left: NodeRef<T>,
right: NodeRef<T>,
parent: NodeBackRef<T>,
value: T,
View Error on non-recursive
rustc: i686-pc-mingw32/stage2/test/collectionstest-i686-pc-mingw32.exe
C:\Users\Alexis\Documents\GitHub\rust\src\libcollections\treemap.rs:864:14: 864:23 error: cannot borrow `cur#0` as mutable more than once at a time
C:\Users\Alexis\Documents\GitHub\rust\src\libcollections\treemap.rs:864 Some(ref mut x) => {
^~~~~~~~~
C:\Users\Alexis\Documents\GitHub\rust\src\libcollections\treemap.rs:864:14: 864:23 note: previous borrow of `cur#0` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `cur#0` until the borrow ends
C:\Users\Alexis\Documents\GitHub\rust\src\libcollections\treemap.rs:864 Some(ref mut x) => {
^~~~~~~~~
C:\Users\Alexis\Documents\GitHub\rust\src\libcollections\treemap.rs:874:2: 874:2 note: previous borrow ends here
C:\Users\Alexis\Documents\GitHub\rust\src\libcollections\treemap.rs
View gist:aab30073fbaea499f72b
fn splay (&mut self, node: &mut Node<T>) {
enum SplayType {NoSplay, Zig, ZigZig, ZigZag};
loop {
let splayType = match node.get_parent() {
None => NoSplay,
Some(parent) => {
match parent.get_parent() {
None => Zig,
Some(_) => {
if parent.is_left() == node.is_left() {
View gist:9627b111878f8be37aa2
[package]
name = "binaryheap"
version = "0.1.0"
authors = [ "a.beingessner@gmail.com" ]
[[bin]]
name = "binaryheap" # the name of the executable to generate
@Gankra
Gankra / gist:06b4c5454bd4f3ef732a
Last active Aug 29, 2015
libcollections traits 0.1
View gist:06b4c5454bd4f3ef732a
pub trait Collection {
fn len(self) -> uint;
fn is_empty(&self) -> bool; //defaulted
}
pub trait Mutable: Collection {
fn clear(&mut self);
}
pub trait Container<T>: Collection {
View gist:84e730a6f9dc8b5d2e15
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `result=""; for arch in i386; do if gcc -arch $arch -c -integrated-as /c/users/alexis/Documents/Github/rust/src/compiler-rt/make/platform/clang_darwin_test_input.c -isysroot /c/users/alexis/Documents/Github/rust/src/compiler-rt/SDKs/darwin -o /dev/null > /dev/null 2> /dev/null; then if c:/program files (x86)/mingw-builds/x32-4.8.1-win32-dwarf-rev5/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe -v 2>&1 | grep "configured to support" | tr ' ' '\n' | grep "^$arch$" >/dev/null 2>/dev/null; then result="$result$arch "; else printf 1>&2 "warning: clang_darwin.mk: dropping arch '$arch' from lib 'eprintf'"; printf 1>&2 " (ld does not support it)\n"; fi; else printf 1>&2 "warning: clang_darwin.mk: dropping arch '$arch' from lib 'eprintf'"; printf 1>&2 " (clang does not support it)\n"; fi; done; echo $result'
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `result="";
@Gankra
Gankra / traits.rs
Last active Aug 29, 2015
libcollections traits 0.2
View traits.rs
/********************************************
****************COMMON **********************
********************************************/
/// Base trait that all collections should inherit from
/// Due to the way the Rust's type system works, a perfectly generic
/// collection of T's can support very few operations. In particular, the
/// ability to store things that *don't* implement Eq, and the
/// distinction between value stores and key-value stores means
You can’t perform that action at this time.