Skip to content

Instantly share code, notes, and snippets.

#![feature(ptr_internals, alloc)]
use std::ops::{Deref, DerefMut};
use std::ptr::{self, Unique};
use std::{alloc, marker::PhantomData, mem};
struct RawVec<T> {
ptr: Unique<T>,
cap: usize,
ChillingHsu /
Last active Nov 24, 2018
quick sort 2 way & 3 way
use std::cmp::Ordering;
fn qsort3way<T: Ord + Copy>(sli: &mut [T], lo: usize, hi: usize) {
if hi <= lo {return;}
let mut lt = lo;
let mut i = lt + 1;
let mut gt = hi;
let v = sli[lo];
while i <= gt {
match sli[i].cmp(&v) {
ChillingHsu /
Last active Dec 29, 2021
Run as Client/Server, for someone who likes GUI emacs and emacsclient to speed up start-up time.
BG_RED=`tput setaf 1`
BG_GREEN=`tput setaf 2`
BOLD=`tput bold`
RESET=`tput sgr0`
DEFAULT_EVAL='(switch-to-buffer "*scratch*")'