file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
orgs.rs
use clap::{App, Arg, ArgMatches, SubCommand}; use config; use git_hub::{GitHubResponse, orgs}; use serde_json; use serde_json::Error; pub fn SUBCOMMAND<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("orgs") .about("List, Get, Edit your GitHub Organizations") .version(version!()) ...
#[test] fn test_build_output_unauthorized() -> () { let response = GitHubResponse { status: StatusCode::Unauthorized, headers: Headers::new(), body: None }; assert_eq!(build_output(&response, false), UNAUTHORIZED); ...
{ let response = GitHubResponse { status: StatusCode::Forbidden, headers: Headers::new(), body: None }; assert_eq!(build_output(&response, false), FORBIDDEN); }
identifier_body
main.rs
use binaryninja::architecture::Architecture; use binaryninja::binaryview::{BinaryViewBase, BinaryViewExt}; fn
() { println!("Loading plugins..."); // This loads all the core architecture, platform, etc plugins binaryninja::headless::init(); println!("Loading binary..."); let bv = binaryninja::open_view("/bin/cat").expect("Couldn't open `/bin/cat`"); println!("Filename: `{}`", bv.metadata().filename()); ...
main
identifier_name
main.rs
use binaryninja::architecture::Architecture; use binaryninja::binaryview::{BinaryViewBase, BinaryViewExt}; fn main() { println!("Loading plugins..."); // This loads all the core architecture, platform, etc plugins binaryninja::headless::init(); println!("Loading binary..."); let bv = binaryninja::open...
}
} // Important! You need to call shutdown or your script will hang forever binaryninja::headless::shutdown();
random_line_split
main.rs
use binaryninja::architecture::Architecture; use binaryninja::binaryview::{BinaryViewBase, BinaryViewExt}; fn main()
.get_data(), addr, ) { Some((_, tokens)) => { tokens .iter() .for_each(|token| print!("{}", token.text().to_str().unwrap())); println!("") ...
{ println!("Loading plugins..."); // This loads all the core architecture, platform, etc plugins binaryninja::headless::init(); println!("Loading binary..."); let bv = binaryninja::open_view("/bin/cat").expect("Couldn't open `/bin/cat`"); println!("Filename: `{}`", bv.metadata().filename()); ...
identifier_body
crh.rs
//! Port configuration register high use rt; /// Reset value pub const DEFAULT: Register = Register(0x4444_4444); /// Register #[derive(Clone, Copy)] #[repr(C)] pub struct Register(u32); impl Register { /// Sets `pin` configuration pub fn cnf(&mut self, pin: u32, state: u32) -> &mut Self
/// Sets `pin` mode pub fn mode(&mut self, pin: u32, state: u32) -> &mut Self { match (state, pin) { (0b00...0b11, 8...15) => { const MASK: u32 = 0b11; let offset = 4 * (pin - 8); self.0 &=!(MASK << offset); self.0 |= state ...
{ match (state, pin) { (0b00...0b11, 8...15) => { const MASK: u32 = 0b11; let offset = 4 * (pin - 8) + 2; self.0 &= !(MASK << offset); self.0 |= state << offset; } _ => rt::abort(), } self ...
identifier_body
crh.rs
//! Port configuration register high use rt; /// Reset value pub const DEFAULT: Register = Register(0x4444_4444); /// Register #[derive(Clone, Copy)] #[repr(C)] pub struct Register(u32); impl Register { /// Sets `pin` configuration pub fn cnf(&mut self, pin: u32, state: u32) -> &mut Self { match (st...
/// Sets `pin` mode pub fn mode(&mut self, pin: u32, state: u32) -> &mut Self { match (state, pin) { (0b00...0b11, 8...15) => { const MASK: u32 = 0b11; let offset = 4 * (pin - 8); self.0 &=!(MASK << offset); self.0 |= state <<...
random_line_split
crh.rs
//! Port configuration register high use rt; /// Reset value pub const DEFAULT: Register = Register(0x4444_4444); /// Register #[derive(Clone, Copy)] #[repr(C)] pub struct
(u32); impl Register { /// Sets `pin` configuration pub fn cnf(&mut self, pin: u32, state: u32) -> &mut Self { match (state, pin) { (0b00...0b11, 8...15) => { const MASK: u32 = 0b11; let offset = 4 * (pin - 8) + 2; self.0 &=!(MASK << offset)...
Register
identifier_name
rpc.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use app_units::Au; use euclid::default::Rect; use script_traits::UntrustedNodeAddress; use servo_arc::Arc; use style::properties::ComputedValues; use webrender_api::ExternalScrollId; /// Synchronous messages that script can send to layout. /// /// In general, you should use messages to talk to Layout. Use the RPC inte...
random_line_split
rpc.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use app_units::Au; use euclid::default::Rect; use script_traits::UntrustedNodeAddress; use servo_arc::Arc; use st...
{ pub node_address: Option<UntrustedNodeAddress>, pub rect: Rect<Au>, } impl OffsetParentResponse { pub fn empty() -> OffsetParentResponse { OffsetParentResponse { node_address: None, rect: Rect::zero(), } } } #[derive(Clone)] pub struct StyleResponse(pub Optio...
OffsetParentResponse
identifier_name
console.rs
use crate::cache; use calx::split_line; use euclid::default::{Point2D, Rect}; use std::io; use std::io::prelude::*; use std::mem; use std::str; use std::sync::Arc; use vitral::{color, Align, Canvas, FontData, Rgba}; struct Message { expire_time_s: f64, text: String, } impl Message { fn new(text: String, t...
.collect::<Vec<String>>(); for line in fragments.iter().rev() { canvas.draw_text(&*self.font, Point2D::new(0, y), Align::Left, color, line); y -= h; lines_left -= 1; } if lines_left <= 0 { break; ...
|c| self.font.char_width(c).unwrap_or(0), screen_area.size.width, ) .map(|x| x.to_string())
random_line_split
console.rs
use crate::cache; use calx::split_line; use euclid::default::{Point2D, Rect}; use std::io; use std::io::prelude::*; use std::mem; use std::str; use std::sync::Arc; use vitral::{color, Align, Canvas, FontData, Rgba}; struct Message { expire_time_s: f64, text: String, } impl Message { fn new(text: String, t...
let message = Message::new(message_text, now); self.done_reading_s = message.expire_time_s; self.lines.push(message); } pub fn get_input(&mut self) -> String { let mut ret = String::new(); mem::swap(&mut ret, &mut self.input_buffer); ret } } impl Write for...
{ self.done_reading_s = now; }
conditional_block
console.rs
use crate::cache; use calx::split_line; use euclid::default::{Point2D, Rect}; use std::io; use std::io::prelude::*; use std::mem; use std::str; use std::sync::Arc; use vitral::{color, Align, Canvas, FontData, Rgba}; struct Message { expire_time_s: f64, text: String, } impl Message { fn new(text: String, t...
(&mut self) { let mut message_text = String::new(); mem::swap(&mut message_text, &mut self.output_buffer); let now = calx::precise_time_s(); if now > self.done_reading_s { self.done_reading_s = now; } let message = Message::new(message_text, now); se...
end_message
identifier_name
console.rs
use crate::cache; use calx::split_line; use euclid::default::{Point2D, Rect}; use std::io; use std::io::prelude::*; use std::mem; use std::str; use std::sync::Arc; use vitral::{color, Align, Canvas, FontData, Rgba}; struct Message { expire_time_s: f64, text: String, } impl Message { fn new(text: String, t...
fn flush(&mut self) -> io::Result<()> { Ok(()) } }
{ let s = str::from_utf8(buf).expect("Wrote non-UTF-8 to Console"); let mut lines = s.split('\n'); if let Some(line) = lines.next() { self.output_buffer.push_str(line); } for line in lines { self.end_message(); self.output_buffer.push_str(line...
identifier_body
main.rs
// Copyright (c) 2013 John Grosen // Licensed under the terms described in the LICENSE file in the root of this repository #[allow(ctypes)]; #[no_std]; #[no_core]; use vga; use term; use util; #[no_mangle] pub fn memset()
fn wait() { do util::range(0, 1<<28) |_| { unsafe { asm!("nop"); } } } #[no_mangle] pub fn kernel_main() { let mut term = &vga::VgaTerm::new(vga::White, vga::LightRed, true) as &term::Terminal; term.put_string("1\n2\n3\n4\n5\n"); term.put_string("6\n7\n8\n9\n10\n"); ...
{}
identifier_body
main.rs
// Copyright (c) 2013 John Grosen // Licensed under the terms described in the LICENSE file in the root of this repository #[allow(ctypes)]; #[no_std]; #[no_core]; use vga; use term; use util; #[no_mangle] pub fn
() {} fn wait() { do util::range(0, 1<<28) |_| { unsafe { asm!("nop"); } } } #[no_mangle] pub fn kernel_main() { let mut term = &vga::VgaTerm::new(vga::White, vga::LightRed, true) as &term::Terminal; term.put_string("1\n2\n3\n4\n5\n"); term.put_string("6\n7\n8\n9\n10\n"...
memset
identifier_name
main.rs
// Copyright (c) 2013 John Grosen // Licensed under the terms described in the LICENSE file in the root of this repository #[allow(ctypes)]; #[no_std]; #[no_core]; use vga; use term; use util; #[no_mangle] pub fn memset() {} fn wait() { do util::range(0, 1<<28) |_| { unsafe { asm!("nop"); ...
term.put_string("\n:O :O"); foo.set_displaying(true); wait(); foo.set_displaying(false); term.put_string("\n;D"); term.set_displaying(true); loop {} }
foo.put_string("hi there\n"); term.put_string("gasp"); wait(); term.set_displaying(false);
random_line_split
echo.rs
//! An "hello world" echo server with tokio-core //! //! This server will create a TCP listener, accept connections in a loop, and //! simply write back everything that's read off of each TCP connection. Each //! TCP connection is processed concurrently with all other TCP connections, and //! each connection will have ...
fn main() { // Allow passing an address to listen on as the first argument of this // program, but otherwise we'll just set up our TCP listener on // 127.0.0.1:8080 for connections. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); let addr = addr.parse::<SocketAddr>().unwrap();...
use tokio_io::AsyncRead; use tokio_io::io::copy; use tokio_core::reactor::Core; use kcp::KcpListener;
random_line_split
echo.rs
//! An "hello world" echo server with tokio-core //! //! This server will create a TCP listener, accept connections in a loop, and //! simply write back everything that's read off of each TCP connection. Each //! TCP connection is processed concurrently with all other TCP connections, and //! each connection will have ...
() { // Allow passing an address to listen on as the first argument of this // program, but otherwise we'll just set up our TCP listener on // 127.0.0.1:8080 for connections. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); let addr = addr.parse::<SocketAddr>().unwrap(); /...
main
identifier_name
echo.rs
//! An "hello world" echo server with tokio-core //! //! This server will create a TCP listener, accept connections in a loop, and //! simply write back everything that's read off of each TCP connection. Each //! TCP connection is processed concurrently with all other TCP connections, and //! each connection will have ...
// connections. This TCP listener is bound to the address we determined // above and must be associated with an event loop, so we pass in a handle // to our event loop. After the socket's created we inform that we're ready // to go and start accepting connections. let socket = KcpListener::bind(&add...
{ // Allow passing an address to listen on as the first argument of this // program, but otherwise we'll just set up our TCP listener on // 127.0.0.1:8080 for connections. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); let addr = addr.parse::<SocketAddr>().unwrap(); // F...
identifier_body
context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Data needed by the layout task. #![deny(unsafe_code)] use canvas_traits::CanvasMsg; use css::matching::{Appl...
#[inline(always)] pub fn style_sharing_candidate_cache(&self) -> RefMut<StyleSharingCandidateCache> { self.cached_local_layout_context.style_sharing_candidate_cache.borrow_mut() } pub fn get_or_request_image(&self, url: Url, use_placeholder: UsePlaceholder) -> ...
{ self.cached_local_layout_context.applicable_declarations_cache.borrow_mut() }
identifier_body
context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Data needed by the layout task. #![deny(unsafe_code)] use canvas_traits::CanvasMsg; use css::matching::{Appl...
use script::layout_interface::{Animation, LayoutChan, ReflowGoal}; use std::cell::{RefCell, RefMut}; use std::collections::HashMap; use std::collections::hash_state::DefaultState; use std::rc::Rc; use std::sync::Arc; use std::sync::mpsc::{channel, Sender}; use style::selector_matching::Stylist; use url::Url; use util::...
random_line_split
context.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Data needed by the layout task. #![deny(unsafe_code)] use canvas_traits::CanvasMsg; use css::matching::{Appl...
(&self) -> RefMut<FontContext> { self.cached_local_layout_context.font_context.borrow_mut() } #[inline(always)] pub fn applicable_declarations_cache(&self) -> RefMut<ApplicableDeclarationsCache> { self.cached_local_layout_context.applicable_declarations_cache.borrow_mut() } #[inlin...
font_context
identifier_name
check_unused.rs
// // Unused import checking // // Although this is mostly a lint pass, it lives in here because it depends on // resolve data structures and because it finalises the privacy information for // `use` items. // // Unused trait imports can't be checked until the method resolution. We save // candidates here, and do the a...
} enum UnusedSpanResult { Used, FlatUnused(Span, Span), NestedFullUnused(Vec<Span>, Span), NestedPartialUnused(Vec<Span>, Vec<Span>), } fn calc_unused_spans( unused_import: &UnusedImport<'_>, use_tree: &ast::UseTree, use_tree_id: ast::NodeId, ) -> UnusedSpanResult { // The full span i...
{ // Use the base UseTree's NodeId as the item id // This allows the grouping of all the lints in the same item if !nested { self.base_id = id; self.base_use_tree = Some(use_tree); } if let ast::UseTreeKind::Nested(ref items) = use_tree.kind { ...
identifier_body
check_unused.rs
// // Unused import checking // // Although this is mostly a lint pass, it lives in here because it depends on // resolve data structures and because it finalises the privacy information for // `use` items. // // Unused trait imports can't be checked until the method resolution. We save // candidates here, and do the a...
if let ast::UseTreeKind::Nested(ref items) = use_tree.kind { if items.is_empty() { self.unused_import(self.base_id).add(id); } } else { self.check_import(id); } visit::walk_use_tree(self, use_tree, id); } } enum UnusedSpanResult...
{ self.base_id = id; self.base_use_tree = Some(use_tree); }
conditional_block
check_unused.rs
// // Unused import checking // // Although this is mostly a lint pass, it lives in here because it depends on // resolve data structures and because it finalises the privacy information for // `use` items. // // Unused trait imports can't be checked until the method resolution. We save // candidates here, and do the a...
(&mut self, krate: &ast::Crate) { for import in self.potentially_unused_imports.iter() { match import.kind { _ if import.used.get() || import.vis.get().is_public() || import.span.is_dummy() => { if let Import...
check_unused
identifier_name
check_unused.rs
// // Unused import checking // // Although this is mostly a lint pass, it lives in here because it depends on // resolve data structures and because it finalises the privacy information for // `use` items. // // Unused trait imports can't be checked until the method resolution. We save // candidates here, and do the a...
} } visit::walk_item(self, item); } fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: ast::NodeId, nested: bool) { // Use the base UseTree's NodeId as the item id // This allows the grouping of all the lints in the same item if!nested { ...
// compiler and we don't need to consider them. if let ast::ItemKind::Use(..) = item.kind { if item.vis.kind.is_pub() || item.span.is_dummy() { return;
random_line_split
build.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} fn main() { inner::main(); }
{}
identifier_body
build.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
() {} } fn main() { inner::main(); }
main
identifier_name
build.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity.
// the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Publ...
// Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
random_line_split
transposition_table.rs
use lru_cache::LruCache; use std::hash::Hash; #[derive(Clone)] pub struct TranspositionTable<B, M> where B: Eq + Hash { cache: LruCache<B, (M, u32)>, } impl<B, M> TranspositionTable<B, M> where B: Eq + Hash, M: Clone { pub fn new(capacity: usize) -> TranspositionTable<B, M> { Tr...
} None } pub fn insert(&mut self, board: B, mv: M, depth: u32) { self.cache.insert(board, (mv, depth)); } }
{ return Some(precomputed_move.0.clone()); }
conditional_block
transposition_table.rs
use lru_cache::LruCache; use std::hash::Hash; #[derive(Clone)]
pub struct TranspositionTable<B, M> where B: Eq + Hash { cache: LruCache<B, (M, u32)>, } impl<B, M> TranspositionTable<B, M> where B: Eq + Hash, M: Clone { pub fn new(capacity: usize) -> TranspositionTable<B, M> { TranspositionTable { cache: LruCache::new(capacity), ...
random_line_split
transposition_table.rs
use lru_cache::LruCache; use std::hash::Hash; #[derive(Clone)] pub struct TranspositionTable<B, M> where B: Eq + Hash { cache: LruCache<B, (M, u32)>, } impl<B, M> TranspositionTable<B, M> where B: Eq + Hash, M: Clone { pub fn new(capacity: usize) -> TranspositionTable<B, M> { Tr...
(&mut self, board: B, mv: M, depth: u32) { self.cache.insert(board, (mv, depth)); } }
insert
identifier_name
transposition_table.rs
use lru_cache::LruCache; use std::hash::Hash; #[derive(Clone)] pub struct TranspositionTable<B, M> where B: Eq + Hash { cache: LruCache<B, (M, u32)>, } impl<B, M> TranspositionTable<B, M> where B: Eq + Hash, M: Clone { pub fn new(capacity: usize) -> TranspositionTable<B, M> { Tr...
}
{ self.cache.insert(board, (mv, depth)); }
identifier_body
result.rs
/* * Panopticon - A libre disassembler * Copyright (C) 2016 Panopticon authors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) an...
}
{ Error(Cow::Owned(format!("Serde error: {}", e))) }
identifier_body
result.rs
/* * Panopticon - A libre disassembler * Copyright (C) 2016 Panopticon authors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) an...
(s: String) -> Error { Error(Cow::Owned(s)) } } impl From<&'static str> for Error { fn from(s: &'static str) -> Error { Error(Cow::Borrowed(s)) } } impl From<Cow<'static, str>> for Error { fn from(s: Cow<'static, str>) -> Error { Error(s) } } impl<T> From<PoisonError<T>> f...
from
identifier_name
result.rs
/* * Panopticon - A libre disassembler * Copyright (C) 2016 Panopticon authors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) an...
Error(Cow::Owned(format!("I/O error: {:?}", e))) } } impl From<goblin::error::Error> for Error { fn from(e: goblin::error::Error) -> Error { Error(Cow::Owned(format!("Goblin error: {}", e))) } } impl From<serde_cbor::Error> for Error { fn from(e: serde_cbor::Error) -> Error { E...
impl From<io::Error> for Error { fn from(e: io::Error) -> Error {
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /// A random number generator which shares one instance of an `OsRng`. /// /// A problem with `OsRng`, which is in...
pub struct ServoRng { rng: ReseedingRng<IsaacWordRng, ServoReseeder>, } impl Rng for ServoRng { #[inline] fn next_u32(&mut self) -> u32 { self.rng.next_u32() } #[inline] fn next_u64(&mut self) -> u64 { self.rng.next_u64() } } impl<'a> SeedableRng<&'a [usize]> for ServoRng ...
// An in-memory RNG that only uses the shared file descriptor for seeding and reseeding.
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /// A random number generator which shares one instance of an `OsRng`. /// /// A problem with `OsRng`, which is in...
/// Reseed the RNG. fn reseed(&mut self, seed: &'a [usize]) { debug!("Manually reseeding ServoRng."); self.rng.reseed((ServoReseeder, as_isaac_seed(seed))) } } impl ServoRng { /// Create an auto-reseeding instance of `ServoRng`. /// /// This uses the shared `OsRng`, so avoids c...
{ debug!("Creating new manually-reseeded ServoRng."); let isaac_rng = IsaacWordRng::from_seed(as_isaac_seed(seed)); let reseeding_rng = ReseedingRng::new(isaac_rng, u64::MAX, ServoReseeder); ServoRng { rng: reseeding_rng } }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /// A random number generator which shares one instance of an `OsRng`. /// /// A problem with `OsRng`, which is in...
(&mut self) -> u64 { self.rng.next_u64() } } impl<'a> SeedableRng<&'a [usize]> for ServoRng { /// Create a manually-reseeding instane of `ServoRng`. /// /// Note that this RNG does not reseed itself, so care is needed to reseed the RNG /// is required to be cryptographically sound. fn f...
next_u64
identifier_name
rusti.rs
compiling things let binary = repl.binary.to_managed(); let options = @session::options { crate_type: session::unknown_crate, binary: binary, addl_lib_search_paths: @mut repl.lib_search_paths.map(|p| Path(*p)), jit: true, .. copy *session::basic_options() }; // Be...
() -> Repl {
repl
identifier_name
rusti.rs
* Rusti works by serializing state between lines of input. This means that each * line can be run in a separate task, and the only limiting factor is that all * local bound variables are encodable. * * This is accomplished by feeding in generated input to rustc for execution in * the JIT compiler. Currently input...
/*! * rusti - A REPL using the JIT backend *
random_line_split
rusti.rs
} // Item declarations are hoisted out of main() _ => { repl.program.record_item(name, s); } } } // Local declarations must be specially dealt with,...
{ run_program(" let mut a = 3; a = 5; let mut b = std::hashmap::HashSet::new::<int>(); b.insert(a); assert!(b.contains(&5)) assert!(b.len() == 1) "); }
identifier_body
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::num::{NumCast, One, Zero}; use s...
} #[inline] pub fn max(x: Au, y: Au) -> Au { let Au(xi) = x; let Au(yi) = y; if xi > yi { x } else { y } } } // assumes 72 points per inch, and 96 px per inch pub fn pt_to_px(pt: f64) -> f64 { pt / 72f64 * 96f64 } // assumes 72 points per inch, and 96 px per inch pub fn p...
{ y }
conditional_block
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::num::{NumCast, One, Zero}; use s...
let Au(s) = *self; let Au(o) = *other; s > o } } impl One for Au { #[inline] fn one() -> Au { Au(1) } } impl Zero for Au { #[inline] fn zero() -> Au { Au(0) } #[inline] fn is_zero(&self) -> bool { let Au(s) = *self; s == 0 } } impl Num for Au {}...
} #[inline] fn gt(&self, other: &Au) -> bool {
random_line_split
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::num::{NumCast, One, Zero}; use s...
(&self) -> Au { let Au(s) = *self; Au(-s) } } impl Ord for Au { #[inline] fn lt(&self, other: &Au) -> bool { let Au(s) = *self; let Au(o) = *other; s < o } #[inline] fn le(&self, other: &Au) -> bool { let Au(s) = *self; let Au(o) = *other;...
neg
identifier_name
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use std::num::{NumCast, One, Zero}; use s...
#[inline] pub fn to_snapped(&self) -> Au { let Au(s) = *self; let res = s % 60i32; return if res >= 30i32 { return Au(s - res + 60i32) } else { return Au(s - res) }; } #[inline] pub fn zero_point() -> Point2D<Au> { Point2D(Au(0), Au(0)) }...
{ let Au(s) = *self; ((s as f64) / 60f64).round() as int }
identifier_body
random_tuples_from_single.rs
use core::hash::Hash; use itertools::Itertools; use malachite_base::num::random::random_primitive_ints; use malachite_base::random::EXAMPLE_SEED; use malachite_base::tuples::random::{random_pairs_from_single, random_triples_from_single}; use malachite_base_test_util::stats::common_values_map::common_values_map_debug; u...
((236, 57, 174), 4), ((73, 168, 192), 4), ((89, 197, 244), 4), ((91, 170, 115), 4), ((142, 168, 231), 4), ], ((127, 253, 76), Some((127, 253, 86))), ); random_pairs_from_single_helper( random_pairs_from_single(random_primitive_i...
((165, 174, 73), 4),
random_line_split
random_tuples_from_single.rs
use core::hash::Hash; use itertools::Itertools; use malachite_base::num::random::random_primitive_ints; use malachite_base::random::EXAMPLE_SEED; use malachite_base::tuples::random::{random_pairs_from_single, random_triples_from_single}; use malachite_base_test_util::stats::common_values_map::common_values_map_debug; u...
#[allow(clippy::type_complexity)] fn random_triples_from_single_helper<I: Clone + Iterator>( xs: I, expected_values: &[(I::Item, I::Item, I::Item)], expected_common_values: &[((I::Item, I::Item, I::Item), usize)], expected_median: ( (I::Item, I::Item, I::Item), Option<(I::Item, I::Item...
{ let xs = random_pairs_from_single(xs); let values = xs.clone().take(20).collect_vec(); let common_values = common_values_map_debug(1000000, 10, xs.clone()); let median = median(xs.take(1000000)); assert_eq!( (values.as_slice(), common_values.as_slice(), median), (expected_values, e...
identifier_body
random_tuples_from_single.rs
use core::hash::Hash; use itertools::Itertools; use malachite_base::num::random::random_primitive_ints; use malachite_base::random::EXAMPLE_SEED; use malachite_base::tuples::random::{random_pairs_from_single, random_triples_from_single}; use malachite_base_test_util::stats::common_values_map::common_values_map_debug; u...
<I: Clone + Iterator>( xs: I, expected_values: &[(I::Item, I::Item, I::Item)], expected_common_values: &[((I::Item, I::Item, I::Item), usize)], expected_median: ( (I::Item, I::Item, I::Item), Option<(I::Item, I::Item, I::Item)>, ), ) where I::Item: Clone + Debug + Eq + Hash + Ord...
random_triples_from_single_helper
identifier_name
account.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} fn new(n: NewAccount) -> Result<String, String> { let password: String = match n.password_file { Some(file) => try!(password_from_file(file)), None => try!(password_prompt()), }; let dir = Box::new(try!(keys_dir(n.path))); let secret_store = Box::new(try!(secret_store(dir, Some(n.iterations)))); let acc_pr...
}.map_err(|e| format!("Could not open keys store: {}", e))
random_line_split
account.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
{ /// import mainnet (false) or testnet (true) accounts pub testnet: bool, /// directory to import accounts to pub to: String, } pub fn execute(cmd: AccountCmd) -> Result<String, String> { match cmd { AccountCmd::New(new_cmd) => new(new_cmd), AccountCmd::List(path) => list(path), AccountCmd::Import(import...
ImportFromGethAccounts
identifier_name
metric.rs
// Copyright 2015 The Delix Project Authors. See the AUTHORS file at the top level directory. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-...
// use super::item; pub trait Metric : Sync + Send { fn log(&self, &str, &str, &str); fn counter(&self, &str) -> item::Counter; fn gauge(&self, &str) -> item::Gauge; fn display(&self); }
// distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
random_line_split
error.rs
// Copyright (C) 2015 Élisabeth HENRY. // // This file is part of Caribon. // // Caribon is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 2.1 of the License, or // (at your option) any l...
} impl error::Error for Error { fn description(&self) -> &str { &self.content } } /// Caribon Result, used by some functions pub type Result<T> = result::Result<T, Error>;
f.write_str(&self.content) }
identifier_body
error.rs
// Copyright (C) 2015 Élisabeth HENRY. // // This file is part of Caribon. // // Caribon is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 2.1 of the License, or // (at your option) any l...
s: &str) -> Error { Error { content: s.to_owned() } } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.content) } } impl error::Error for Error { fn description(&self) -> &str { &self.content } } /// Caribon Result, u...
ew(
identifier_name
error.rs
// Copyright (C) 2015 Élisabeth HENRY. // // This file is part of Caribon. // // Caribon is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 2.1 of the License, or // (at your option) any l...
impl error::Error for Error { fn description(&self) -> &str { &self.content } } /// Caribon Result, used by some functions pub type Result<T> = result::Result<T, Error>;
impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.content) } }
random_line_split
testing.rs
#![cfg(test)] use test::Bencher; use types::*; use magics::*; use uci; static mut INITIALIZED: bool = false; pub fn check_init()
#[bench] pub fn move_gen(b: &mut Bencher) { check_init(); let board = Board::start_position(); b.iter(|| board.get_moves()); } // #[bench] // pub fn get_moves(b: &mut Bencher) { // check_init(); // let mut res = 0; // let c = 0; // // b.iter(|| black_box({ // res |= bishop_moves(...
{ unsafe { if !INITIALIZED { uci::init(); INITIALIZED = true; } } }
identifier_body
testing.rs
#![cfg(test)] use test::Bencher; use types::*;
static mut INITIALIZED: bool = false; pub fn check_init() { unsafe { if!INITIALIZED { uci::init(); INITIALIZED = true; } } } #[bench] pub fn move_gen(b: &mut Bencher) { check_init(); let board = Board::start_position(); b.iter(|| board.get_moves()); } // #...
use magics::*; use uci;
random_line_split
testing.rs
#![cfg(test)] use test::Bencher; use types::*; use magics::*; use uci; static mut INITIALIZED: bool = false; pub fn
() { unsafe { if!INITIALIZED { uci::init(); INITIALIZED = true; } } } #[bench] pub fn move_gen(b: &mut Bencher) { check_init(); let board = Board::start_position(); b.iter(|| board.get_moves()); } // #[bench] // pub fn get_moves(b: &mut Bencher) { // ch...
check_init
identifier_name
testing.rs
#![cfg(test)] use test::Bencher; use types::*; use magics::*; use uci; static mut INITIALIZED: bool = false; pub fn check_init() { unsafe { if!INITIALIZED
} } #[bench] pub fn move_gen(b: &mut Bencher) { check_init(); let board = Board::start_position(); b.iter(|| board.get_moves()); } // #[bench] // pub fn get_moves(b: &mut Bencher) { // check_init(); // let mut res = 0; // let c = 0; // // b.iter(|| black_box({ // res |= bisho...
{ uci::init(); INITIALIZED = true; }
conditional_block
small-enums-with-fields.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
Some(-20000), "Some(-20000)"); check!(Either<u8, i8>, 2, Either::Left(132), "Left(132)", Either::Right(-32), "Right(-32)"); check!(Either<u8, i16>, 4, Either::Left(132), "Left(132)", Either::Right(-20000), "Right(-20000)"); }
None, "None", Some(129), "Some(129)"); check!(Option<i16>, 4, None, "None",
random_line_split
small-enums-with-fields.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T, U> { Left(T), Right(U) } macro_rules! check { ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ assert_eq!(size_of::<$t>(), $sz); $({ static S: $t = $e; let v: $t = $e; assert_eq!(S, v); assert_eq!(format!("{:?}", v), $s); assert_eq!(form...
Either
identifier_name
small-enums-with-fields.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ check!(Option<u8>, 2, None, "None", Some(129), "Some(129)"); check!(Option<i16>, 4, None, "None", Some(-20000), "Some(-20000)"); check!(Either<u8, i8>, 2, Either::Left(132), "Left(132)", Either::Right(-32), "Right(-32)"); check!(Either<...
identifier_body
reconnect.rs
#![allow(unused_variables)] #![allow(unused_imports)] extern crate fred; extern crate tokio_core; extern crate tokio_timer_patched as tokio_timer; extern crate futures; #[macro_use] extern crate log; extern crate pretty_env_logger; use fred::RedisClient; use fred::owned::RedisClientOwned; use fred::types::*; use fr...
() { pretty_env_logger::init(); let config = RedisConfig::default(); let policy = ReconnectPolicy::Constant { delay: 1000, attempts: 0, // retry forever max_attempts: 0 }; let timer = Timer::default(); let mut core = Core::new().unwrap(); let handle = core.handle(); println!("Connecti...
main
identifier_name
reconnect.rs
#![allow(unused_variables)] #![allow(unused_imports)] extern crate fred; extern crate tokio_core; extern crate tokio_timer_patched as tokio_timer; extern crate futures; #[macro_use] extern crate log; extern crate pretty_env_logger; use fred::RedisClient; use fred::owned::RedisClientOwned; use fred::types::*; use fr...
}); let joined = connection.join(commands) .join(errors) .join(reconnects); let _ = core.run(joined).unwrap(); }
.map(move |_| client) }) .and_then(|client| { client.quit()
random_line_split
reconnect.rs
#![allow(unused_variables)] #![allow(unused_imports)] extern crate fred; extern crate tokio_core; extern crate tokio_timer_patched as tokio_timer; extern crate futures; #[macro_use] extern crate log; extern crate pretty_env_logger; use fred::RedisClient; use fred::owned::RedisClientOwned; use fred::types::*; use fr...
let errors = client.on_error().for_each(|err| { println!("Client error: {:?}", err); Ok(()) }); let reconnects = client.on_reconnect().for_each(|client| { println!("Client reconnected."); Ok(()) }); let commands = client.on_connect().and_then(|client| { println!("Client connected."); ...
{ pretty_env_logger::init(); let config = RedisConfig::default(); let policy = ReconnectPolicy::Constant { delay: 1000, attempts: 0, // retry forever max_attempts: 0 }; let timer = Timer::default(); let mut core = Core::new().unwrap(); let handle = core.handle(); println!("Connecting ...
identifier_body
destructured-fn-argument.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// debugger:continue // debugger:finish // debugger:print aa // check:$30 = {34, 35} // debugger:continue // debugger:finish // debugger:print bb // check:$31 = {36, 37} // debugger:continue // debugger:finish // debugger:print cc // check:$32 = 38 // debugger:continue // debugger:finish // debugger:print dd // che...
// check:$28 = 32 // debugger:print ue // check:$29 = 33
random_line_split
destructured-fn-argument.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
((&cc, _): (&int, int)) { zzz(); } fn unique_pointer(~dd: ~(int, int, int)) { zzz(); } fn ref_binding(ref ee: (int, int, int)) { zzz(); } fn ref_binding_in_tuple((ref ff, gg): (int, (int, int))) { zzz(); } fn ref_binding_in_struct(Struct { b: ref hh,.. }: Struct) { zzz(); } fn univariant_enum(U...
contained_borrowed_pointer
identifier_name
destructured-fn-argument.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn struct_pattern(Struct { a: k, b: l }: Struct) { zzz(); } fn ignored_tuple_element((m, _, n): (int, u16, i32)) { zzz(); } fn ignored_struct_field(Struct { b: o,.. }: Struct) { zzz(); } fn one_struct_destructured_one_not((Struct { a: p, b: q }, r): (Struct, Struct)) { zzz(); } fn different_order_...
{ zzz(); }
identifier_body
mod.rs
use parse_scene::parse_scene; use std::sync::Arc; use image_types::Color; use cgmath::{Point, Vector}; use cgmath::{Vector3, Point3, Ray3, Ray}; use cgmath::dot; use self::util::random_cos_around; pub use self::illuminator::Illuminator; pub use self::intersectable::Intersectable; pub use self::scene_objects::{SceneObje...
(&self, point: &Point3<f32>, normal: &Vector3<f32>, depth: u32) -> Color { let mut total_light = Color { r: 0.0, g: 0.0, b: 0.0 }; let reduced_samples = self.num_gi_samples >> (depth * 2) as uint; if reduced_samples == 0 { return Color { r: 0.0, g: 0.0, b: 0.0 }; }; for _ in range(0, red...
environment_light
identifier_name
mod.rs
use parse_scene::parse_scene; use std::sync::Arc; use image_types::Color; use cgmath::{Point, Vector}; use cgmath::{Vector3, Point3, Ray3, Ray}; use cgmath::dot; use self::util::random_cos_around; pub use self::illuminator::Illuminator; pub use self::intersectable::Intersectable; pub use self::scene_objects::{SceneObje...
pub objects: Vec<SceneObject>, pub lights: Vec<SceneLight>, pub num_gi_samples: u32, pub num_shadow_samples: u32, pub bounces: u32 } pub struct Material { pub color: Color } pub fn build_scene(filename: &str) -> Scene { let scene = parse_scene(filename); scene } impl Scene { pub f...
random_line_split
mod.rs
use parse_scene::parse_scene; use std::sync::Arc; use image_types::Color; use cgmath::{Point, Vector}; use cgmath::{Vector3, Point3, Ray3, Ray}; use cgmath::dot; use self::util::random_cos_around; pub use self::illuminator::Illuminator; pub use self::intersectable::Intersectable; pub use self::scene_objects::{SceneObje...
fn find_intersection(&self, ray: &Ray3<f32>) -> Option<Intersection> { let mut closest = None; let mut closest_distance = 99999999999.0; for object in self.objects.iter() { let result = object.intersection(ray); match result { Some(distance) => { ...
{ let intersect = self.find_intersection(ray); match intersect { Some(intersection) => { let diff = self.light_diffuse(&intersection.point, &intersection.normal, depth); ...
identifier_body
factory.rs
//! thread model use std::cmp; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc::{Receiver, Sender}; use std::sync::{mpsc, Arc, Mutex}; use std::thread::{self, Builder}; /// Messages the monitor thread sends to worker threads to control their /// activity. #[derive(PartialEq, Eq, Debug)...
, W>( i: usize, had: Arc<AtomicUsize>, belt: Arc<Mutex<Vec<I>>>, container: Sender<Option<I>>, manager: Sender<WorkerMessage>, fun: Arc<W>, kill_switch: Arc<AtomicBool>, workers: Arc<Mutex<Vec<Sender<BossMessage>>>>, threshold: usize, maximum_shared: usize, ) where I: Send +'...
rk<I
identifier_name
factory.rs
//! thread model use std::cmp; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc::{Receiver, Sender}; use std::sync::{mpsc, Arc, Mutex}; use std::thread::{self, Builder}; /// Messages the monitor thread sends to worker threads to control their /// activity. #[derive(PartialEq, Eq, Debug)...
} for _ in 0..tithe { belt.push(hopper.pop().unwrap()); } manager.send(WorkerMessage::WakeUp).ok(); } } ...
for _ in 0..tithe { belt.push(widgets.pop().unwrap()); } tithe = 0; }
conditional_block
factory.rs
//! thread model use std::cmp; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc::{Receiver, Sender}; use std::sync::{mpsc, Arc, Mutex}; use std::thread::{self, Builder}; /// Messages the monitor thread sends to worker threads to control their /// activity. #[derive(PartialEq, Eq, Debug)...
break; } if kill_switch.load(Ordering::Relaxed) { manager.send(WorkerMessage::Slain).ok(); break; } while let Some(stuff) = { let mut temp = belt.lock().unwrap(); temp.pop() } { ...
if message == BossMessage::Stop {
random_line_split
method_self_arg1.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl Copy for Foo {} impl Foo { pub fn foo(self, x: &Foo) { unsafe { COUNT *= 2; } // Test internal call. Foo::bar(&self); Foo::bar(x); Foo::baz(self); Foo::baz(*x); Foo::qux(box self); Foo::qux(box *x); } pub fn bar(&self) { unsaf...
pub fn get_count() -> u64 { unsafe { COUNT } } pub struct Foo;
random_line_split
method_self_arg1.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn bar(&self) { unsafe { COUNT *= 3; } } pub fn baz(self) { unsafe { COUNT *= 5; } } pub fn qux(self: Box<Foo>) { unsafe { COUNT *= 7; } } }
{ unsafe { COUNT *= 2; } // Test internal call. Foo::bar(&self); Foo::bar(x); Foo::baz(self); Foo::baz(*x); Foo::qux(box self); Foo::qux(box *x); }
identifier_body
method_self_arg1.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() -> u64 { unsafe { COUNT } } pub struct Foo; impl Copy for Foo {} impl Foo { pub fn foo(self, x: &Foo) { unsafe { COUNT *= 2; } // Test internal call. Foo::bar(&self); Foo::bar(x); Foo::baz(self); Foo::baz(*x); Foo::qux(box self); Foo::qux(box *...
get_count
identifier_name
router.rs
//! This example shows how to serve static files at specific //! mount points, and then delegate the rest of the paths to a router. //! //! It serves the docs from target/doc at the /docs/ mount point //! and delegates the rest to a router, which itself defines a //! handler for route /hello //! //! Make sure to genera...
() { let mut router = Router::new(); router .get("/hello", say_hello); let mut mount = Mount::new(); mount .mount("/", router) .mount("/docs/", Static::new(Path::new("target/doc"))); Iron::new(mount).listen(Ipv4Addr(127, 0, 0, 1), 3000); }
main
identifier_name
router.rs
//! This example shows how to serve static files at specific //! mount points, and then delegate the rest of the paths to a router. //! //! It serves the docs from target/doc at the /docs/ mount point //! and delegates the rest to a router, which itself defines a //! handler for route /hello //! //! Make sure to genera...
Iron::new(mount).listen(Ipv4Addr(127, 0, 0, 1), 3000); }
random_line_split
router.rs
//! This example shows how to serve static files at specific //! mount points, and then delegate the rest of the paths to a router. //! //! It serves the docs from target/doc at the /docs/ mount point //! and delegates the rest to a router, which itself defines a //! handler for route /hello //! //! Make sure to genera...
{ let mut router = Router::new(); router .get("/hello", say_hello); let mut mount = Mount::new(); mount .mount("/", router) .mount("/docs/", Static::new(Path::new("target/doc"))); Iron::new(mount).listen(Ipv4Addr(127, 0, 0, 1), 3000); }
identifier_body
mod.rs
//! The module contains a simple HTTP/2 server implementation. use http::{Response, HttpResult, HttpError, HttpScheme, Header, StreamId}; use http::transport::TransportStream; use http::connection::{HttpConnection, EndStream, SendStatus}; use http::session::{DefaultSessionState, SessionState, Stream}; use http::server...
(&mut self, responses: Vec<Response>) -> HttpResult<()> { for response in responses.into_iter() { try!(self.conn.start_response( response.headers, response.stream_id, EndStream::No)); let mut stream = self.conn.state.get_stream_...
prepare_responses
identifier_name
mod.rs
//! The module contains a simple HTTP/2 server implementation. use http::{Response, HttpResult, HttpError, HttpScheme, Header, StreamId}; use http::transport::TransportStream; use http::connection::{HttpConnection, EndStream, SendStatus}; use http::session::{DefaultSessionState, SessionState, Stream}; use http::server...
/// Removes closed streams from the connection state. #[inline] fn reap_streams(&mut self) -> HttpResult<()> { // Moves the streams out of the state and then drops them let _ = self.conn.state.get_closed(); Ok(()) } }
{ while let SendStatus::Sent = try!(self.conn.send_next_data()) {} Ok(()) }
identifier_body
mod.rs
//! The module contains a simple HTTP/2 server implementation. use http::{Response, HttpResult, HttpError, HttpScheme, Header, StreamId}; use http::transport::TransportStream; use http::connection::{HttpConnection, EndStream, SendStatus}; use http::session::{DefaultSessionState, SessionState, Stream}; use http::server...
/// Removes closed streams from the connection state. #[inline] fn reap_streams(&mut self) -> HttpResult<()> { // Moves the streams out of the state and then drops them let _ = self.conn.state.get_closed(); Ok(()) } }
Ok(()) }
random_line_split
mod.rs
//! The module contains a simple HTTP/2 server implementation. use http::{Response, HttpResult, HttpError, HttpScheme, Header, StreamId}; use http::transport::TransportStream; use http::connection::{HttpConnection, EndStream, SendStatus}; use http::session::{DefaultSessionState, SessionState, Stream}; use http::server...
let conn = HttpConnection::<TS, TS>::with_stream(stream, HttpScheme::Http); let mut server = SimpleServer { conn: ServerConnection::with_connection(conn, DefaultSessionState::new()), handler: handler, }; // Initialize the connection -- send own settings and pro...
{ return Err(HttpError::UnableToConnect); }
conditional_block
plugin_io.rs
use std::os::raw::{c_char, c_void}; use prodbg_api::io::{CPDLoadState, CPDSaveState, LoadState}; use prodbg_api::cfixed_string::CFixedString; use std::ffi::CStr; use std::mem::transmute; use std::ptr; struct WriterData { data: Vec<String>, read_index: usize, } impl WriterData { fn new() -> WriterData { ...
(data: &Vec<String>) -> WriterData { WriterData { data: data.clone(), read_index: 0, } } } fn write_int(priv_data: *mut c_void, data: i64) { unsafe { println!("saving {}", data); let t = priv_data as *mut WriterData; let v = format!("{}", data); ...
new_load
identifier_name
plugin_io.rs
use std::os::raw::{c_char, c_void}; use prodbg_api::io::{CPDLoadState, CPDSaveState, LoadState}; use prodbg_api::cfixed_string::CFixedString; use std::ffi::CStr; use std::mem::transmute; use std::ptr; struct WriterData { data: Vec<String>, read_index: usize, } impl WriterData { fn new() -> WriterData { ...
fn write_string(priv_data: *mut c_void, data: *const c_char) { unsafe { let t = priv_data as *mut WriterData; let v = CStr::from_ptr(data).to_string_lossy().into_owned(); println!("saving {}", v); (*t).data.push(v); } } // TODO: error handling fn read_int(priv_data: *mut c_voi...
{ unsafe { println!("saving {}", data); let t = priv_data as *mut WriterData; let v = format!("{}", data); (*t).data.push(v); } }
identifier_body
plugin_io.rs
use std::os::raw::{c_char, c_void}; use prodbg_api::io::{CPDLoadState, CPDSaveState, LoadState}; use prodbg_api::cfixed_string::CFixedString; use std::ffi::CStr; use std::mem::transmute; use std::ptr; struct WriterData { data: Vec<String>, read_index: usize, } impl WriterData { fn new() -> WriterData { ...
let tstring = CFixedString::from_str(&v); ptr::copy(tstring.as_ptr(), data as *mut i8, len); LoadState::Ok } } pub fn get_writer_funcs() -> CPDSaveState { CPDSaveState { priv_data: unsafe { transmute(Box::new(WriterData::new())) }, write_int: write_int, write...
{ len = max_len as usize; }
conditional_block
plugin_io.rs
use std::os::raw::{c_char, c_void}; use prodbg_api::io::{CPDLoadState, CPDSaveState, LoadState}; use prodbg_api::cfixed_string::CFixedString; use std::ffi::CStr; use std::mem::transmute; use std::ptr; struct WriterData { data: Vec<String>, read_index: usize, } impl WriterData { fn new() -> WriterData { ...
let v = format!("{}", data); (*t).data.push(v); } } fn write_string(priv_data: *mut c_void, data: *const c_char) { unsafe { let t = priv_data as *mut WriterData; let v = CStr::from_ptr(data).to_string_lossy().into_owned(); println!("saving {}", v); (*t).data.push...
random_line_split
bg.rs
all background layers. The cache is created lazily /// (when BG layer pixels are looked up), so we will not waste time caching a disabled BG layer. #[derive(Default)] pub struct BgCache { layers: [BgLayerCache; 4], } /// Data that's stored in the BG layer caches for a single pixel #[derive(Copy, Clone, Default)] ...
; let screen_y = y ^ if vflip { 0xff } else { 0x00 }; let mut org_x = (self.m7hofs as i16 - self.m7x as i16) &!0x1c00; if org_x < 0 { org_x |= 0x1c00; } let mut org_y = (self.m7vofs as i16 - self.m7y as i16) &!0x1c00; if org_y < 0 { org_y |= 0x1c00; } ...
{ 0x00 }
conditional_block
bg.rs
of all background layers. The cache is created lazily /// (when BG layer pixels are looked up), so we will not waste time caching a disabled BG layer. #[derive(Default)] pub struct BgCache { layers: [BgLayerCache; 4], } /// Data that's stored in the BG layer caches for a single pixel #[derive(Copy, Clone, Default...
(&mut self, bg_num: u8) { // Apply BG scrolling and get the tile coordinates // FIXME Apply mosaic filter // FIXME Fix this: "Note that many games will set their vertical scroll values to -1 rather // than 0. This is because the SNES loads OBJ data for each scanline during the previous ...
render_bg_scanline
identifier_name
bg.rs
line of all background layers. The cache is created lazily /// (when BG layer pixels are looked up), so we will not waste time caching a disabled BG layer. #[derive(Default)] pub struct BgCache { layers: [BgLayerCache; 4], } /// Data that's stored in the BG layer caches for a single pixel #[derive(Copy, Clone, Def...
(6, _) => palette_num * 16, // BG1 has 16 colors (7, _) => panic!("unreachable: palette_base_for_bg_tile for mode 7"), _ => unreachable!(), } } fn render_mode7_scanline(&mut self) { // TODO Figure out how to integrate EXTBG assert!(self.setini & 0x40 ...
(3, 1) => 0, (3, 2) => palette_num * 16, (4, 1) => 0, (4, 2) => palette_num * 4,
random_line_split
9linkedlist.rs
use List::*; enum List { Cons(u32, Box<List>), Nil } impl List { fn new() -> List { Nil } fn prepend(self, val: u32) -> List { Cons(val, Box::new(self)) } fn len(&self) -> i32 { match *self { Cons(_, ref tail) => 1 + tail.len(), Nil => 0 ...
{ let mut list = List::new(); list = list.prepend(4); list = list.prepend(3); list = list.prepend(2); list = list.prepend(1); println!("{}", list.stringify()); println!("Length: {}", list.len()); }
identifier_body
9linkedlist.rs
use List::*; enum
{ Cons(u32, Box<List>), Nil } impl List { fn new() -> List { Nil } fn prepend(self, val: u32) -> List { Cons(val, Box::new(self)) } fn len(&self) -> i32 { match *self { Cons(_, ref tail) => 1 + tail.len(), Nil => 0 } } fn ...
List
identifier_name
9linkedlist.rs
use List::*; enum List { Cons(u32, Box<List>), Nil } impl List { fn new() -> List { Nil } fn prepend(self, val: u32) -> List { Cons(val, Box::new(self)) } fn len(&self) -> i32 { match *self { Cons(_, ref tail) => 1 + tail.len(), Nil => 0 ...
println!("{}", list.stringify()); println!("Length: {}", list.len()); }
list = list.prepend(4); list = list.prepend(3); list = list.prepend(2); list = list.prepend(1);
random_line_split
names.rs
use errors::{ParseError, make_error}; use nom::{IResult, ErrorKind}; use nom::IResult::*; use std::error; use std::fmt; use std::io; use std::io::Write; use std::str::FromStr; /// Representation of a domain name /// /// Domain names consist of one or more labels, broken up by the character '.'. /// /// ``` /// # use m...
(&self, fmt: &mut fmt::Formatter) -> fmt::Result { use std::str; let mut pos = 0; loop { match self.name[pos] { 0 => break, length => { let start = (pos + 1) as usize; let end = start + length as usize; ...
fmt
identifier_name
names.rs
use errors::{ParseError, make_error}; use nom::{IResult, ErrorKind}; use nom::IResult::*; use std::error; use std::fmt; use std::io; use std::io::Write; use std::str::FromStr; /// Representation of a domain name /// /// Domain names consist of one or more labels, broken up by the character '.'. /// /// ``` /// # use m...
else { Done(out, name) } } 1...63 => { name.push(length as u8); let newlength = name.len() + length + 1; if newlength > 255 { // Plus the ending '0' makes this > 255. return Error(make_error(TotalLengthGreat...
{ Error(ErrorKind::Custom(ParseError::from(TotalLengthGreaterThan255(name.len())))) }
conditional_block
names.rs
use errors::{ParseError, make_error}; use nom::{IResult, ErrorKind}; use nom::IResult::*; use std::error; use std::fmt; use std::io; use std::io::Write; use std::str::FromStr; /// Representation of a domain name /// /// Domain names consist of one or more labels, broken up by the character '.'. /// /// ``` /// # use m...
} let offset = (((i[0] & 0b0011_1111) as usize) << 8) + i[1] as usize; if data.len() < offset { return Incomplete(Needed::Size(offset)); } let out = &i[2..]; match do_parse_name(&data[offset..], data, name) { Done(_,...
192...255 => { if i.len() < 2 { return Incomplete(Needed::Size(2));
random_line_split
foreign-dupe.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ unsafe { rustrt1::rust_get_test_int(); rustrt2::rust_get_test_int(); } }
identifier_body
foreign-dupe.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
rustrt1::rust_get_test_int(); rustrt2::rust_get_test_int(); } }
random_line_split
foreign-dupe.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { unsafe { rustrt1::rust_get_test_int(); rustrt2::rust_get_test_int(); } }
main
identifier_name