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(test)] | |
extern crate test; | |
trait Max2 { | |
type Item; | |
fn max_by_key2<B: Ord, F>(self, f: F) -> Option<Self::Item> where | |
Self: Sized, | |
F: FnMut(&Self::Item) -> B; | |
} |
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
pub fn render(library: &Library, state: &mut State, mut stack: Vec<String>, expression: &mut Expression) -> Expression { | |
match expression { | |
// We have a symbolic expression that we have to evaluate | |
Expression::Symbolic(ref mut args) | Expression::NotDone(ref mut args) => { | |
// If we have a valid expression (unnamed ones are not allowed) | |
if args.len() > 0 { | |
// Get the first nested expression | |
return match args.remove(0) { | |
// If the first expression is a plain literal | |
Expression::Literal(Literal::S(name)) => { |
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
extern crate ssh2; | |
use std::net::TcpStream; | |
use ssh2::Session; | |
fn create_session() -> (TcpStream, Session) { | |
let tcp = TcpStream::connect("test:22").expect("Cannot connect"); | |
let mut sess = Session::new().expect("cannot start session"); | |
sess.handshake(&tcp).expect("handshake failed"); |
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
inside: TreeIterator { current: Tree { nodes: [None, None] }, depth: 0 } | |
Got out Tree { nodes: [None, None] } | |
After first inc(0) Tree { nodes: [None, None] } | |
After second inc(1) Tree { nodes: [Some(Tree { nodes: [None, None] }), None] } | |
next tree: Some(Tree { nodes: [None, None] }) | |
inside: TreeIterator { current: Tree { nodes: [Some(Tree { nodes: [None, None] }), None] }, depth: 1 } | |
Got out Tree { nodes: [Some(Tree { nodes: [None, None] }), Some(Tree { nodes: [None, None] })] } | |
After first inc(1) Tree { nodes: [Some(Tree { nodes: [None, None] }), Some(Tree { nodes: [None, None] })] } | |
next tree: Some(Tree { nodes: [Some(Tree { nodes: [None, None] }), Some(Tree { nodes: [None, None] })] }) | |
inside: TreeIterator { current: Tree { nodes: [Some(Tree { nodes: [None, None] }), Some(Tree { nodes: [None, None] })] }, depth: 1 } |
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(const_fn)] | |
// rust self-tracing benchmark using DebugCtl.BTF | |
extern crate winapi; | |
extern crate kernel32; | |
extern crate libc; | |
use std::time::Instant; |
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(libc)] | |
#![feature(test)] | |
extern crate libc; | |
extern crate test; | |
extern crate seahash; | |
use std::slice; | |
use std::ffi::CStr; | |
use std::panic; | |
use std::str; |
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
bench: libauthz.so | |
python2 main.py | |
libauthz.so: rusty_authz.rs Makefile | |
rustc -C opt-level=3 -C lto rusty_authz.rs --crate-type cdylib -o libauthz.so | |
.PHONY: bench |
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
impl<T: Transport> BufferedTransport<T> { | |
fn get_bytes(&mut self) -> io::Result<&[u8]> { | |
if self.rpos == self.rbuf.len() { | |
self.rpos = 0; | |
self.rcap = try!(self.underlying.read(&mut self.rbuf)); | |
} | |
Ok(&self.rbuf[self.rpos..self.rcap]) | |
} |
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::io::stdin; | |
use std::io::Read; | |
use std::rc::Rc; | |
use std::cell::RefCell; | |
use std::cmp::max; | |
#[derive(Debug, Copy, Clone)] | |
struct Position(u16, u16); | |
impl Position { | |
fn adjacent(&self, other: &Position) -> bool { | |
max((self.0 as i16 - other.0 as i16).abs(), (self.1 as i16 - other.1 as i16).abs()) <= 1 |
NewerOlder