Skip to content

Instantly share code, notes, and snippets.

View aarondandy's full-sized avatar
🐦
:parrotwave1::parrotwave2::parrotwave3::parrotwave4::parrotwave5::parrotwave6:

Aaron Dandy aarondandy

🐦
:parrotwave1::parrotwave2::parrotwave3::parrotwave4::parrotwave5::parrotwave6:
View GitHub Profile
@aarondandy
aarondandy / gist:6859164
Created October 6, 2013 21:10
multiple impls
struct Junk { a: f64 }
impl Mul<Junk,Junk> for Junk {
fn mul(&self, rhs:&Junk) -> Junk {Junk{a: &self.a * rhs.a}}
}
impl Mul<f64,Junk> for Junk {
fn mul(&self, rhs:&f64) -> Junk {Junk{a: &self.a * rhs}}
}
fn main(){
println((Junk{a:2_f64} * Junk{a:3_f64}).a.to_str());
@aarondandy
aarondandy / gist:6821660
Created October 4, 2013 06:12
so much error...
struct Junk<T> { a: T }
impl<T:Mul<T,T>> Mul<T,Junk<T>> for Junk<T> {
fn mul(&self, rhs: &T) -> Junk<T> {
Junk{
a: self.a.mul(rhs)
}
}
}
@aarondandy
aarondandy / line direction N CW
Last active October 12, 2021 18:10
Calculates the north relative clockwise orientation of a line.
/*
The MIT License
Copyright (c) 2010 Aaron Dandy (aaron.dandy@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell