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 test() { | |
let x : [u8, ..256]; | |
let val = get_val(); | |
if val == 0 { | |
x = [1, ..256]; | |
return x; | |
} else if val == 3 { | |
x = [3, ..256]; | |
return x; |
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
// Feel free to copy and modify this code if it's useful to you. | |
macro_rules! if_cfg { | |
($(#[cfg($cfg:meta)] $it:item)+ fallback: $els:item) => ( | |
$(#[cfg($cfg)] $it)+ | |
#[cfg(not(any($($cfg),*)))] $els | |
) | |
} | |
if_cfg { | |
#[cfg(target_arch="x86")] |
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
test int::test::bench_add_1000_10 ... bench: 268 ns/iter (+/- 4) | |
test int::test::bench_add_1000_1000 ... bench: 1666 ns/iter (+/- 131) | |
test int::test::bench_add_100_100 ... bench: 205 ns/iter (+/- 33) | |
test int::test::bench_add_10_10 ... bench: 51 ns/iter (+/- 41) | |
test int::test::bench_add_1_1 ... bench: 39 ns/iter (+/- 33) | |
test int::test::bench_div_1000_1000 ... bench: 2359 ns/iter (+/- 4169) | |
test int::test::bench_div_10_10 ... bench: 58 ns/iter (+/- 135) | |
test int::test::bench_div_1_1 ... bench: 62 ns/iter (+/- 26) | |
test int::test::bench_div_20_2 ... bench: 226 ns/iter (+/- 30) | |
test int::test::bench_div_250_250 ... bench: 117 ns/iter (+/- 1094) |
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
extern crate smallvec; | |
use std::collections::VecDeque; | |
use std::io::Read; | |
use smallvec::SmallVec; | |
pub type LexResult<T> = std::result::Result<T, Error>; | |
/** |
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
macro_rules! handle_element( | |
($tag:expr, $string:expr, $ctor:ident, [], $type_id:expr) => ( () ); | |
($tag:expr, $string:expr, $ctor:ident, [ $($field:ident),* ], $type_id:expr, ) => ( | |
if eq_slice($tag, $string) { | |
let _element = ~$ctor { | |
parent: Element::new($type_id, ($tag).to_str()), | |
$( | |
$field: None | |
),* | |
}; |
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
struct OneShot<S, T> (S, ~fn (S) -> T); | |
impl<S, T> OneShot<S,T> { | |
fn run(~self) -> T { | |
let (s, f) = match self { | |
~OneShot(s, f) => (s,f) | |
}; | |
f(s) | |
} |
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
struct my_c_struct { | |
f1:int, | |
f2:int | |
} | |
type MyStruct = my_c_struct; | |
impl Drop for MyStruct { | |
fn finalize(&self) { | |
unsafe { |
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
use core::unstable::intrinsics::{init, atomic_cxchg, atomic_xchg}; | |
/** | |
* Implementation of the Chase & Lev Work-Stealing deque. | |
* | |
* This requires using owned pointers to data in order to ensure that the data is freed at the | |
* right time and place, it also allows for some of the operations to be atomic, which would not be | |
* possible if the data was bigger than a pointer. | |
* | |
* One key difference from Chase & Lev is that this implementation zeroes out the location in |
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 f() -> ! { f() } | |
define internal fastcc void @f() #0 { | |
static_allocas: | |
tail call fastcc void @f() | |
unreachable | |
} |
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
#0 0x00007ffff7886ea4 in task::spawn::spawn_raw_oldsched::make_child_wrapper::anon::expr_fn_18909 () from /home/james/projects/rust/compiler/x86_64-unknown-linux-gnu/stage1/bin/../lib/libstd-6c65cf4b443341b1-0.7-pre.so | |
#1 0x00007ffff790c36c in __morestack () from /home/james/projects/rust/compiler/x86_64-unknown-linux-gnu/stage1/bin/../lib/libstd-6c65cf4b443341b1-0.7-pre.so | |
#2 0x00007ffff7fc4315 in task_start_wrapper (a=0x7fffec207c80) at /home/james/projects/rust/compiler/src/rt/rust_task.cpp:166 | |
#3 0x0000000000000000 in ?? () |
OlderNewer