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
| test : List String -> String | |
| test xs = ?something |
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
| 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: |
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
| /// 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 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
| // 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 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
| 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 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
| enum Void {} | |
| enum Foo<T, U> { | |
| A(int) for T = (), U = () | |
| } |
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
| 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 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
| //! Chain macro in Rust | |
| //! | |
| //! A typical usage is to avoid nested match expressions. | |
| //! | |
| //! Supports: | |
| //! - Pattern matching | |
| //! - Or expressions (A | B => ...) | |
| //! - Guarded statements (x if <cond> => ...) | |
| //! - Implicit else (requires all arms to return same type) |
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
| /** | |
| * 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 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
| #!/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() { |