Skip to content

Instantly share code, notes, and snippets.

@glfmn
glfmn / .pre-commit.sh
Last active January 23, 2024 06:46
pre-commit Test Automation Script
#!/usr/bin/env sh
# pre-commit.sh
# Colors
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
BOLD='\033[1m'
@Geal
Geal / gist:540ddd745045e7335c0d
Created January 14, 2015 12:47
create a closure depending on a parameter
fn prod<'a,'b>(a:uint) -> Box<FnMut(&'b[u8]) -> &'b[u8] +'a> {
box move |&: input: &'b[u8]| -> &'b[u8] {
input.slice_from(a)
}
}
fn main() {
let mut a = prod(2);
println!("a1: {}", a("abcdefgh".as_bytes()));
// -> a1: [99, 100, 101, 102, 103, 104]