Skip to content

Instantly share code, notes, and snippets.

View torkleyy's full-sized avatar

Thomas Schaller torkleyy

  • Wolf GmbH
  • Bavaria, Germany
View GitHub Profile
@torkleyy
torkleyy / trait_object.rs
Last active March 26, 2018 06:16 — forked from rust-play/playground.rs
How to cast a generic `T: O` to a generic trait object `O` in Rust
trait Foo {
fn method(&self);
}
trait Cast<T> {
fn cast(t: &T) -> &Self;
fn cast_mut(t: &mut T) -> &mut Self;
}
@torkleyy
torkleyy / gist:c0b90863f61198e3563a39e860208c6b
Last active March 25, 2018 20:35
Specs System Decorator
use specs::System;
use specs::SystemData;
pub struct InstrumentedSystem<T> {
pub system: T,
}
impl<T> InstrumentedSystem<T> {
pub fn new(system: T) -> Self {
InstrumentedSystem {
@torkleyy
torkleyy / playground.rs
Created December 8, 2017 13:53 — forked from anonymous/playground.rs
Rust code shared from the playground
const INPUT: &str = "6169763796227664136644229724736711773811471986347364813198\
2449728688116728695866572989524473392982963976411147683588415878214189996163533\
5845471757941581181487242988327988983333997865614591526441446699598873414819683\
1917298735798978579136673284993278834377211217661472385847495991971385539887695\
6427631354172668133549845585632211935573662181331613137869866693259374322169811\
6836353253215972428893581471233581177749146537873713685747843767216521817923716\
3528837672978496752682491519252674493518798957134774622211362557796347614192318\
7534658445615596987614385911513939292257263723518774888174635963254624769684533\
5314437457293443419737464693268381862484484835874775632858674999564462187752323\
7438343392183599313646338362886111557314285435894329114876629965363319558213593\