This file contains 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
rustc 0.10-pre (0a5138c 2014-03-04 13:16:41 -0800) | |
/// A struct with borrowed pointer to a closure. | |
/// This is to be able to reuse the closure then struct runs out of scope. | |
pub struct Test<'a> { | |
f: &'a 'a || | |
} | |
impl<'a> Test<'a> { |
This file contains 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
rustc 0.10-pre (0a5138c 2014-03-04 13:16:41 -0800) | |
pub trait Expr<'a, T> { | |
fn then(&'a self, f: &'a 'a ||) -> T; | |
} | |
impl<'a> Expr<'a, ()> for () { | |
fn then(&'a self, f: &'a 'a ||) -> () { | |
(*f)(); |
This file contains 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
#!/bin/sh | |
while true; do | |
echo -n " > " | |
read line | |
TMP=`mktemp` | |
rustc - -o $TMP <<EOF | |
#[feature(globs, macro_rules, struct_variant)]; | |
// extern mod extra; | |
fn main() { |
This file contains 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
/** | |
* cairo_show_text: | |
* @cr: a cairo context | |
* @utf8: a NUL-terminated string of text encoded in UTF-8, or %NULL | |
* | |
* A drawing operator that generates the shape from a string of UTF-8 | |
* characters, rendered according to the current font_face, font_size | |
* (font_matrix), and font_options. | |
* |
This file contains 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
let x = Some(1); | |
let y = Some(2); | |
let z = monad!( | |
None { | |
_ => x, | |
Some(x) => y, | |
Some(y) => Some(x+y) | |
} | |
); | |
assert_eq!(z, Some(3)); |
This file contains 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
enum Void {} | |
enum Foo<T, U> { | |
A(int) for T = (), U = () | |
} |
This file contains 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
fn insert_text(text: &mut HashMap<&'static str, &'static str>) { | |
let text: Vec<&'static str> = vec!(include!("text.rs")); | |
for chunk in text.as_slice().chunks(2) { | |
let id: &'static str = *chunk.get(0).unwrap(); | |
let txt: &'static str = *chunk.get(1).unwrap(); | |
text.insert(id, txt); | |
} | |
} | |
This file contains 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
// rustc 0.10-pre-nightly (7bda3df 2014-04-02 17:51:48 -0700) | |
// host: x86_64-apple-darwin | |
// | |
// Compile with | |
// RUST_BACKTRACE=1 rustc lib.rs --crate-type=rlib | |
#![allow(unreachable_code)] | |
pub fn foo() { | |
fail!("hello"); |
This file contains 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
/// Returns true if T is int, otherwise false. | |
fn is_int<T: Num>(num: T) -> bool { | |
match <T> { | |
int => true, | |
_ => false, | |
} | |
} | |
/// Returns true if T impls Clone. | |
fn is_clone(val: T) -> bool { |
This file contains 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
compute : Integer -> Integer | |
compute x = if (x `mod` 2) == 0 then x `div` 2 else 3 * x + 1 | |
traverse : Integer -> List Integer | |
traverse 1 = [1] | |
traverse x = traverse (compute x) :: x | |
ERROR: | |
collatz.idr:7:35: |