Skip to content

Instantly share code, notes, and snippets.

@shadowmint
shadowmint / errors
Last active August 29, 2015 14:05
boo
Fresh array v0.1.4 (https://github.com/shadowmint/rust-array?ref=0.1.5#f574f1a3)
Compiling txt v0.1.0 (file:///Users/doug/dev/rust-txt)
src/parser/parser.rs:63:18: 63:35 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
src/parser/parser.rs:63 for token in ast.tokens.iter() {
^~~~~~~~~~~~~~~~~
src/parser/parser.rs:62:3: 83:4 note: consider using an explicit lifetime parameter as shown: fn phase_pattern_match(&'a self, ast: &'a mut Ast<'a, T>)
src/parser/parser.rs:62 fn phase_pattern_match(&'a self, ast:&mut Ast<'a, T>) {
src/parser/parser.rs:63 for token in ast.tokens.iter() {
src/parser/parser.rs:64 let mut matched = false;
src/parser/parser.rs:65 self.patterns.iter().all(|pattern| -> bool {
@shadowmint
shadowmint / magic.scss
Last active August 29, 2015 14:05
Sass magic
@function str-split($value) {
$rtn: ();
$tmp: $value;
$busy: true;
@while $busy {
$index: str-index($tmp, ' ');
@if $index {
$bit: str-slice($tmp, 0, $index - 1);
$rtn: append($rtn, $bit);
$tmp: str-slice($tmp, $index + 1);
/// Invoke this when the last 'length' nodes are all the same repeat type.
/// If the node before the first one is *also* that type, merge into that
/// node; otherwise perform the default repeat action.
fn reduce_repeat<'a>(&self, stack:&mut Vec<AstNode<'a, T>>, id:T, length:uint) {
let mut merged:Vec<AstNode<'a, T>> = Vec::new();
for i in range(0, length) {
merged.push(stack.pop().unwrap());
}
trace!("Trying to peform a repeat reducation...!")
@shadowmint
shadowmint / SassMeister-input.scss
Created August 27, 2014 00:36
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0)
// ----
@function str-split($value) {
$rtn: ();
$tmp: $value;
$busy: true;
@while $busy {
impl<'a> Iterator<Path> for GlobIter<'a> {
fn next(&mut self) -> Option<Path> {
match self.walker {
Some(ref mut walker) => {
let mut ended = false;
while !ended {
match walker.next() {
Some(v) => {
match v.lstat() {
Ok(stats) => {
@shadowmint
shadowmint / errors.
Created August 30, 2014 07:37
errors
dougs-Mac-mini:rust-array doug$ cargo test
Compiling array v0.1.6 (file:///Users/doug/dev/rust-array)
src/array.rs:140:64: 140:72 error: explicit lifetime bound required
src/array.rs:140 impl<'a, T: PartialEq + Clone + Default> Index<uint,T> for &'a Array<T> {
^~~~~~~~
src/array.rs:147:71: 147:79 error: explicit lifetime bound required
src/array.rs:147 impl<'a, T: PartialEq + Clone + Default> IndexMut<uint,T> for &'a mut Array<T> {
^~~~~~~~
src/view.rs:13:14: 13:22 error: explicit lifetime bound required
src/view.rs:13 parent:&'a Array<T>,
#pragma strict
import System.Collections.Generic;
/** Create a new instance */
public static function factory(dx:int, dy:int, size:float):TacticsMap {
var rtn = new TacticsMap();
rtn.tiles = new int[dx * dy];
rtn.heights = new int[dx * dy];
rtn.dx = dx;
use std::io::{File,IoResult,UserRWX};
use std::os;
use std::io::TempDir;
use std::io::fs;
pub struct FileUtils {
pub path:Option<TempDir>
}
impl FileUtils {
use pattern::Pattern;
use pattern::Glob;
mod pattern;
fn main() {
let foo = Glob;
}
diff --git a/src/lib/codegen.rs b/src/lib/codegen.rs
index 3166f63..f8121a8 100644
--- a/src/lib/codegen.rs
+++ b/src/lib/codegen.rs
@@ -800,7 +800,7 @@ impl<'a> IndentWriter<'a> {
#[allow(dead_code)]
fn fail<S : Str>(&self, reason: S) {
- self.write_line(format!("fail!({:?});", reason));
+ self.write_line(format!("fail!({});", reason.as_slice()));