Skip to content

Instantly share code, notes, and snippets.

View U007D's full-sized avatar

Brad Gibson U007D

View GitHub Profile
@U007D
U007D / main.rs
Created March 26, 2022 13:51 — forked from jix/main.rs
Lifetime GAT emulation on stable rust
// This is a technique to emulate lifetime GATs (generic associated types) on stable rust starting
// with rustc 1.33.
//
// I haven't seen this exact technique before, but I would be surprised if no one else came up with
// it. I think this avoids most downsides of other lifetime GAT workarounds I've seen.
//
// In particular, neither implementing nor using traits with emulated lifetime GATs requires adding
// any helper items. Only defining the trait requires a single helper trait (+ a single helper impl
// for the 2nd variant) per GAT. This also makes the technique viable without any boilerplate
// reducing macros.
@U007D
U007D / openocd-unmatched.cfg
Created July 17, 2021 01:38 — forked from a4lg/openocd-unmatched.cfg
HiFive Unmatched + OpenOCD configuration (S7+U7 cores; no flash configured)
adapter speed 10000
adapter driver ftdi
ftdi_device_desc "Dual RS232-HS"
ftdi_vid_pid 0x0403 0x6010
ftdi_layout_init 0x0008 0x001b
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020
set _CHIPNAME riscv
transport select jtag
@U007D
U007D / playground.rs
Created February 14, 2018 14:56 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::fmt;
#[derive(Debug, Clone, Copy)]
pub enum CardinalPoint {
North = 0x2191, // ↑
NorthEast = 0x2197, // ↗
East = 0x2192, // →
SouthEast = 0x2198, // ↘
South = 0x2193, // ↓
SouthWest = 0x2199, // ↙
@U007D
U007D / playground.rs
Created February 14, 2018 14:56 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::fmt;
#[derive(Debug, Clone, Copy)]
pub enum CardinalPoint {
North = 0x2191, // ↑
NorthEast = 0x2197, // ↗
East = 0x2192, // →
SouthEast = 0x2198, // ↘
South = 0x2193, // ↓
SouthWest = 0x2199, // ↙
@U007D
U007D / hkt_lens.rs
Created November 29, 2017 14:50
Simulated HKT in Rust via type lenses
// Project the generics out into an HList
pub trait Unapply {
type Out: ty::Tm<ty::List<ty::Star>> + HList;
}
// Reapply the type to a fresh set of generics
pub trait Reapply<Args: ty::Tm<ty::List<ty::Star>>>
: Unapply
{
type Out: Unapply<Out = Args>;
@U007D
U007D / workspace.sh
Created February 26, 2017 16:54 — forked from dixson3/workspace.sh
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/Documents/workspace.dmg.sparseimage
create() {
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 60g -volname workspace ${WORKSPACE}
}
detach() {
@U007D
U007D / workspace.sh
Created February 26, 2017 16:54 — forked from dixson3/workspace.sh
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/Documents/workspace.dmg.sparseimage
create() {
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 60g -volname workspace ${WORKSPACE}
}
detach() {