Skip to content

Instantly share code, notes, and snippets.

Avatar
🐦
:parrotwave1::parrotwave2::parrotwave3::parrotwave4::parrotwave5::parrotwave6:

Aaron Dandy aarondandy

🐦
:parrotwave1::parrotwave2::parrotwave3::parrotwave4::parrotwave5::parrotwave6:
View GitHub Profile
View gist:6859164
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());
View gist:6821660
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 Oct 12, 2021
Calculates the north relative clockwise orientation of a line.
View line direction N CW
/*
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