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
radionodelist.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 dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen...
(window: &Window) -> Root<RadioNodeList> { RadioNodeList::new(window, NodeListType::Simple(vec![])) } // FIXME: This shouldn't need to be implemented here since NodeList (the parent of // RadioNodeList) implements Length // https://github.com/servo/servo/issues/5875 pub fn Length(&self) -> ...
empty
identifier_name
radionodelist.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 dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen...
// FIXME: This shouldn't need to be implemented here since NodeList (the parent of // RadioNodeList) implements Length // https://github.com/servo/servo/issues/5875 pub fn Length(&self) -> u32 { self.node_list.Length() } } impl RadioNodeListMethods for RadioNodeList { // https://html....
{ RadioNodeList::new(window, NodeListType::Simple(vec![])) }
identifier_body
win32.rs
#[allow(non_camel_case_types)] extern crate libc; use self::libc::types::os::arch::c95::{ c_int, c_long, c_ulong, wchar_t, c_uint, c_ushort }; use self::libc::types::common::c95::c_void; // Standard C types in Microsoft C pub type CCINT = c_int; // WinDef.h:173 => typedef unsigned int UINT; pub type UINT = c_uint;...
pub type HINSTANCE = HANDLE; // WinDef.h:277 => DECLARE_HANDLE(HMENU); pub type HMENU = HANDLE; // WinDef.h:275 => DECLARE_HANDLE(HICON); pub type HICON = HANDLE; // WinDef.h:311 => DECLARE_HANDLE(HCURSOR); pub type HCURSOR = HANDLE; // WinDef.h:261 => DECLARE_HANDLE(HBRUSH); pub type HBRUSH = HANDLE; // WinDef.h:...
// WinDef.h:208 => DECLARE_HANDLE(HWND); pub type HWND = HANDLE; // WinDef.h:280 => DECLARE_HANDLE(HINSTANCE);
random_line_split
pass.rs
// Copyright 2012 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 ...
debug!("pass #%d", passno); passno += 1; do time(copy pass.name) { (pass.f)(srv.clone(), copy doc) } } } #[test] fn test_run_passes() { fn pass1( _srv: astsrv::Srv, doc: doc::Doc ) -> doc::Doc { doc::Doc{ pages: ~[ ...
passes: ~[Pass] ) -> doc::Doc { let mut passno = 0; do vec::foldl(doc, passes) |doc, pass| {
random_line_split
pass.rs
// Copyright 2012 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 ...
( srv: astsrv::Srv, doc: doc::Doc, passes: ~[Pass] ) -> doc::Doc { let mut passno = 0; do vec::foldl(doc, passes) |doc, pass| { debug!("pass #%d", passno); passno += 1; do time(copy pass.name) { (pass.f)(srv.clone(), copy doc) } } } #[test] fn test_ru...
run_passes
identifier_name
pass.rs
// Copyright 2012 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 ...
#[test] fn test_run_passes() { fn pass1( _srv: astsrv::Srv, doc: doc::Doc ) -> doc::Doc { doc::Doc{ pages: ~[ doc::CratePage(doc::CrateDoc{ topmod: doc::ModDoc{ item: doc::ItemDoc { name...
{ let mut passno = 0; do vec::foldl(doc, passes) |doc, pass| { debug!("pass #%d", passno); passno += 1; do time(copy pass.name) { (pass.f)(srv.clone(), copy doc) } } }
identifier_body
any_unique_aliases_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use...
/// If the union variant matches, return a mutable reference to the super::example_2::MonsterT. pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> { if let Self::M2(v) = self { Some(v.as_mut()) } else { None } } }
{ if let Self::M2(v) = self { Some(v.as_ref()) } else { None } }
identifier_body
any_unique_aliases_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use...
(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> { match self { Self::NONE => None, Self::M(v) => Some(v.pack(fbb).as_union_value()), Self::TS(v) => Some(v.pack(fbb).as_union_value()), Self::M2(v) => Some(v.pack(fbb).as_union_va...
pack
identifier_name
any_unique_aliases_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use...
else { f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) } } } impl Serialize for AnyUniqueAliases { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { serializer.serialize_unit_variant("AnyUniqueAliases", self.0 as u32, self.variant_name().unwrap()) }...
{ f.write_str(name) }
conditional_block
any_unique_aliases_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use...
} else { f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) } } } impl Serialize for AnyUniqueAliases { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { serializer.serialize_unit_variant("AnyUniqueAliases", self.0 as u32, self.variant_name().unwrap()...
} impl std::fmt::Debug for AnyUniqueAliases { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name)
random_line_split
issue-3012-1.rs
// Copyright 2012 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 ...
(&mut self) { /* c::close(self.sockfd); */ } } pub fn socket_handle(x: u32) -> socket_handle { socket_handle { sockfd: x } } }
drop
identifier_name
issue-3012-1.rs
// Copyright 2012 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 ...
}
{ socket_handle { sockfd: x } }
identifier_body
issue-3012-1.rs
// Copyright 2012 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 ...
}
}
random_line_split
timers.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 dom::bindings::cell::DOMRefCell; use dom::bindings::callback::ExceptionHandling::Report; use dom::bindings::co...
{ Cancel, Suspend, Resume } // Holder for the various JS values associated with setTimeout // (ie. function value to invoke and all arguments to pass // to the function when calling it) // TODO: Handle rooting during fire_timer when movable GC is turned on #[jstraceable] #[privatize] #[derive(Clone)]...
TimerControlMsg
identifier_name
timers.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 dom::bindings::cell::DOMRefCell; use dom::bindings::callback::ExceptionHandling::Report; use dom::bindings::co...
timeout: i32, is_interval: IsInterval, source: TimerSource, script_chan: Box<ScriptChan+Send>) -> i32 { let timeout = cmp::max(0, timeout) as ...
callback: TimerCallback, arguments: Vec<JSVal>,
random_line_split
func_tracked.rs
use FuncUnsafe; use Symbol; /// A pointer to a shared function which allows a user-provided ref-counting implementation to avoid outliving its library. #[derive(Debug)]
impl <T, TLib> FuncTracked<T, TLib> { /// Creates a new [FuncTracked](struct.FuncTracked.html). /// This should only be called within the library. pub fn new(func: FuncUnsafe<T>, lib: TLib) -> Self { FuncTracked { func: func, _lib: lib, } } } impl <T, TLib> Symb...
pub struct FuncTracked<T, TLib> { func: FuncUnsafe<T>, _lib: TLib, }
random_line_split
func_tracked.rs
use FuncUnsafe; use Symbol; /// A pointer to a shared function which allows a user-provided ref-counting implementation to avoid outliving its library. #[derive(Debug)] pub struct FuncTracked<T, TLib> { func: FuncUnsafe<T>, _lib: TLib, } impl <T, TLib> FuncTracked<T, TLib> { /// Creates a new [FuncTracked...
} impl <T, TLib> Clone for FuncTracked<T, TLib> where T: Copy, TLib: Clone { fn clone(&self) -> Self { FuncTracked { func: self.func, _lib: self._lib.clone(), } } }
{ self.func }
identifier_body
func_tracked.rs
use FuncUnsafe; use Symbol; /// A pointer to a shared function which allows a user-provided ref-counting implementation to avoid outliving its library. #[derive(Debug)] pub struct FuncTracked<T, TLib> { func: FuncUnsafe<T>, _lib: TLib, } impl <T, TLib> FuncTracked<T, TLib> { /// Creates a new [FuncTracked...
(func: FuncUnsafe<T>, lib: TLib) -> Self { FuncTracked { func: func, _lib: lib, } } } impl <T, TLib> Symbol<T> for FuncTracked<T, TLib> where T: Copy { unsafe fn get(&self) -> T { self.func } } impl <T, TLib> Clone for FuncTracked<T, TLib> where T: C...
new
identifier_name
parsyncat.rs
//! Highlights the files given on the command line, in parallel. //! Prints the highlighted output to stdout. use syntect::parsing::SyntaxSet; use syntect::highlighting::{ThemeSet, Style}; use syntect::easy::HighlightFile; use rayon::prelude::*; use std::fs::File; use std::io::{BufReader, BufRead}; fn
() { let files: Vec<String> = std::env::args().skip(1).collect(); if files.is_empty() { println!("Please provide some files to highlight."); return; } let syntax_set = SyntaxSet::load_defaults_newlines(); let theme_set = ThemeSet::load_defaults(); // We first collect the conte...
main
identifier_name
parsyncat.rs
//! Highlights the files given on the command line, in parallel. //! Prints the highlighted output to stdout. use syntect::parsing::SyntaxSet; use syntect::highlighting::{ThemeSet, Style}; use syntect::easy::HighlightFile; use rayon::prelude::*; use std::fs::File; use std::io::{BufReader, BufRead}; fn main() { l...
//...so that the highlighted regions have valid lifetimes... let regions: Vec<Vec<(Style, &str)>> = files.par_iter() .zip(&contents) .map(|(filename, contents)| { let mut regions = Vec::new(); let theme = &theme_set.themes["base16-ocean.dark"]; let mut highlight...
random_line_split
parsyncat.rs
//! Highlights the files given on the command line, in parallel. //! Prints the highlighted output to stdout. use syntect::parsing::SyntaxSet; use syntect::highlighting::{ThemeSet, Style}; use syntect::easy::HighlightFile; use rayon::prelude::*; use std::fs::File; use std::io::{BufReader, BufRead}; fn main() { l...
let syntax_set = SyntaxSet::load_defaults_newlines(); let theme_set = ThemeSet::load_defaults(); // We first collect the contents of the files... let contents: Vec<Vec<String>> = files.par_iter() .map(|filename| { let mut lines = Vec::new(); // We use `String::new()` an...
{ println!("Please provide some files to highlight."); return; }
conditional_block
parsyncat.rs
//! Highlights the files given on the command line, in parallel. //! Prints the highlighted output to stdout. use syntect::parsing::SyntaxSet; use syntect::highlighting::{ThemeSet, Style}; use syntect::easy::HighlightFile; use rayon::prelude::*; use std::fs::File; use std::io::{BufReader, BufRead}; fn main()
lines.push(line); line = String::new(); } lines }) .collect(); //...so that the highlighted regions have valid lifetimes... let regions: Vec<Vec<(Style, &str)>> = files.par_iter() .zip(&contents) .map(|(filename, contents)| { ...
{ let files: Vec<String> = std::env::args().skip(1).collect(); if files.is_empty() { println!("Please provide some files to highlight."); return; } let syntax_set = SyntaxSet::load_defaults_newlines(); let theme_set = ThemeSet::load_defaults(); // We first collect the contents...
identifier_body
tcpstream.rs
use openssl::ssl::SslStream; use std::io::{BufRead, BufReader, Error, Read, Write}; use std::net::TcpStream; #[derive(Debug)] pub enum TCPStreamType { Plain(BufReader<TcpStream>), SSL(BufReader<SslStream<TcpStream>>), } impl Write for TCPStreamType { fn write(&mut self, buf: &[u8]) -> Result<usize, Error>...
(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error> { match *self { TCPStreamType::Plain(ref mut stream) => stream.read_until(byte, buf), TCPStreamType::SSL(ref mut stream) => stream.read_until(byte, buf), } } pub fn write_string(&mut self, buf: &str) -> Res...
read_until
identifier_name
tcpstream.rs
use openssl::ssl::SslStream; use std::io::{BufRead, BufReader, Error, Read, Write}; use std::net::TcpStream; #[derive(Debug)] pub enum TCPStreamType { Plain(BufReader<TcpStream>), SSL(BufReader<SslStream<TcpStream>>), } impl Write for TCPStreamType { fn write(&mut self, buf: &[u8]) -> Result<usize, Error>...
fn flush(&mut self) -> Result<(), Error> { match *self { TCPStreamType::Plain(ref mut stream) => stream.get_mut().flush(), TCPStreamType::SSL(ref mut stream) => stream.get_mut().flush(), } } } impl Read for TCPStreamType { fn read(&mut self, buf: &mut [u8]) -> Resu...
{ match *self { TCPStreamType::Plain(ref mut stream) => stream.get_mut().write(buf), TCPStreamType::SSL(ref mut stream) => stream.get_mut().write(buf), } }
identifier_body
tcpstream.rs
use openssl::ssl::SslStream; use std::io::{BufRead, BufReader, Error, Read, Write}; use std::net::TcpStream; #[derive(Debug)] pub enum TCPStreamType { Plain(BufReader<TcpStream>), SSL(BufReader<SslStream<TcpStream>>), } impl Write for TCPStreamType { fn write(&mut self, buf: &[u8]) -> Result<usize, Error>...
impl Read for TCPStreamType { fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> { match *self { TCPStreamType::Plain(ref mut stream) => stream.read(buf), TCPStreamType::SSL(ref mut stream) => stream.read(buf), } } } impl TCPStreamType { pub fn read_until(&m...
TCPStreamType::Plain(ref mut stream) => stream.get_mut().flush(), TCPStreamType::SSL(ref mut stream) => stream.get_mut().flush(), } } }
random_line_split
eig.rs
use super::lobpcg::{lobpcg, LobpcgResult, Order}; use crate::{generate, Scalar}; use lax::Lapack; ///! Implements truncated eigenvalue decomposition /// use ndarray::prelude::*; use ndarray::stack; use ndarray::ScalarOperand; use num_traits::{Float, NumCast}; /// Truncated eigenproblem solver /// /// This struct wrap...
(mut self, preconditioner: Array2<A>) -> Self { self.preconditioner = Some(preconditioner); self } // calculate the eigenvalues decompose pub fn decompose(&self, num: usize) -> LobpcgResult<A> { let x: Array2<f64> = generate::random((self.problem.len_of(Axis(0)), num)); let...
precondition_with
identifier_name
eig.rs
use super::lobpcg::{lobpcg, LobpcgResult, Order}; use crate::{generate, Scalar}; use lax::Lapack; ///! Implements truncated eigenvalue decomposition /// use ndarray::prelude::*; use ndarray::stack; use ndarray::ScalarOperand; use num_traits::{Float, NumCast}; /// Truncated eigenproblem solver /// /// This struct wrap...
pub struct TruncatedEigIterator<A: Scalar> { step_size: usize, remaining: usize, eig: TruncatedEig<A>, } impl<A: Float + Scalar + ScalarOperand + Lapack + PartialOrd + Default> Iterator for TruncatedEigIterator<A> { type Item = (Array1<A>, Array2<A>); fn next(&mut self) -> Option<Self::Item> {...
/// Truncate eigenproblem iterator /// /// This wraps a truncated eigenproblem and provides an iterator where each step yields a new /// eigenvalue/vector pair. Useful for generating pairs until a certain condition is met.
random_line_split
variable_length_fields.rs
// Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com> // // 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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or...
() { // Test if we can add data to the u16be let mut packet = [0u8; 7]; { let mut p = MutablePacketWithU16Packet::new(&mut packet[..]).unwrap(); p.set_length(6); p.set_data(&vec![0x0001, 0x1223, 0x3ff4]); } let ref_packet = [0x06, /* length */ 0x00, 0x...
main
identifier_name
variable_length_fields.rs
// Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com> // // 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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or...
unimplemented!() } fn main() { // Test if we can add data to the u16be let mut packet = [0u8; 7]; { let mut p = MutablePacketWithU16Packet::new(&mut packet[..]).unwrap(); p.set_length(6); p.set_data(&vec![0x0001, 0x1223, 0x3ff4]); } let ref_packet = [0x06, /* length */...
payload: Vec<u8> } fn length_fn(_: &PacketWithPayloadPacket) -> usize {
random_line_split
advent6.rs
// advent6.rs // christmas light grid extern crate bit_vec; #[macro_use] extern crate scan_fmt; use bit_vec::BitVec; use std::io; #[cfg(not(test))] const GRID_SIZE: usize = 1000; #[cfg(test)] const GRID_SIZE: usize = 8; fn main() { // Part 1 initialization // Initialize grid of lights, all off let row_...
else if cmd.contains("off") { apply_cmd2(cmd, grid, "turn off ", Box::new(|x| *x = if *x > 0 { *x - 1 } else { *x })); } else if cmd.contains("on") { apply_cmd2(cmd, grid, "turn on ", Box::new(|x| *x += 1)); } } fn apply_cmd2(cmd: &str, grid: &mut [[u32; GRID_SIZE]; GRID_SIZE], cmd_head: &st...
{ apply_cmd2(cmd, grid, "toggle ", Box::new(|x| *x += 2)); }
conditional_block
advent6.rs
// advent6.rs // christmas light grid extern crate bit_vec; #[macro_use] extern crate scan_fmt; use bit_vec::BitVec; use std::io; #[cfg(not(test))] const GRID_SIZE: usize = 1000; #[cfg(test)] const GRID_SIZE: usize = 8; fn main() { // Part 1 initialization // Initialize grid of lights, all off let row_...
// Part 2 initialization let mut grid2 = [[0u32; GRID_SIZE]; GRID_SIZE]; // Part 1 and 2, Parse input loop { let mut input = String::new(); let result = io::stdin().read_line(&mut input); match result { Ok(byte_count) => if byte_count == 0 { break; }, Err...
random_line_split
advent6.rs
// advent6.rs // christmas light grid extern crate bit_vec; #[macro_use] extern crate scan_fmt; use bit_vec::BitVec; use std::io; #[cfg(not(test))] const GRID_SIZE: usize = 1000; #[cfg(test)] const GRID_SIZE: usize = 8; fn main() { // Part 1 initialization // Initialize grid of lights, all off let row_...
(grid: &Vec<BitVec>) -> usize { let mut total_bits = 0; for row in grid { total_bits += row.iter().filter(|x| *x).count(); } total_bits } #[test] fn test_part1() { let bv = BitVec::from_elem(8, false); let mut grid: Vec<BitVec> = Vec::new(); for _ in 0..8 { grid.push(bv.clo...
count_bits
identifier_name
advent6.rs
// advent6.rs // christmas light grid extern crate bit_vec; #[macro_use] extern crate scan_fmt; use bit_vec::BitVec; use std::io; #[cfg(not(test))] const GRID_SIZE: usize = 1000; #[cfg(test)] const GRID_SIZE: usize = 8; fn main() { // Part 1 initialization // Initialize grid of lights, all off let row_...
fn calc_total_brightness(grid: &[[u32; GRID_SIZE]; GRID_SIZE]) -> u32 { grid.iter().fold(0, |x,row| x + row.iter().fold(0, |y,z| y + z)) } #[test] fn test_part2() { let mut grid = [[0u32; GRID_SIZE]; GRID_SIZE]; parse_command2("turn on 0,0 through 0,0", &mut grid); assert_eq!(1, calc_total_brightnes...
{ let cmd_tail = cmd.trim_left_matches(cmd_head); let (x1, y1, x2, y2) = scan_fmt!(cmd_tail, "{},{} through {},{}", usize, usize, usize, usize); let range = Range {x1: x1.unwrap(), y1: y1.unwrap(), x2: x2.unwrap(), y2: y2.unwrap()}; let rows = &mut grid[range.y1..range.y2+1]; for row in rows { ...
identifier_body
cpu.rs
//use gb::memory::Memory; use std::sync::mpsc::channel; #[derive(Default)] pub struct Cpu { // some variables public for debugging at the moment pub reg_a: u8, // accumulator pub reg_b: u8, pub reg_c: u8, pub reg_d: u8, pub reg_e: u8, pub reg_f: u8, // flags pub reg_h: u8, pub re...
reg_pc: 0x0100, cont: true, allow_interrupts: false, interrupt_count: 0, cycle_count: 0 } } // combination register getters pub fn get_reg_af(&self) -> u16 { (((self.reg_a as u16 * 0x100)) + (self.reg_f as u16)) as u16 } pub fn get_reg_bc(&self) ->...
random_line_split
cpu.rs
//use gb::memory::Memory; use std::sync::mpsc::channel; #[derive(Default)] pub struct Cpu { // some variables public for debugging at the moment pub reg_a: u8, // accumulator pub reg_b: u8, pub reg_c: u8, pub reg_d: u8, pub reg_e: u8, pub reg_f: u8, // flags pub reg_h: u8, pub re...
(&mut self) { if get_bit_at_8(self.reg_f, 6) { self.reg_f -= 0b01000000u8; } } pub fn reset_h(&mut self) { if get_bit_at_8(self.reg_f, 5) { self.reg_f -= 0b00100000u8; } } pub fn reset_c(&mut self) { if get_bit_at_8(self.reg_f, 4) { ...
reset_n
identifier_name
cpu.rs
//use gb::memory::Memory; use std::sync::mpsc::channel; #[derive(Default)] pub struct Cpu { // some variables public for debugging at the moment pub reg_a: u8, // accumulator pub reg_b: u8, pub reg_c: u8, pub reg_d: u8, pub reg_e: u8, pub reg_f: u8, // flags pub reg_h: u8, pub re...
pub fn reset_n(&mut self) { if get_bit_at_8(self.reg_f, 6) { self.reg_f -= 0b01000000u8; } } pub fn reset_h(&mut self) { if get_bit_at_8(self.reg_f, 5) { self.reg_f -= 0b00100000u8; } } pub fn reset_c(&mut self) { if get_bit_at_8(self....
{ if get_bit_at_8(self.reg_f, 7) { self.reg_f -= 0b10000000u8; } }
identifier_body
cpu.rs
//use gb::memory::Memory; use std::sync::mpsc::channel; #[derive(Default)] pub struct Cpu { // some variables public for debugging at the moment pub reg_a: u8, // accumulator pub reg_b: u8, pub reg_c: u8, pub reg_d: u8, pub reg_e: u8, pub reg_f: u8, // flags pub reg_h: u8, pub re...
else { false } } pub fn get_bit_at_8(input: u8, n: u8) -> bool { if n < 8 { input & (1 << n)!= 0 } else { false } }
{ input & (1 << n) != 0 }
conditional_block
iso_8859_13.rs
// AUTOGENERATED FROM index-iso-8859-13.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ // // For details on index-iso-8859-13.txt see the Encoding Standard // http://encoding.spec.whatwg.org/ static FORWARD_TABLE: &'static [u16...
FORWARD_TABLE[(code - 0x80) as uint] } static BACKWARD_TABLE_LOWER: &'static [u8] = &[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132,...
pub fn forward(code: u8) -> u16 {
random_line_split
iso_8859_13.rs
// AUTOGENERATED FROM index-iso-8859-13.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ // // For details on index-iso-8859-13.txt see the Encoding Standard // http://encoding.spec.whatwg.org/ static FORWARD_TABLE: &'static [u16...
(code: u32) -> u8 { let offset = (code >> 6) as uint; let offset = if offset < 129 {BACKWARD_TABLE_UPPER[offset] as uint} else {0}; BACKWARD_TABLE_LOWER[offset + ((code & 63) as uint)] } #[cfg(test)] single_byte_tests!()
backward
identifier_name
iso_8859_13.rs
// AUTOGENERATED FROM index-iso-8859-13.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ // // For details on index-iso-8859-13.txt see the Encoding Standard // http://encoding.spec.whatwg.org/ static FORWARD_TABLE: &'static [u16...
static BACKWARD_TABLE_LOWER: &'static [u8] = &[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 14...
{ FORWARD_TABLE[(code - 0x80) as uint] }
identifier_body
iso_8859_13.rs
// AUTOGENERATED FROM index-iso-8859-13.txt, ORIGINAL COMMENT FOLLOWS: // // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ // // For details on index-iso-8859-13.txt see the Encoding Standard // http://encoding.spec.whatwg.org/ static FORWARD_TABLE: &'static [u16...
else {0}; BACKWARD_TABLE_LOWER[offset + ((code & 63) as uint)] } #[cfg(test)] single_byte_tests!()
{BACKWARD_TABLE_UPPER[offset] as uint}
conditional_block
camera.rs
use glfw; use std::uint; use std::libc::c_int; use std::hashmap::HashMap; use math::{Vec3, Mat4}; use gl::Mesh; use gl::shader::{Shader, AttribLocation, UniformLocation}; use glfw::Window; pub struct Camera { window: ~Window, translation: Vec3<f32>, rotation: Vec3<f32>, eye: Vec3<f32>, center: ...
(&self) -> Mat4<f32> { let f = (self.center - self.eye).normalize(); let s = f.cross(&self.up.normalize()).normalize(); let u = s.cross(&f); let mut result = Mat4::from_elem(1.0f32); result.data[0][0] = s.x.clone(); result.data[1][0] = s.y.clone(); ...
calc_view
identifier_name
camera.rs
use glfw; use std::uint; use std::libc::c_int; use std::hashmap::HashMap; use math::{Vec3, Mat4}; use gl::Mesh; use gl::shader::{Shader, AttribLocation, UniformLocation}; use glfw::Window; pub struct Camera { window: ~Window, translation: Vec3<f32>, rotation: Vec3<f32>, eye: Vec3<f32>, center: V...
impl Camera { pub fn new(window: ~Window, shader_name: &str) -> Camera { let (width, height) = window.get_size(); let program = Shader::from_files(fmt!("%s.v.glsl", shader_name), fmt!("%s.f.glsl", shader_name)); let zero_vec = Vec3::new(0.0f32, 0.0, 0.0); let mut attribs = H...
random_line_split
condvar.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 ...
let mut sys_now = libc::timeval { tv_sec: 0, tv_usec: 0 }; let stable_now = Instant::now(); let r = libc::gettimeofday(&mut sys_now, ptr::null_mut()); debug_assert_eq!(r, 0); let nsec = dur.subsec_nanos() as libc::c_long + (sys_now.tv_usec * 1000) as libc::c_l...
} // First, figure out what time it currently is, in both system and // stable time. pthread_cond_timedwait uses system time, but we want to // report timeout based on stable time.
random_line_split
condvar.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 Condvar { pub const fn new() -> Condvar { // Might be moved and address is changing it is better to avoid // initialization of potentially opaque OS data before it landed Condvar { inner: UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER) } } #[cfg(any(target_os = "macos", ...
{ if value > <libc::time_t>::max_value() as u64 { <libc::time_t>::max_value() } else { value as libc::time_t } }
identifier_body
condvar.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 ...
(value: u64) -> libc::time_t { if value > <libc::time_t>::max_value() as u64 { <libc::time_t>::max_value() } else { value as libc::time_t } } impl Condvar { pub const fn new() -> Condvar { // Might be moved and address is changing it is better to avoid // initialization ...
saturating_cast_to_time_t
identifier_name
condvar.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 ...
// First, figure out what time it currently is, in both system and // stable time. pthread_cond_timedwait uses system time, but we want to // report timeout based on stable time. let mut sys_now = libc::timeval { tv_sec: 0, tv_usec: 0 }; let stable_now = Instant::now(); ...
{ // OSX implementation of `pthread_cond_timedwait` is buggy // with super long durations. When duration is greater than // 0x100_0000_0000_0000 seconds, `pthread_cond_timedwait` // in macOS Sierra return error 316. // // This program demonstrates ...
conditional_block
test_cargo_build_auth.rs
use std::io::{TcpListener, Listener, Acceptor, BufferedStream}; use std::io::net::tcp::TcpAcceptor; use std::collections::HashSet; use git2; use support::{project, execs, ResultTest, UPDATING}; use support::paths; use hamcrest::assert_that; fn setup() { } struct Closer { a: TcpAcceptor } impl Drop for Closer { ...
.file("Cargo.toml", r#" [project] name = "script" version = "0.0.1" authors = [] "#) .file("src/main.rs", r#" fn main() { println!("username=foo"); println!("password=bar"); } "#); a...
tx.send(()); }); let script = project("script")
random_line_split
test_cargo_build_auth.rs
use std::io::{TcpListener, Listener, Acceptor, BufferedStream}; use std::io::net::tcp::TcpAcceptor; use std::collections::HashSet; use git2; use support::{project, execs, ResultTest, UPDATING}; use support::paths; use hamcrest::assert_that; fn setup()
struct Closer { a: TcpAcceptor } impl Drop for Closer { fn drop(&mut self) { let _ = self.a.close_accept(); } } // Test that HTTP auth is offered from `credential.helper` test!(http_auth_offered { let mut listener = TcpListener::bind("127.0.0.1", 0).assert(); let addr = listener.socket_name(...
{ }
identifier_body
test_cargo_build_auth.rs
use std::io::{TcpListener, Listener, Acceptor, BufferedStream}; use std::io::net::tcp::TcpAcceptor; use std::collections::HashSet; use git2; use support::{project, execs, ResultTest, UPDATING}; use support::paths; use hamcrest::assert_that; fn setup() { } struct Closer { a: TcpAcceptor } impl Drop for Closer { ...
(&mut self) { let _ = self.a.close_accept(); } } // Test that HTTP auth is offered from `credential.helper` test!(http_auth_offered { let mut listener = TcpListener::bind("127.0.0.1", 0).assert(); let addr = listener.socket_name().assert(); let mut a = listener.listen().unwrap(); let a2 = a...
drop
identifier_name
animation.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/. */ //! CSS transitions and animations. use flow::{self, Flow}; use incremental::{self, RestyleDamage}; use clock_ti...
layout_task.tick_animations(rw_data); layout_task.script_chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap(); }
random_line_split
animation.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/. */ //! CSS transitions and animations. use flow::{self, Flow}; use incremental::{self, RestyleDamage}; use clock_ti...
(flow: &mut Flow, animations: &HashMap<OpaqueNode, Vec<Animation>>) { let mut damage = RestyleDamage::empty(); flow.mutate_fragments(&mut |fragment| { if let Some(ref animations) = animations.get(&OpaqueNode(fragment.node.id())) { for animation in *animatio...
recalc_style_for_animations
identifier_name
animation.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/. */ //! CSS transitions and animations. use flow::{self, Flow}; use incremental::{self, RestyleDamage}; use clock_ti...
Entry::Occupied(mut entry) => entry.get_mut().push(new_running_animation), } } rw_data.running_animations = Arc::new(running_animations); } let animation_state; if rw_data.running_animations.is_empty() { animation_state = AnimationState::NoAnimationsPres...
{ let mut new_running_animations = Vec::new(); while let Ok(animation) = rw_data.new_animations_receiver.try_recv() { new_running_animations.push(animation) } if !new_running_animations.is_empty() { let mut running_animations = (*rw_data.running_animations).clone(); // Expire ol...
identifier_body
animation.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/. */ //! CSS transitions and animations. use flow::{self, Flow}; use incremental::{self, RestyleDamage}; use clock_ti...
if progress <= 0.0 { continue } let mut new_style = fragment.style.clone(); animation.property_animation.update(&mut *Arc::make_unique(&mut new_style), progress); dam...
{ progress = 1.0 }
conditional_block
fn-custom-2.rs
// rustfmt-fn_arg_indent: Inherit // rustfmt-generics_indent: Tabbed // rustfmt-where_indent: Inherit // rustfmt-where_layout: Mixed // Test different indents. fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) { foo(); } fn bar<'a: 'bbbbbbb...
} struct Foo<TTTTTTTTTTTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUU, VVVVVVVVVVVVVVVVVVVVVVVVVVV, WWWWWWWWWWWWWWWWWWWWWWWW> { foo: Foo, }
{ baz(); }
identifier_body
fn-custom-2.rs
// rustfmt-fn_arg_indent: Inherit // rustfmt-generics_indent: Tabbed // rustfmt-where_indent: Inherit // rustfmt-where_layout: Mixed // Test different indents. fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) { foo(); } fn bar<'a: 'bbbbbbb...
foo: Foo, }
random_line_split
fn-custom-2.rs
// rustfmt-fn_arg_indent: Inherit // rustfmt-generics_indent: Tabbed // rustfmt-where_indent: Inherit // rustfmt-where_layout: Mixed // Test different indents. fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) { foo(); } fn bar<'a: 'bbbbbbb...
<'a: 'bbbbbbbbbbbbbbbbbbbbbbbbbbb, TTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUU: WWWWWWWWWWWWWWWWWWWWWWWW>(a: Aaaaaaaaaaaaaaa) { bar(); } fn baz() where X: TTTTTTTT { baz(); } } struct Foo<TTTTTTTTTTTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUU, VVVVVVVVVVVVVVVVVVVVVVVVVVV, WWWWWWWWWWWWWWWWWWWWWWWW> {...
bar
identifier_name
lib.rs
//! waitgroup provides an interface for awaiting the completion of multiple asynchronous tasks use std::sync::{Condvar, Mutex}; /// A waitgroup waits for a collection of tasks to complete. /// It keeps track of tasks via shared counter pub struct WaitGroup { cvar: Condvar, count: Mutex<usize>, } impl Default...
} /// blocks the current thread until wait group is complete pub fn wait(&self) { let mut count = self.count.lock().unwrap(); while *count > 0 { count = self.cvar.wait(count).unwrap(); } } } #[test] fn it_works() {}
{ self.cvar.notify_all(); }
conditional_block
lib.rs
//! waitgroup provides an interface for awaiting the completion of multiple asynchronous tasks use std::sync::{Condvar, Mutex}; /// A waitgroup waits for a collection of tasks to complete. /// It keeps track of tasks via shared counter pub struct WaitGroup { cvar: Condvar, count: Mutex<usize>, } impl Default...
impl WaitGroup { /// creates a new wait group instance pub fn new(n: usize) -> WaitGroup { WaitGroup { cvar: Condvar::new(), count: Mutex::new(n), } } /// adds `delta` to internal counter pub fn add(&self, delta: usize) { let mut count = self.count.l...
random_line_split
lib.rs
//! waitgroup provides an interface for awaiting the completion of multiple asynchronous tasks use std::sync::{Condvar, Mutex}; /// A waitgroup waits for a collection of tasks to complete. /// It keeps track of tasks via shared counter pub struct WaitGroup { cvar: Condvar, count: Mutex<usize>, } impl Default...
} #[test] fn it_works() {}
{ let mut count = self.count.lock().unwrap(); while *count > 0 { count = self.cvar.wait(count).unwrap(); } }
identifier_body
lib.rs
//! waitgroup provides an interface for awaiting the completion of multiple asynchronous tasks use std::sync::{Condvar, Mutex}; /// A waitgroup waits for a collection of tasks to complete. /// It keeps track of tasks via shared counter pub struct WaitGroup { cvar: Condvar, count: Mutex<usize>, } impl Default...
(n: usize) -> WaitGroup { WaitGroup { cvar: Condvar::new(), count: Mutex::new(n), } } /// adds `delta` to internal counter pub fn add(&self, delta: usize) { let mut count = self.count.lock().unwrap(); *count += delta; self.notify_if_empty(*cou...
new
identifier_name
command.rs
use super::error::CodecError; use crate::SocketType; use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::collections::HashMap; use std::convert::TryFrom; #[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone)] pub enum ZmqCommandName { READY, } impl From<ZmqCommandName> for String { fn from(c_nam...
pub fn add_properties(&mut self, map: HashMap<String, Bytes>) -> &mut Self { self.properties.extend(map); self } } impl TryFrom<BytesMut> for ZmqCommand { type Error = CodecError; fn try_from(mut buf: BytesMut) -> Result<Self, Self::Error> { let command_len = buf.get_u8() as ...
{ self.properties.insert(name, value); self }
identifier_body
command.rs
use super::error::CodecError; use crate::SocketType; use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::collections::HashMap; use std::convert::TryFrom; #[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone)] pub enum ZmqCommandName { READY, } impl From<ZmqCommandName> for String { fn from(c_nam...
message_len += prop.len() + 1; message_len += val.len() + 4; } let long_message = message_len > 255; let mut bytes = BytesMut::new(); if long_message { bytes.reserve(message_len + 9); bytes.put_u8(0x06); bytes.put_u64(message_...
message_len += command_name.len() + 1; for (prop, val) in command.properties.iter() {
random_line_split
command.rs
use super::error::CodecError; use crate::SocketType; use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::collections::HashMap; use std::convert::TryFrom; #[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone)] pub enum ZmqCommandName { READY, } impl From<ZmqCommandName> for String { fn from(c_nam...
(&mut self, name: String, value: Bytes) -> &mut Self { self.properties.insert(name, value); self } pub fn add_properties(&mut self, map: HashMap<String, Bytes>) -> &mut Self { self.properties.extend(map); self } } impl TryFrom<BytesMut> for ZmqCommand { type Error = Cod...
add_prop
identifier_name
graph.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 std::fmt; #[derive(Copy, Clone, Debug)] pub(crate) struct Color(pub u8, pub u8, pub u8); impl fmt::Display for...
#[derive(Clone, Debug)] pub(crate) struct ColorPalette { pub purple: Color, pub red: Color, pub orange: Color, pub yellow: Color, pub green: Color, pub cyan: Color, pub blue: Color, pub black: Color, #[allow(dead_code)] pub gray: Color, #[allow(dead_code)] pub white: Col...
}
random_line_split
graph.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 std::fmt; #[derive(Copy, Clone, Debug)] pub(crate) struct Color(pub u8, pub u8, pub u8); impl fmt::Display for...
{ pub owns: EdgeStyle, pub uses: EdgeStyle, } pub(crate) fn edge_styles() -> EdgeStyles { let color_palette = color_palette(); EdgeStyles { owns: EdgeStyle::new(color_palette.black, Stroke::Solid), uses: EdgeStyle::new(color_palette.gray, Stroke::Dashed), } }
EdgeStyles
identifier_name
source.rs
pub fn to_source(payment_address: &str, seq_no: i32) -> Option<String> { let addr_parts: Vec<&str> = payment_address.split(":").collect(); if addr_parts.len()!= 3 { return None } let mut source_parts: Vec<String> = Vec::new(); source_parts.push(addr_parts.get(0).unwrap().to_string()); ...
let seq_no = match last_parts.get(0).unwrap().to_string().parse() { Ok(v) => v, Err(_) => return None }; let mut recipient_parts = Vec::new(); recipient_parts.push(source_parts.get(0).unwrap().to_string()); recipient_parts.push(source_parts.get(1).unwrap().to_string()); recipien...
random_line_split
source.rs
pub fn to_source(payment_address: &str, seq_no: i32) -> Option<String> { let addr_parts: Vec<&str> = payment_address.split(":").collect(); if addr_parts.len()!= 3 { return None } let mut source_parts: Vec<String> = Vec::new(); source_parts.push(addr_parts.get(0).unwrap().to_string()); ...
(source: &str) -> Option<(i32, String)> { let source_parts: Vec<&str> = source.split(":").collect(); if source_parts.len()!= 3 { return None } let last = source_parts.get(2).unwrap(); let last_parts: Vec<&str> = last.split("_").collect(); if last_parts.len()!= 2 { return None ...
from_source
identifier_name
source.rs
pub fn to_source(payment_address: &str, seq_no: i32) -> Option<String> { let addr_parts: Vec<&str> = payment_address.split(":").collect(); if addr_parts.len()!= 3 { return None } let mut source_parts: Vec<String> = Vec::new(); source_parts.push(addr_parts.get(0).unwrap().to_string()); ...
recipient_parts.push(source_parts.get(0).unwrap().to_string()); recipient_parts.push(source_parts.get(1).unwrap().to_string()); recipient_parts.push(last_parts.get(1).unwrap().to_string()); Some((seq_no, recipient_parts.join(":"))) }
{ let source_parts: Vec<&str> = source.split(":").collect(); if source_parts.len() != 3 { return None } let last = source_parts.get(2).unwrap(); let last_parts: Vec<&str> = last.split("_").collect(); if last_parts.len() != 2 { return None } let seq_no = match last_par...
identifier_body
vtable.rs
} } true }); debug!("lookup_vtables_for_param result(\ location_info={:?}, \ type_param_bounds={}, \ ty={}, \ result={})", location_info, type_param_bounds.repr(vcx.tcx()), ty.repr(vcx.tcx()), param_re...
(vcx: &VtableContext, location_info: &LocationInfo, bounds: &[@ty::TraitRef], param: param_index, trait_ref: @ty::TraitRef) -> Option<vtable_origin> { let tcx = vcx.tcx();...
lookup_vtable_from_bounds
identifier_name
vtable.rs
} } true }); debug!("lookup_vtables_for_param result(\ location_info={:?}, \ type_param_bounds={}, \ ty={}, \ result={})", location_info, type_param_bounds.repr(vcx.tcx()), ty.repr(vcx.tcx()), param_re...
let vtable_opt = match ty::get(ty).sty { ty::ty_param(param_ty {idx: n,..}) => { let type_param_bounds: &[@ty::TraitRef] = vcx.param_env.type_param_bounds[n].trait_bounds; lookup_vtable_from_bounds(vcx, location_info, ...
{ debug!("lookup_vtable(ty={}, trait_ref={})", vcx.infcx.ty_to_str(ty), vcx.infcx.trait_ref_to_str(trait_ref)); let _i = indenter(); let ty = match fixup_ty(vcx, location_info, ty, is_early) { Some(ty) => ty, None => { // fixup_ty can only fail if this is e...
identifier_body
vtable.rs
} } true }); debug!("lookup_vtables_for_param result(\ location_info={:?}, \ type_param_bounds={}, \ ty={}, \ result={})", location_info, type_param_bounds.repr(vcx.tcx()), ty.repr(vcx.tcx()), param_r...
} } } // Look up the vtable implementing the trait `trait_ref` at type `t` fn lookup_vtable(vcx: &VtableContext, location_info: &LocationInfo, ty: ty::t, trait_ref: @ty::TraitRef, is_early: bool) -> Option<vtable_origin> { debug!("...
ppaux::trait_ref_to_str(tcx, &r_exp_trait_ref), ppaux::trait_ref_to_str(tcx, &r_act_trait_ref), ty::type_err_to_str(tcx, err))); }
random_line_split
configrepo.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
{ pub db: Arc<Mutex<rusqlite::Connection>>, } impl ConfigRepo { pub fn new(filename: Option<&PathBuf>) -> Result<Self, ConfigRepoError> { let mut conn = ConnectionBuilder::filename(filename).open()?; init_db(&mut conn)?; Ok(Self { db: Arc::new(Mutex::new(conn)), }) ...
ConfigRepo
identifier_name
configrepo.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
pub fn get_user_by_name(&self, username: &str) -> Result<User, ConfigRepoError> { let conn = self.db.lock().unwrap(); let user = conn .query_row( "SELECT uuid, username FROM users WHERE username =?", params![username], |row| { ...
}) .await? }
random_line_split
configrepo.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
_ => err.into(), })?; Ok(user) } pub fn get_users(&self) -> Result<Vec<User>, ConfigRepoError> { let conn = self.db.lock().unwrap(); let mut stmt = conn.prepare("SELECT uuid, username FROM users")?; let rows = stmt.query_map(params![], |row| { ...
{ ConfigRepoError::NoUser(username.to_string()) }
conditional_block
configrepo.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
} pub fn init_db(db: &mut rusqlite::Connection) -> Result<(), rusqlite::Error> { let version = db .query_row("select max(version) from schema", params![], |row| { let version: i64 = row.get(0).unwrap(); Ok(version) }) .unwrap_or(-1); if version == 1 { // W...
{ let password_hash = bcrypt::hash(password, bcrypt::DEFAULT_COST)?; let mut conn = self.db.lock().unwrap(); let tx = conn.transaction()?; let n = tx.execute( "UPDATE users SET password = ? where uuid = ?", params![password_hash, id], )?; tx.commit...
identifier_body
uct_benchmark.rs
#[macro_use] extern crate criterion; use criterion::{Bencher, Criterion}; use oppai_field::construct_field::construct_field; use oppai_field::field; use oppai_field::player::Player; use oppai_uct::uct::{UcbType, UctConfig, UctKomiType, UctRoot}; use rand::SeedableRng; use rand_xorshift::XorShiftRng;
const SEED: [u8; 16] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]; const UCT_CONFIG: UctConfig = UctConfig { threads_count: 1, radius: 3, ucb_type: UcbType::Ucb1Tuned, draw_weight: 0.4, uctk: 1.0, when_create_children: 2, depth: 8, komi_type: UctKomiType::Dynamic, red: 0.45, green...
random_line_split
uct_benchmark.rs
#[macro_use] extern crate criterion; use criterion::{Bencher, Criterion}; use oppai_field::construct_field::construct_field; use oppai_field::field; use oppai_field::player::Player; use oppai_uct::uct::{UcbType, UctConfig, UctKomiType, UctRoot}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; const SEED: [u8; ...
criterion_main!(uct);
{ let mut c = Criterion::default().sample_size(10).configure_from_args(); c.bench_function("uct", find_best_move); }
identifier_body
uct_benchmark.rs
#[macro_use] extern crate criterion; use criterion::{Bencher, Criterion}; use oppai_field::construct_field::construct_field; use oppai_field::field; use oppai_field::player::Player; use oppai_uct::uct::{UcbType, UctConfig, UctKomiType, UctRoot}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; const SEED: [u8; ...
(bencher: &mut Bencher) { let mut rng = XorShiftRng::from_seed(SEED); let field = construct_field( &mut rng, " ........ ........ ...a.... ..AaA... ...Aaa.. ..A.A... ........ ........ ", ); let length = field::length(field.width(), field.height()); bencher.iter(|| { let ...
find_best_move
identifier_name
fileops.rs
//! Contains operations related to the /dev/ipath character files. extern crate libc; use std::ffi::CString; use libc::c_int; use std::os::unix::io::{RawFd, AsRawFd}; use std::ops::Drop; use std::io::Error; pub struct Fd(RawFd); impl Fd { pub fn open<T: Into<String>>(path: T, mode: c_int) -> Result<Fd, Error> { ...
(&self) -> c_int { unsafe { libc::close(self.0) } } // With F_SETFD we only care if fcntl failed pub fn try_set_flag(&self, flag: c_int ) -> Result<c_int, Error> { match unsafe { libc::fcntl(self.0, libc::F_SETFD, flag) } { -1 => Err(Error::last_os_error()), ret @ _ => Ok(ret) } } } im...
close
identifier_name
fileops.rs
//! Contains operations related to the /dev/ipath character files. extern crate libc; use std::ffi::CString; use libc::c_int; use std::os::unix::io::{RawFd, AsRawFd}; use std::ops::Drop; use std::io::Error; pub struct Fd(RawFd); impl Fd { pub fn open<T: Into<String>>(path: T, mode: c_int) -> Result<Fd, Error> { ...
fn drop(&mut self) { if self.0!= -1 { self.close(); } } } #[test] // Check open/close on a file that should exist in most linux based OS. fn open_close_devnull() { use std::error::Error as std_error; match Fd::open("/dev/null", libc::O_RDONLY) { Err(e) => panic!(e.description().to_owned()), ...
} } impl Drop for Fd { // XXX: Do we need to check result of close?
random_line_split
fileops.rs
//! Contains operations related to the /dev/ipath character files. extern crate libc; use std::ffi::CString; use libc::c_int; use std::os::unix::io::{RawFd, AsRawFd}; use std::ops::Drop; use std::io::Error; pub struct Fd(RawFd); impl Fd { pub fn open<T: Into<String>>(path: T, mode: c_int) -> Result<Fd, Error> { ...
// With F_SETFD we only care if fcntl failed pub fn try_set_flag(&self, flag: c_int ) -> Result<c_int, Error> { match unsafe { libc::fcntl(self.0, libc::F_SETFD, flag) } { -1 => Err(Error::last_os_error()), ret @ _ => Ok(ret) } } } impl AsRawFd for Fd { fn as_raw_fd(&self) -> RawFd { ...
{ unsafe { libc::close(self.0) } }
identifier_body
day08.rs
use std::fs::File; use std::io::BufReader; use std::io::BufRead; fn escape(string: &str) -> String { let mut ret = String::new(); ret.push('"'); for ch in string.chars() { match ch { '"' => ret += "\\\"", '\\' => ret += "\\\\", a => ret.push(a), } } ...
() { let f = File::open("inputs/day08.in").unwrap(); let file = BufReader::new(&f); let (count1, count2) = file.lines(). map(|l| l.unwrap()). map(|l| (l.len(), escape(l.trim()), unescape(l.trim()))). map(|(l, e, u)| (l - u.chars().count(), e.len() - l)). fold((0, 0), |a, b| ...
main
identifier_name
day08.rs
use std::fs::File; use std::io::BufReader; use std::io::BufRead; fn escape(string: &str) -> String
fn unescape(string: &str) -> String { let mut seq = string.chars().skip(1); let mut ret = String::new(); loop { match seq.next() { Some('\\') => { match seq.next() { Some('\\') => ret.push('\\'), Some('"') => ret.push('"'), ...
{ let mut ret = String::new(); ret.push('"'); for ch in string.chars() { match ch { '"' => ret += "\\\"", '\\' => ret += "\\\\", a => ret.push(a), } } ret.push('"'); ret }
identifier_body
day08.rs
use std::fs::File; use std::io::BufReader; use std::io::BufRead; fn escape(string: &str) -> String { let mut ret = String::new(); ret.push('"'); for ch in string.chars() { match ch { '"' => ret += "\\\"", '\\' => ret += "\\\\", a => ret.push(a), } } ...
let (count1, count2) = file.lines(). map(|l| l.unwrap()). map(|l| (l.len(), escape(l.trim()), unescape(l.trim()))). map(|(l, e, u)| (l - u.chars().count(), e.len() - l)). fold((0, 0), |a, b| (a.0+b.0, a.1 + b.1)); println!("1: {}", count1); println!("2: {}", count2); }
random_line_split
generic-impl-more-params-with-defaults.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 ...
<T, A = Heap>( marker::PhantomData<(T,A)>); impl<T, A = Heap> Vec<T, A> { fn new() -> Vec<T, A> {Vec(marker::PhantomData)} } fn main() { Vec::<isize, Heap, bool>::new(); //~^ ERROR too many type parameters provided }
Vec
identifier_name
generic-impl-more-params-with-defaults.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<T, A = Heap> Vec<T, A> { fn new() -> Vec<T, A> {Vec(marker::PhantomData)} } fn main() { Vec::<isize, Heap, bool>::new(); //~^ ERROR too many type parameters provided }
marker::PhantomData<(T,A)>);
random_line_split
generic-impl-more-params-with-defaults.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 ...
} fn main() { Vec::<isize, Heap, bool>::new(); //~^ ERROR too many type parameters provided }
{Vec(marker::PhantomData)}
identifier_body
query_client.rs
use lru::*; use update_client::ThreatDescriptor; use database::*; use errors::*; use gsburl::*; use db_actor::*; use atoms::*; use std::collections::HashMap; use std::thread; use chan; use chan::{Sender, Receiver}; use fibers::{ThreadPoolExecutor, Executor, Spawn}; use futures; // This client will attempt to query ...
(&mut self, url: String, receipt: Sender<Atoms>, this: Sender<Atoms>) { let hashes = generate_hashes(&url).unwrap(); for hash in hashes.keys().cloned() { self.db_actor .send(Atoms::DBQuery { hash_prefix: hash, receipt: this.clone(), ...
query
identifier_name
query_client.rs
use lru::*; use update_client::ThreatDescriptor; use database::*; use errors::*; use gsburl::*; use db_actor::*; use atoms::*; use std::collections::HashMap; use std::thread; use chan; use chan::{Sender, Receiver}; use fibers::{ThreadPoolExecutor, Executor, Spawn}; use futures; // This client will attempt to query ...
Atoms::Query { url, receipt } => client.query(url, receipt, sender), Atoms::DBQueryResponse { hash_prefix: _, result, origin } => { let _ = origin.send(Atoms::QueryResponse { result: result }); } _ => panic!("Unexpec...
let msg = receiver.recv().expect("No one has a name for this QueryClient"); let sender = sender_c.clone(); match msg {
random_line_split
packed-struct-drop-aligned.rs
// Copyright 2017 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 ...
<'a>(u8, Aligned<'a>); fn main() { let drop_count = &Cell::new(0); { let mut p = Packed(0, Aligned { drop_count }); p.1 = Aligned { drop_count }; assert_eq!(drop_count.get(), 1); } assert_eq!(drop_count.get(), 2); }
Packed
identifier_name
packed-struct-drop-aligned.rs
// Copyright 2017 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<'a> Drop for Aligned<'a> { fn drop(&mut self) { check_align(self); self.drop_count.set(self.drop_count.get() + 1); } } #[repr(packed)] struct Packed<'a>(u8, Aligned<'a>); fn main() { let drop_count = &Cell::new(0); { let mut p = Packed(0, Aligned { drop_count }); ...
}
random_line_split
htmllabelelement.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 dom::bindings::codegen::HTMLLabelElementBinding; use dom::bindings::codegen::InheritTypes::HTMLLabelElementDer...
}
~"" } pub fn SetHtmlFor(&mut self, _html_for: DOMString) { }
random_line_split
htmllabelelement.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 dom::bindings::codegen::HTMLLabelElementBinding; use dom::bindings::codegen::InheritTypes::HTMLLabelElementDer...
(&self) -> bool { match self.type_id { NodeTargetTypeId(ElementNodeTypeId(HTMLLabelElementTypeId)) => true, _ => false } } } impl HTMLLabelElement { pub fn new_inherited(localName: DOMString, document: JS<Document>) -> HTMLLabelElement { HTMLLabelElement { ...
is_htmllabelelement
identifier_name
htmllabelelement.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 dom::bindings::codegen::HTMLLabelElementBinding; use dom::bindings::codegen::InheritTypes::HTMLLabelElementDer...
pub fn new(localName: DOMString, document: &JS<Document>) -> JS<HTMLLabelElement> { let element = HTMLLabelElement::new_inherited(localName, document.clone()); Node::reflect_node(~element, document, HTMLLabelElementBinding::Wrap) } } impl HTMLLabelElement { pub fn HtmlFor(&self) -> DOMStr...
{ HTMLLabelElement { htmlelement: HTMLElement::new_inherited(HTMLLabelElementTypeId, localName, document) } }
identifier_body
domparser.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 dom::bindings::codegen::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
<'a>(&'a mut self) -> &'a mut Reflector { &mut self.reflector_ } }
mut_reflector
identifier_name
domparser.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 dom::bindings::codegen::DOMParserBinding;
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml}; use dom::bindings::js::JS; use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object}; use dom::bindings::error::{Fallible, FailureUnknown}; use dom::document::{Document, HTMLDocument, NonHTMLDocument}; use dom::window...
random_line_split
domparser.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 dom::bindings::codegen::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
}
{ &mut self.reflector_ }
identifier_body
filter.rs
// // imag - the personal information management suite for the commandline
// 2.1 of the License. // // This library 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 // Lesser General Public License for more details. // // You should have received a copy of ...
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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; version
random_line_split
lib.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 ...
mod macros; #[path = "num/float_macros.rs"] mod float_macros; #[path = "num/int_macros.rs"] mod int_macros; #[path = "num/uint_macros.rs"] mod uint_macros; #[path = "num/int.rs"] pub mod int; #[path = "num/i8.rs"] pub mod i8; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "nu...
#![no_std] #![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)] #![feature(simd, unsafe_destructor)] #![deny(missing_doc)]
random_line_split