This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use array::with; | |
mod array { | |
use std::marker::PhantomData; | |
use std::ops::{Deref, DerefMut}; | |
#[derive(Clone,Copy)] | |
pub struct InvariantLifetime<'id>( | |
PhantomData<*mut &'id ()>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "syn_pat_compile" | |
version = "0.1.0" | |
authors = ["Stu Black <trurl@freeshell.org>"] | |
[dependencies] | |
syn = "0.10.6" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(drain)] | |
use std::cmp::Ordering; | |
pub fn main() { | |
let mut x_vec = vec![1, 2, 3, 4]; | |
let mut y_vec = vec![3, 4, 5]; | |
// Slightly contrived example: iterate through two sorted sequences in | |
// tandem, merging them into a new sequence. | |
let mut xs = x_vec.drain(0..); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(append)] | |
use std::fmt; | |
use std::result::Result; | |
/// Simple tree data structure that owns its child nodes. | |
#[derive(Eq, PartialEq)] | |
struct Tree<T> { | |
data: T, | |
children: Vec<Tree<T>>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashSet; | |
#[deriving(Eq, Hash)] | |
struct Foo { | |
a: usize, | |
b: &'static str, | |
} | |
pub fn main() { | |
let mut s = HashSet::new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package errordemo | |
import scala.annotation.StaticAnnotation | |
import scala.reflect.macros.whitebox.Context | |
class mymacro extends StaticAnnotation { | |
def macroTransform(annottees: Any*): Any = macro MacroImpl.macroImpl | |
} | |
class MacroImpl(val c: Context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mymacro.test | |
import scala.annotation.StaticAnnotation | |
import scala.language.experimental.macros | |
import scala.reflect.macros.Context | |
trait MyTypeClass[T] { | |
def something(c: Context): c.Tree | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mymacro.test | |
import scala.annotation.StaticAnnotation | |
import scala.language.experimental.macros | |
import scala.reflect.macros.Context | |
trait MyTypeClass[T] { | |
def something: Int | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Item { | |
ITEM1, ITEM2, ITEM3, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sbt compile | |
Loading /usr/share/sbt/bin/sbt-launch-lib.bash | |
[info] Loading project definition from /home/stu/projects/scala-trees/project | |
[info] Set current project to PCFG parsing (in build file:/home/stu/projects/scala-trees/) | |
[info] Updating {file:/home/stu/projects/scala-trees/}scala-trees... | |
[info] Resolving org.scala-lang#scala-library;2.10.3 ... | |
[info] Resolving org.scalatest#scalatest_2.10;2.0 ... | |
[info] Resolving org.scala-lang#scala-reflect;2.10.0 ... | |
[info] Resolving org.scala-lang#scala-compiler;2.10.3 ... | |
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ... |
NewerOlder