Skip to content

Instantly share code, notes, and snippets.

View pzol's full-sized avatar

Piotr Zolnierek pzol

View GitHub Profile
trait Locale {
fn to_upper(s: &str) {}
}
struct Indifferent;
impl Locale for Indifferent {}
static mut current_locale : &'static Locale = &'static Indifferent as &'static Locale;
trait Locale {
fn to_upper(s: &str) {}
}
struct Indifferent;
impl Locale for Indifferent {}
#[test]
fn test_indifferent(){
let l: &Locale = &Indifferent;
#[feature(macro_rules)];
struct Grapheme<'r> {
codepoint: &'r [CodePoint]
}
struct Graphemes<'r> {
chars: std::str::Chars<'r>
}
mod unicode {
struct Cluster<'a> {
chars: &'a [char]
}
pub fn unpack<'a>(s: &str) -> &'a [Cluster<'a>] {
let mut clusters = ~[];
// let cluster = Cluster { chars: &'static [] };
// clusters.push(cluster);
clusters.as_slice()
struct UpperChars<'a> {
chars: std::str::Chars<'a>
}
struct LowerChars<'a> {
chars: std::str::Chars<'a>
}
fn lower_chars<'a>(s: &'a str) -> LowerChars<'a> {
LowerChars { chars: s.chars() }
struct LowerChars<'a> {
chars: std::str::Chars<'a>
}
fn lower<'a>(s: &'a str) -> LowerChars<'a> {
LowerChars { chars: s.chars() }
}
impl<'a> Iterator<char> for LowerChars<'a> {
fn next(&mut self) -> Option<char> {
/* soon to be auto-generated */
use std::cmp::{Equal, Less, Greater};
use std::vec::ImmutableVector;
use std::option::None;
static LETTER_UPPERCASE : &'static [(char, char)] = &[
('\x41', '\x5a')
];
@pzol
pzol / ffi.rs
Last active August 29, 2015 13:56
#[allow(ctypes, dead_code)];
#[feature(globs)];
use std::str;
use std::libc::{ c_char };
pub type UChar = u16;
pub type UChar32 = i32;
@pzol
pzol / pos.rs
Created February 16, 2014 19:11
fn pos(pos: int, len: uint) -> uint {
let ilen = len as int;
let result = match pos {
p if p < 0 && ilen + p < 0 => 0,
p if p < 0 => ilen + p,
p => p
} as uint;
result
}
#[allow(ctypes, dead_code)];
#[feature(globs)];
use std::vec;
pub type UBool = u8;
pub type UProperty = int;
pub type UChar = u16;
pub type UChar32 = i32;