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
data_loader.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 crate::fetch; use headers::{ContentType, HeaderMapExt}; use hyper_serde::Serde; use mime::{self, Mime}; use n...
} } #[test] fn empty_invalid() { assert_parse("data:", None, None, None); } #[test] fn plain() { assert_parse( "data:,hello%20world", Some(ContentType::from( "text/plain; charset=US-ASCII".parse::<Mime>().unwrap(), )), Some("us-ascii"), Some(b"hello worl...
"Decoding data URL failed".to_owned() )) ); },
random_line_split
data_loader.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 crate::fetch; use headers::{ContentType, HeaderMapExt}; use hyper_serde::Serde; use mime::{self, Mime}; use n...
() { assert_parse( "data:text/plain;charset=latin1,hello", Some(ContentType::from( "text/plain; charset=latin1".parse::<Mime>().unwrap(), )), Some("latin1"), Some(b"hello"), ); } #[test] fn plain_only_charset() { assert_parse( "data:;charset=utf-8...
plain_charset
identifier_name
inode_to_pid.rs
use netinfo::{Inode, Pid}; use netinfo::error::*; use std::collections::HashMap; use std::fs::{read_dir, read_link}; use std::str::FromStr; use std::borrow::Borrow; use std::io::ErrorKind as IOErrorKind; /// This struct generates a HashMap from inodes to pid from file descriptors under `/proc/{pid}/fd/`. /// /// Exam...
// update inodes for this pid self.refresh_pid(pid)?; } Ok(()) } /// Returns None if inode was not found pub fn find_pid(&self, inode: Inode) -> Option<Pid> { self.inode_to_pid_map.get(&inode).map(|&x| x) } }
{ self.inode_to_pid_map.clear(); let entries = read_dir("/proc")?; for dir_entry_opt in entries { let dir_entry = dir_entry_opt?; // test whether filename is /proc/{pid} or something else (non-numeric) let os_filename = dir_entry.file_name(); let...
identifier_body
inode_to_pid.rs
use netinfo::{Inode, Pid}; use netinfo::error::*; use std::collections::HashMap; use std::fs::{read_dir, read_link}; use std::str::FromStr; use std::borrow::Borrow; use std::io::ErrorKind as IOErrorKind; /// This struct generates a HashMap from inodes to pid from file descriptors under `/proc/{pid}/fd/`. /// /// Exam...
() -> InodeToPidMap { InodeToPidMap { inode_to_pid_map: HashMap::new() } } fn refresh_pid(&mut self, pid: Pid) -> Result<()> { // read file descriptors /proc/{pid}/fd and ignore PermissionDenied errors let entries = match read_dir(format!("/proc/{}/fd", pid)) { Ok(x) => x, ...
new
identifier_name
inode_to_pid.rs
use netinfo::{Inode, Pid}; use netinfo::error::*; use std::collections::HashMap; use std::fs::{read_dir, read_link}; use std::str::FromStr; use std::borrow::Borrow; use std::io::ErrorKind as IOErrorKind; /// This struct generates a HashMap from inodes to pid from file descriptors under `/proc/{pid}/fd/`. /// /// Exam...
/// Returns None if inode was not found pub fn find_pid(&self, inode: Inode) -> Option<Pid> { self.inode_to_pid_map.get(&inode).map(|&x| x) } }
Ok(()) }
random_line_split
inode_to_pid.rs
use netinfo::{Inode, Pid}; use netinfo::error::*; use std::collections::HashMap; use std::fs::{read_dir, read_link}; use std::str::FromStr; use std::borrow::Borrow; use std::io::ErrorKind as IOErrorKind; /// This struct generates a HashMap from inodes to pid from file descriptors under `/proc/{pid}/fd/`. /// /// Exam...
// get pid as number let pid = Pid::from_str(filename.borrow())?; // update inodes for this pid self.refresh_pid(pid)?; } Ok(()) } /// Returns None if inode was not found pub fn find_pid(&self, inode: Inode) -> Option<Pid> { self.i...
{ continue }
conditional_block
app_usart_stm32l1.rs
#![feature(plugin, no_std, core)] #![crate_type="staticlib"] #![no_std] #![plugin(macro_platformtree)] extern crate core; extern crate zinc; #[no_mangle] pub unsafe fn main() { use zinc::drivers::chario::CharIO; use zinc::hal; use zinc::hal::pin::Gpio; use zinc::hal::stm32l1::{init, pin, usart}; zinc::hal:...
uart.puts("Hello, world\n"); led1.set_high(); loop {} }
led1.set_low(); let uart = usart::Usart::new(usart::UsartPeripheral::Usart2, 38400, usart::WordLen::WordLen8bits, hal::uart::Parity::Disabled, usart::StopBit::StopBit1bit, &sys_clock);
random_line_split
app_usart_stm32l1.rs
#![feature(plugin, no_std, core)] #![crate_type="staticlib"] #![no_std] #![plugin(macro_platformtree)] extern crate core; extern crate zinc; #[no_mangle] pub unsafe fn main()
pin::Mode::GpioOut(pin::OutputType::OutPushPull, pin::Speed::VeryLow), pin::PullType::PullNone); led1.set_low(); let uart = usart::Usart::new(usart::UsartPeripheral::Usart2, 38400, usart::WordLen::WordLen8bits, hal::uart::Parity::Disabled, usart::StopBit::StopBit1bit, &sys_clock); uart.puts("Hello, ...
{ use zinc::drivers::chario::CharIO; use zinc::hal; use zinc::hal::pin::Gpio; use zinc::hal::stm32l1::{init, pin, usart}; zinc::hal::mem_init::init_stack(); zinc::hal::mem_init::init_data(); let sys_clock = init::ClockConfig::new_default(); sys_clock.setup(); let _pin_tx = pin::Pin::new(pin::Port::...
identifier_body
app_usart_stm32l1.rs
#![feature(plugin, no_std, core)] #![crate_type="staticlib"] #![no_std] #![plugin(macro_platformtree)] extern crate core; extern crate zinc; #[no_mangle] pub unsafe fn
() { use zinc::drivers::chario::CharIO; use zinc::hal; use zinc::hal::pin::Gpio; use zinc::hal::stm32l1::{init, pin, usart}; zinc::hal::mem_init::init_stack(); zinc::hal::mem_init::init_data(); let sys_clock = init::ClockConfig::new_default(); sys_clock.setup(); let _pin_tx = pin::Pin::new(pin::Por...
main
identifier_name
cancel_of_async_receive.rs
extern crate asyncio; use std::io; use std::time::Duration; use asyncio::*; use asyncio::ip::*; static mut GOAL_FLAG: bool = false; struct UdpClient { soc: UdpSocket, timer: SteadyTimer, buf: [u8; 256], } impl UdpClient { fn start(ctx: &IoContext) -> io::Result<()> { let soc = try!(UdpSocket...
(mut cl: Strand<Self>) { cl.timer.expires_from_now(Duration::new(1, 0)); cl.timer.async_wait(cl.wrap(Self::on_wait)); cl.soc.async_receive( &mut cl.get().buf, 0, cl.wrap(Self::on_receive), ); } fn on_receive(_: Strand<Self>, res: io::Result<us...
on_start
identifier_name
cancel_of_async_receive.rs
extern crate asyncio; use std::io; use std::time::Duration; use asyncio::*; use asyncio::ip::*; static mut GOAL_FLAG: bool = false; struct UdpClient { soc: UdpSocket, timer: SteadyTimer, buf: [u8; 256], } impl UdpClient { fn start(ctx: &IoContext) -> io::Result<()> { let soc = try!(UdpSocket...
{ let ctx = &IoContext::new().unwrap(); UdpClient::start(ctx).unwrap(); ctx.run(); assert!(unsafe { GOAL_FLAG }) }
identifier_body
cancel_of_async_receive.rs
extern crate asyncio; use std::io; use std::time::Duration; use asyncio::*; use asyncio::ip::*; static mut GOAL_FLAG: bool = false; struct UdpClient { soc: UdpSocket, timer: SteadyTimer, buf: [u8; 256], } impl UdpClient { fn start(ctx: &IoContext) -> io::Result<()> { let soc = try!(UdpSocket...
} } #[test] fn main() { let ctx = &IoContext::new().unwrap(); UdpClient::start(ctx).unwrap(); ctx.run(); assert!(unsafe { GOAL_FLAG }) }
{ panic!("{:?}", res); }
conditional_block
cancel_of_async_receive.rs
extern crate asyncio; use std::io; use std::time::Duration; use asyncio::*; use asyncio::ip::*; static mut GOAL_FLAG: bool = false; struct UdpClient { soc: UdpSocket, timer: SteadyTimer, buf: [u8; 256], } impl UdpClient { fn start(ctx: &IoContext) -> io::Result<()> { let soc = try!(UdpSocket...
} } fn on_wait(mut cl: Strand<Self>, res: io::Result<()>) { if let Ok(_) = res { cl.soc.cancel(); } else { panic!("{:?}", res); } } } #[test] fn main() { let ctx = &IoContext::new().unwrap(); UdpClient::start(ctx).unwrap(); ctx.run(); ...
} } else { panic!("{:?}", res);
random_line_split
projection-one-region-closure.rs
// Copyright 2016 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 ...
// We are projecting `<T as Anything<'b>>::AssocType`, and we know // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); } #[rustc_regions] fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) where T: Anything<'b>, T: 'a, 'b: 'a, { ...
T: Anything<'b>, T::AssocType: 'a, {
random_line_split
projection-one-region-closure.rs
// Copyright 2016 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 ...
#[rustc_regions] fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) where T: Anything<'b>, { with_signature(cell, t, |cell, t| require(cell, t)); //~^ ERROR the parameter type `T` may not live long enough //~| ERROR } #[rustc_regions] fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>...
{ }
identifier_body
projection-one-region-closure.rs
// Copyright 2016 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, 'b, T>(cell: Cell<&'a ()>, t: T) where T: Anything<'b>, 'a: 'a, { with_signature(cell, t, |cell, t| require(cell, t)); //~^ ERROR the parameter type `T` may not live long enough //~| ERROR } #[rustc_regions] fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) where T: Anything<'b>,...
no_relationships_early
identifier_name
main.rs
use std::fs::File; use std::io::{BufRead, BufReader}; const AT: [u8; 256] = { let mut array = [0; 256]; array[b'A' as usize] = 1; array[b'T' as usize] = 1; array }; const GC: [u8; 256] = { let mut array = [0; 256]; array[b'G' as usize] = 1; array[b'C' as usize] = 1; array }; fn main()
for c in line.iter() { at += AT[*c as usize] as usize; gc += GC[*c as usize] as usize; } line.clear(); } let gc_ratio: f64 = gc as f64 / (gc as f64 + at as f64); println!("GC ratio (gc/(gc+at)): {}", gc_ratio); }
{ let filename = "chry_multiplied.fa"; let file = File::open(filename).unwrap(); let mut reader = BufReader::new(file); let mut at = 0; let mut gc = 0; let mut line = Vec::with_capacity(100); loop { match reader.read_until(b'\n', &mut line) { Ok(0) => break, ...
identifier_body
main.rs
use std::fs::File; use std::io::{BufRead, BufReader}; const AT: [u8; 256] = { let mut array = [0; 256]; array[b'A' as usize] = 1; array[b'T' as usize] = 1; array }; const GC: [u8; 256] = { let mut array = [0; 256]; array[b'G' as usize] = 1; array[b'C' as usize] = 1; array }; fn
() { let filename = "chry_multiplied.fa"; let file = File::open(filename).unwrap(); let mut reader = BufReader::new(file); let mut at = 0; let mut gc = 0; let mut line = Vec::with_capacity(100); loop { match reader.read_until(b'\n', &mut line) { Ok(0) => break, ...
main
identifier_name
main.rs
use std::fs::File; use std::io::{BufRead, BufReader}; const AT: [u8; 256] = { let mut array = [0; 256]; array[b'A' as usize] = 1; array[b'T' as usize] = 1; array }; const GC: [u8; 256] = { let mut array = [0; 256]; array[b'G' as usize] = 1; array[b'C' as usize] = 1; array
}; fn main() { let filename = "chry_multiplied.fa"; let file = File::open(filename).unwrap(); let mut reader = BufReader::new(file); let mut at = 0; let mut gc = 0; let mut line = Vec::with_capacity(100); loop { match reader.read_until(b'\n', &mut line) { Ok(0) => break...
random_line_split
layers.rs
// Copyright 2017 Google Inc. All rights reserved. // // 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-2.0 // // Unless required by applicable...
/// Applies `delta`, which is presumed to contain empty spans. /// This is only used when we receive an edit, to adjust current span /// positions. fn blank_scopes(&mut self, delta: &Delta<RopeInfo>) { self.style_spans.apply_shape(delta); self.scope_spans.apply_shape(delta); } ...
{ self.scope_spans.edit(iv, spans.to_owned()); self.update_styles(iv, spans); }
identifier_body
layers.rs
// Copyright 2017 Google Inc. All rights reserved. // // 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-2.0 // // Unless required by applicable...
// apply the stack, generating children as needed. for i in upper_bound_of_last..stack.len() { let style_mod = highlighter.get_style(&stack[0..i+1]); base_style_mod = base_style_mod.apply(style_mod); } let style = Style::from_syntect_styl...
break } } let mut base_style_mod = last_style.unwrap_or_default();
random_line_split
layers.rs
// Copyright 2017 Google Inc. All rights reserved. // // 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-2.0 // // Unless required by applicable...
let mut layer_iter = self.layers.values(); let mut resolved = layer_iter.next().unwrap().style_spans.subseq(iv); for other in layer_iter { let spans = other.style_spans.subseq(iv); assert_eq!(resolved.len(), spans.len()); resolved = resolved.merge(&spans, |a...
{ return }
conditional_block
layers.rs
// Copyright 2017 Google Inc. All rights reserved. // // 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-2.0 // // Unless required by applicable...
{ layers: BTreeMap<PluginPid, ScopeLayer>, deleted: HashSet<PluginPid>, merged: Spans<Style>, } /// A collection of scope spans from a single source. pub struct ScopeLayer { stack_lookup: Vec<Vec<Scope>>, style_lookup: Vec<Style>, // TODO: this might be efficient (in memory at least) if we use...
Layers
identifier_name
lib.rs
// Copyright 2020 The Exonum Team // // 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-2.0 // // Unless required by applicable law or agreed to i...
) -> Result<(), ExecutionError> { // Initialize indexes. Not doing this may lead to errors in HTTP API, since it relies on // `wallets` indexes being initialized for returning corresponding proofs. SchemaImpl::new(context.service_data()); Ok(()) } fn wire_api(&self, builder:...
_params: Vec<u8>,
random_line_split
lib.rs
// Copyright 2020 The Exonum Team // // 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-2.0 // // Unless required by applicable law or agreed to i...
fn wire_api(&self, builder: &mut ServiceApiBuilder) { CryptocurrencyApi::wire(builder); } } /// Use predefined instance name and id for frontend. impl DefaultInstance for CryptocurrencyService { const INSTANCE_ID: InstanceId = 3; const INSTANCE_NAME: &'static str = "crypto"; }
{ // Initialize indexes. Not doing this may lead to errors in HTTP API, since it relies on // `wallets` indexes being initialized for returning corresponding proofs. SchemaImpl::new(context.service_data()); Ok(()) }
identifier_body
lib.rs
// Copyright 2020 The Exonum Team // // 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-2.0 // // Unless required by applicable law or agreed to i...
; impl Service for CryptocurrencyService { fn initialize( &self, context: ExecutionContext<'_>, _params: Vec<u8>, ) -> Result<(), ExecutionError> { // Initialize indexes. Not doing this may lead to errors in HTTP API, since it relies on // `wallets` indexes being initial...
CryptocurrencyService
identifier_name
zero-size-type-destructors.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 ...
() { foo(); assert!((unsafe { destructions } == 0)); }
main
identifier_name
zero-size-type-destructors.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 ...
pub fn main() { foo(); assert!((unsafe { destructions } == 0)); }
{ #[unsafe_no_drop_flag] struct Foo; impl Drop for Foo { fn drop(&mut self) { unsafe { destructions -= 1 }; } }; let _x = [Foo, Foo, Foo]; }
identifier_body
zero-size-type-destructors.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
static mut destructions : int = 3; pub fn foo() { #[unsafe_no_drop_flag] struct Foo; impl Drop for Foo { fn drop(&mut self) { unsafe { destructions -= 1 }; } }; let _x = [Foo, Foo, Foo]; } pub fn main() { foo(); assert!((unsafe { destructions } == 0)); }
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
garbage_collector.rs
/* Copyright 2017 Jinjing Wang This file is part of mtcp. mtcp 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. mtcp is distributed in the...
( state: Arc<Mutex<State>>, ) { loop { match state.lock() { Ok(mut state) => { if state.pending_stop { break; } let ref mut tcbs = state.tcbs; // debug!("performing GC: {:#?}", *tcbs); ...
garbage_collection
identifier_name
garbage_collector.rs
/* Copyright 2017 Jinjing Wang This file is part of mtcp. mtcp 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. mtcp is distributed in the...
pub fn garbage_collection ( state: Arc<Mutex<State>>, ) { loop { match state.lock() { Ok(mut state) => { if state.pending_stop { break; } let ref mut tcbs = state.tcbs; // debug!("performing GC...
random_line_split
garbage_collector.rs
/* Copyright 2017 Jinjing Wang This file is part of mtcp. mtcp 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. mtcp is distributed in the...
closed_keys.push(k.clone()); } TCP_State::TimeWait(state) => { if now_utc() - state.timestamp > Duration::seconds(30) { closed_keys.push(k.clone()); } ...
{ loop { match state.lock() { Ok(mut state) => { if state.pending_stop { break; } let ref mut tcbs = state.tcbs; // debug!("performing GC: {:#?}", *tcbs); debug!("performing GC: {}", tcbs.len()...
identifier_body
garbage_collector.rs
/* Copyright 2017 Jinjing Wang This file is part of mtcp. mtcp 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. mtcp is distributed in the...
} sleep(std::time::Duration::from_secs(10)); } }
{ debug!("GC died: {:#?}", err); break; }
conditional_block
client.rs
extern crate piston_window; extern crate rustc_serialize; use rustc_serialize::json; use std::env; use std::io; use std::net::UdpSocket; use std::str; use piston_window::*; mod game; use game::*; impl Snake { fn draw<G>(&self, transform: math::Matrix2d, g: &mut G) where G: Graphics { for rect in self.to...
socket.send("start".as_bytes()).unwrap(); // Graphics loop let mut window: PistonWindow = WindowSettings::new("Culebra!", [1000, 1000]) .exit_on_esc(true).build().unwrap(); let mut gs = GameState::new(); let mut events = window.events(); let mut oneSecondPingTimer = 0.0; ...
{ // Read server IP address from command line let mut ip_addr: String = "127.0.0.1".to_string(); let mut args = env::args(); if args.len() >= 2 { args.next(); if let Some(ip) = args.next() { ip_addr = String::from(ip); } } //println!("{}", ip_addr); //...
identifier_body
client.rs
extern crate piston_window; extern crate rustc_serialize; use rustc_serialize::json; use std::env; use std::io; use std::net::UdpSocket; use std::str; use piston_window::*; mod game; use game::*; impl Snake { fn draw<G>(&self, transform: math::Matrix2d, g: &mut G) where G: Graphics { for rect in self.to...
oneSecondPingTimer = 0.0; } } // Listen to keystrokes and send movement intention to server if let Some(Button::Keyboard(key)) = e.press_args() { if let Some(dir) = match key { Key::Up => Some("Up"), Key::Down => Some("Down...
oneSecondPingTimer += u.dt; if oneSecondPingTimer >= 1.0 { //println!("{:?}", oneSecondPingTimer); socket.send("ping".as_bytes()).unwrap();
random_line_split
client.rs
extern crate piston_window; extern crate rustc_serialize; use rustc_serialize::json; use std::env; use std::io; use std::net::UdpSocket; use std::str; use piston_window::*; mod game; use game::*; impl Snake { fn draw<G>(&self, transform: math::Matrix2d, g: &mut G) where G: Graphics { for rect in self.to...
(socket: &UdpSocket) -> Option<GameState> { let mut recv_buf: [u8; 4096] = [0; 4096]; match socket.recv(&mut recv_buf) { Ok(bytes_read) => { let msg = str::from_utf8(&recv_buf[0.. bytes_read]).unwrap(); //println!("received {:?} bytes: {}", bytes_read, msg); if msg....
receive_game_state_from_server
identifier_name
client.rs
extern crate piston_window; extern crate rustc_serialize; use rustc_serialize::json; use std::env; use std::io; use std::net::UdpSocket; use std::str; use piston_window::*; mod game; use game::*; impl Snake { fn draw<G>(&self, transform: math::Matrix2d, g: &mut G) where G: Graphics { for rect in self.to...
} // Listen to keystrokes and send movement intention to server if let Some(Button::Keyboard(key)) = e.press_args() { if let Some(dir) = match key { Key::Up => Some("Up"), Key::Down => Some("Down"), Key::Left => Some("Left"), ...
{ //println!("{:?}", oneSecondPingTimer); socket.send("ping".as_bytes()).unwrap(); oneSecondPingTimer = 0.0; }
conditional_block
build.rs
use std::io::prelude::*; use std::fs::File; use std::path::Path; extern crate toml; #[macro_use] extern crate serde_derive; // error in rust compiler. Bugfix requested in Sept. 2017 // these are used, but the compiler is not seeing it for // some reason #[allow(unused_imports)] #[macro_use] extern crate serde_json;...
use std::env; use std::fs;
random_line_split
build.rs
use std::env; use std::fs; use std::io::prelude::*; use std::fs::File; use std::path::Path; extern crate toml; #[macro_use] extern crate serde_derive; // error in rust compiler. Bugfix requested in Sept. 2017 // these are used, but the compiler is not seeing it for // some reason #[allow(unused_imports)] #[macro_us...
; } // Gets the revision number from the Cargo.toml file. pub fn get_revision() -> Option<String> { let dir = match env::var("CARGO_MANIFEST_DIR"){ Ok(d) => d, Err(_) => panic!("Couldn't Manifest Directory"), }; let filename = "Cargo.toml"; let p = format!("{}/{}",dir,filename); l...
{ panic!("Error creating version_constants.rs: {}", e); }
conditional_block
build.rs
use std::env; use std::fs; use std::io::prelude::*; use std::fs::File; use std::path::Path; extern crate toml; #[macro_use] extern crate serde_derive; // error in rust compiler. Bugfix requested in Sept. 2017 // these are used, but the compiler is not seeing it for // some reason #[allow(unused_imports)] #[macro_us...
() { let target = env::var("TARGET").unwrap(); println!("target={}", target); if let Ok(_mode) = env::var("LIBINDY_STATIC") { let libindy_lib_path = env::var("LIBINDY_DIR").unwrap(); println!("cargo:rustc-link-search=native={}",libindy_lib_path); println!("cargo:rustc-link-lib=stati...
main
identifier_name
expr-fn.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 ...
fn f<T>(t: T) -> T { t } assert_eq!(f(10), 10); } fn test_alt() { fn f() -> int { match true { false => { 10 } true => { 20 } } } assert_eq!(f(), 20); } fn test_if() { fn f() -> int { if true { 10 } else { 20 } } assert_eq!(f(), 10); } fn test_block() { fn f() -> int { { 10 } } assert...
fn test_generic() {
random_line_split
expr-fn.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 ...
fn test_generic() { fn f<T>(t: T) -> T { t } assert_eq!(f(10), 10); } fn test_alt() { fn f() -> int { match true { false => { 10 } true => { 20 } } } assert_eq!(f(), 20); } fn test_if() { fn f() -> int { if true { 10 } else { 20 } } assert_eq!(f(), 10); } fn test_block() { fn f() -> int...
{ fn f() -> Vec<int> { vec!(10, 11) } let vect = f(); assert_eq!(*vect.get(1), 11); }
identifier_body
expr-fn.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 ...
else { 20 } } assert_eq!(f(), 10); } fn test_block() { fn f() -> int { { 10 } } assert_eq!(f(), 10); } fn test_ret() { fn f() -> int { return 10 // no semi } assert_eq!(f(), 10); } // From issue #372 fn test_372() { fn f() -> int { let x = { 3 }; x } assert_eq!(f(), 3); } ...
{ 10 }
conditional_block
expr-fn.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 ...
() -> Vec<int> { vec!(10, 11) } let vect = f(); assert_eq!(*vect.get(1), 11); } fn test_generic() { fn f<T>(t: T) -> T { t } assert_eq!(f(10), 10); } fn test_alt() { fn f() -> int { match true { false => { 10 } true => { 20 } } } assert_eq!(f(), 20); } fn test_if() { fn f() -> int { if tr...
f
identifier_name
test_dir.rs
extern crate nix; extern crate tempfile; use nix::dir::{Dir, Type}; use nix::fcntl::OFlag; use nix::sys::stat::Mode; use std::fs::File; use self::tempfile::tempdir; #[test] fn read() { let tmp = tempdir().unwrap(); File::create(&tmp.path().join("foo")).unwrap(); ::std::os::unix::fs::symlink("foo", tmp.pat...
{ assert_eq!(Dir::from_fd(-1).unwrap_err(), nix::Error::Sys(nix::errno::Errno::EBADF)); }
identifier_body
test_dir.rs
extern crate nix; extern crate tempfile; use nix::dir::{Dir, Type}; use nix::fcntl::OFlag; use nix::sys::stat::Mode; use std::fs::File; use self::tempfile::tempdir; #[test] fn read() { let tmp = tempdir().unwrap(); File::create(&tmp.path().join("foo")).unwrap(); ::std::os::unix::fs::symlink("foo", tmp.pat...
let tmp = tempdir().unwrap(); let mut dir = Dir::open(tmp.path(), OFlag::O_DIRECTORY | OFlag::O_RDONLY | OFlag::O_CLOEXEC, Mode::empty()).unwrap(); let entries1: Vec<_> = dir.iter().map(|e| e.unwrap().file_name().to_owned()).collect(); let entries2: Vec<_> = dir.iter().map(|e...
random_line_split
test_dir.rs
extern crate nix; extern crate tempfile; use nix::dir::{Dir, Type}; use nix::fcntl::OFlag; use nix::sys::stat::Mode; use std::fs::File; use self::tempfile::tempdir; #[test] fn read() { let tmp = tempdir().unwrap(); File::create(&tmp.path().join("foo")).unwrap(); ::std::os::unix::fs::symlink("foo", tmp.pat...
() { assert_eq!(Dir::from_fd(-1).unwrap_err(), nix::Error::Sys(nix::errno::Errno::EBADF)); }
ebadf
identifier_name
media_queries.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/. */ //! Servo's media-query device and expression representation. use app_units::Au; use context::QuirksMode; use css...
(pub ExpressionKind); impl Expression { /// The kind of expression we're, just for unit testing. /// /// Eventually this will become servo-only. pub fn kind_for_testing(&self) -> &ExpressionKind { &self.0 } /// Parse a media expression of the form: /// /// ``` /// (media-fe...
Expression
identifier_name
media_queries.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/. */ //! Servo's media-query device and expression representation. use app_units::Au; use context::QuirksMode; use css...
/// https://quirks.spec.whatwg.org/#the-tables-inherit-color-from-body-quirk pub fn set_body_text_color(&self, _color: RGBA) { // Servo doesn't implement this quirk (yet) } /// Returns whether we ever looked up the root font size of the Device. pub fn used_root_font_size(&self) -> bool { ...
/// Sets the body text color for the "inherit color from body" quirk. ///
random_line_split
media_queries.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/. */ //! Servo's media-query device and expression representation. use app_units::Au; use context::QuirksMode; use css...
} /// A expression kind servo understands and parses. /// /// Only `pub` for unit testing, please don't use it directly! #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum ExpressionKind { /// http://dev.w3.org/csswg/mediaqueries-3/#width Width(Range<specified::Leng...
{ RGBA::new(255, 255, 255, 255) }
identifier_body
lib.rs
#[macro_use] extern crate nom; use std::fs::File; use std::io::prelude::*; named!(take_until_break<&str, &str>, take_until!("//")); named!(take_until_subj<&str, &str>, take_until!("SUBJ/")); pub fn open(filename: &str) -> String { let mut f = File::open(filename).expect("File not found"); let mut contents = ...
tag!("SUBJ") >> ws!(alt!(tag!("/") | tag!(":"))) >> subject: take_until_break >> (subject) )); match parse(contents) { Ok(i) => &i.1, Err(_) => "UNKNOWN", } } #[cfg(test)] mod tests { use super::*; #[test] fn can_open_files() { assert_eq!(o...
random_line_split
lib.rs
#[macro_use] extern crate nom; use std::fs::File; use std::io::prelude::*; named!(take_until_break<&str, &str>, take_until!("//")); named!(take_until_subj<&str, &str>, take_until!("SUBJ/")); pub fn open(filename: &str) -> String { let mut f = File::open(filename).expect("File not found"); let mut contents = ...
(contents: &str) -> &str { named!(parse<&str, &str>, do_parse!( take_until!("SUBJ") >> tag!("SUBJ") >> ws!(alt!(tag!("/") | tag!(":"))) >> subject: take_until_break >> (subject) )); match parse(contents) { Ok(i) => &i.1, Err(_) => "UNKNOWN", } } #[...
get_subject
identifier_name
bot_benches.rs
use std::time::Duration; use criterion::{Criterion,black_box,Bencher,Fun}; use lazy_static; use pleco::Board; use pleco::bot_prelude::*; use pleco::tools::Searcher; lazy_static! { pub static ref RAND_BOARDS: Vec<Board> = { let mut vec = Vec::new(); vec.push(Board::start_pos()); vec };...
criterion_group!(name = bot_benches; config = Criterion::default().sample_size(11).warm_up_time(Duration::from_millis(100)); targets = bench_all_searchers_4_ply );
{ lazy_static::initialize(&RAND_BOARDS); let minimax = Fun::new("MiniMax",bench_searcher::<MiniMaxSearcher>); let parallel_minimax = Fun::new("ParallelMiniMax",bench_searcher::<ParallelMiniMaxSearcher>); let alpha_beta = Fun::new("AlphaBeta",bench_searcher::<AlphaBetaSearcher>); let jamboree = Fun::...
identifier_body
bot_benches.rs
use std::time::Duration; use criterion::{Criterion,black_box,Bencher,Fun}; use lazy_static; use pleco::Board; use pleco::bot_prelude::*; use pleco::tools::Searcher; lazy_static! { pub static ref RAND_BOARDS: Vec<Board> = { let mut vec = Vec::new(); vec.push(Board::start_pos()); vec };...
<S: Searcher>(b: &mut Bencher, data: &(&Vec<Board>, u16)) { b.iter(|| { for board in data.0.iter() { black_box(S::best_move(board.shallow_clone(), data.1)); } }) } fn bench_all_searchers_4_ply(c: &mut Criterion) { lazy_static::initialize(&RAND_BOARDS); let minimax = Fun::new...
bench_searcher
identifier_name
bot_benches.rs
use std::time::Duration; use criterion::{Criterion,black_box,Bencher,Fun}; use lazy_static; use pleco::Board; use pleco::bot_prelude::*; use pleco::tools::Searcher;
let mut vec = Vec::new(); vec.push(Board::start_pos()); vec }; } fn bench_searcher<S: Searcher>(b: &mut Bencher, data: &(&Vec<Board>, u16)) { b.iter(|| { for board in data.0.iter() { black_box(S::best_move(board.shallow_clone(), data.1)); } }) } fn benc...
lazy_static! { pub static ref RAND_BOARDS: Vec<Board> = {
random_line_split
redox.rs
use super::syscall; pub const SYS_DEBUG: usize = 0; pub const SYS_ALLOC: usize = 1000; pub const SYS_REALLOC: usize = 1001; pub const SYS_REALLOC_INPLACE: usize = 1002; pub const SYS_UNALLOC: usize = 1003; #[no_mangle] pub unsafe fn sys_debug(ptr: *const u8, len: usize) -> usize { syscall(SYS_DEBUG, ptr as usize...
(size: usize) -> usize { syscall(SYS_ALLOC, size, 0, 0) } #[no_mangle] pub unsafe fn sys_realloc(ptr: usize, size: usize) -> usize { syscall(SYS_REALLOC, ptr, size, 0) } #[no_mangle] pub unsafe fn sys_realloc_inplace(ptr: usize, size: usize) -> usize { syscall(SYS_REALLOC_INPLACE, ptr, size, 0) } #[no_ma...
sys_alloc
identifier_name
redox.rs
use super::syscall; pub const SYS_DEBUG: usize = 0; pub const SYS_ALLOC: usize = 1000; pub const SYS_REALLOC: usize = 1001; pub const SYS_REALLOC_INPLACE: usize = 1002; pub const SYS_UNALLOC: usize = 1003; #[no_mangle] pub unsafe fn sys_debug(ptr: *const u8, len: usize) -> usize
#[no_mangle] pub unsafe fn sys_alloc(size: usize) -> usize { syscall(SYS_ALLOC, size, 0, 0) } #[no_mangle] pub unsafe fn sys_realloc(ptr: usize, size: usize) -> usize { syscall(SYS_REALLOC, ptr, size, 0) } #[no_mangle] pub unsafe fn sys_realloc_inplace(ptr: usize, size: usize) -> usize { syscall(SYS_REA...
{ syscall(SYS_DEBUG, ptr as usize, len, 0) }
identifier_body
redox.rs
use super::syscall; pub const SYS_DEBUG: usize = 0; pub const SYS_ALLOC: usize = 1000;
pub const SYS_REALLOC_INPLACE: usize = 1002; pub const SYS_UNALLOC: usize = 1003; #[no_mangle] pub unsafe fn sys_debug(ptr: *const u8, len: usize) -> usize { syscall(SYS_DEBUG, ptr as usize, len, 0) } #[no_mangle] pub unsafe fn sys_alloc(size: usize) -> usize { syscall(SYS_ALLOC, size, 0, 0) } #[no_mangle] p...
pub const SYS_REALLOC: usize = 1001;
random_line_split
base64.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 ...
(&self) -> ~str { let mut s = ~""; unsafe { let len = self.len(); str::reserve(&mut s, ((len + 3u) / 4u) * 3u); let mut i = 0u; while i < len - (len % 3u) { let n = (self[i] as uint) << 16u | (self[i + 1u] as uint)...
to_base64
identifier_name
base64.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 ...
} // Heh, would be cool if we knew this was exhaustive // (the dream of bounded integer types) match len % 3 { 0 => (), 1 => { let n = (self[i] as uint) << 16u; str::push_char(&mut s, CHARS[(n >> 18u) & 63u]); ...
{ let mut s = ~""; unsafe { let len = self.len(); str::reserve(&mut s, ((len + 3u) / 4u) * 3u); let mut i = 0u; while i < len - (len % 3u) { let n = (self[i] as uint) << 16u | (self[i + 1u] as uint) << 8u | ...
identifier_body
base64.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 ...
fn to_base64(&self) -> ~str { let mut s = ~""; unsafe { let len = self.len(); str::reserve(&mut s, ((len + 3u) / 4u) * 3u); let mut i = 0u; while i < len - (len % 3u) { let n = (self[i] as uint) << 16u | (self[...
impl<'self> ToBase64 for &'self [u8] {
random_line_split
backtrace.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 ...
rest = &rest[$pat.len()..]; } else)* { try!(writer.write_all(rest.as_bytes())); break; } }) }...
try!(writer.write_all($demangled));
random_line_split
backtrace.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 ...
if valid { let mut chars = inner.chars(); while valid { let mut i = 0; for c in chars.by_ref() { if c.is_numeric() { i = i * 10 + c as uint - '0' as uint; } else { break } } ...
{ valid = false; }
conditional_block
backtrace.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 ...
if c.is_numeric() { i = i * 10 + c as uint - '0' as uint; } else { break } } if i == 0 { valid = chars.next().is_none(); break } else if chars.by_ref().take(i - 1)....
{ // First validate the symbol. If it doesn't look like anything we're // expecting, we just print it literally. Note that we must handle non-rust // symbols because we could have any function in the backtrace. let mut valid = true; let mut inner = s; if s.len() > 4 && s.starts_with("_ZN") && s....
identifier_body
backtrace.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 ...
(writer: &mut Write, s: &str) -> io::Result<()> { // First validate the symbol. If it doesn't look like anything we're // expecting, we just print it literally. Note that we must handle non-rust // symbols because we could have any function in the backtrace. let mut valid = true; let mut inner = s; ...
demangle
identifier_name
mod.rs
mod cgb; mod palette; mod registers; mod tile; use std::cmp; use crate::cpu::CycleType; use crate::irq::{Interrupt, IrqHandler}; use crate::memory::Memory; use self::palette::PaletteClassic; use self::registers::{LcdControl, LcdControllerStatus}; use self::tile::Tile; use self::GpuMode::*; /// The width of the Game...
let x_start = cmp::max(self.window_x as i32 - 7, 0) as usize; for x in x_start..SCREEN_W { let window_x = (self.scroll_x as usize + x) % BACKGROUND_WIDTH; let window_y = (self.scroll_y as usize + y) % BACKGROUND_HEIGHT; let tile = self.get_tile( ...
{ let palette_data = self.bg_palette.data(); // background line if LcdControl::BgDisplayEnable.is_set(self.lcd_control) { for x in 0..SCREEN_W { let background_x = (self.scroll_x as usize + x) % BACKGROUND_WIDTH; let background_y = (self.scroll_y as us...
identifier_body
mod.rs
mod cgb; mod palette; mod registers; mod tile; use std::cmp; use crate::cpu::CycleType; use crate::irq::{Interrupt, IrqHandler}; use crate::memory::Memory; use self::palette::PaletteClassic; use self::registers::{LcdControl, LcdControllerStatus}; use self::tile::Tile; use self::GpuMode::*; /// The width of the Game...
match a { 0x8000..=0x97FF => { // tileset let addr = a - 0x8000; let tile_index = addr / 16; let data_index = addr % 16; debug_assert!(tile_index < 384); self.tileset[tile_index].raw_byte(data_index) ...
{ let data = self.cgb_data.as_ref().unwrap(); match a { r::VRAM_BANK => return data.vram_bank_selector, r::BGP_INDEX => return data.bg_palette_index.raw_value(), r::BGP_DATA => return data.get_bg_color(), r::OBP_INDEX => return data...
conditional_block
mod.rs
mod cgb; mod palette; mod registers; mod tile; use std::cmp; use crate::cpu::CycleType; use crate::irq::{Interrupt, IrqHandler}; use crate::memory::Memory; use self::palette::PaletteClassic; use self::registers::{LcdControl, LcdControllerStatus}; use self::tile::Tile; use self::GpuMode::*; /// The width of the Game...
if self.cgb_mode { let data = self.cgb_data.as_ref().unwrap(); match a { r::VRAM_BANK => return data.vram_bank_selector, r::BGP_INDEX => return data.bg_palette_index.raw_value(), r::BGP_DATA => return data.get_bg_color(), r...
let a = address as usize;
random_line_split
mod.rs
mod cgb; mod palette; mod registers; mod tile; use std::cmp; use crate::cpu::CycleType; use crate::irq::{Interrupt, IrqHandler}; use crate::memory::Memory; use self::palette::PaletteClassic; use self::registers::{LcdControl, LcdControllerStatus}; use self::tile::Tile; use self::GpuMode::*; /// The width of the Game...
(&self) -> Vec<RGB> { self.frame_buffer.to_vec() } } impl Memory for Gpu { fn read_byte(&mut self, address: u16) -> u8 { use self::cgb::regs as r; use self::registers::*; let a = address as usize; if self.cgb_mode { let data = self.cgb_data.as_ref().unwrap(...
screen_data
identifier_name
filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
* 02110-1301, USA. */ extern crate libc; use std::ptr; use libc::{c_void}; use log::*; use core::*; pub struct File; #[repr(C)] #[derive(Debug)] pub struct FileContainer { head: * mut c_void, tail: * mut c_void, } impl FileContainer { pub fn default() -> FileContainer { FileContainer { head:pt...
* version 2 along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
random_line_split
filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
(&mut self) { SCLogDebug!("FILECONTAINER: pruning"); match unsafe {SC} { None => panic!("BUG no suricata_config"), Some(c) => { (c.FilePrune)(&self); } } } pub fn file_set_txid_on_last_file(&mut self, tx_id: u64) { match unsafe...
files_prune
identifier_name
filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
match unsafe {SC} { None => panic!("BUG no suricata_config"), Some(c) => { let res = match is_gap { false => { SCLogDebug!("appending file data"); let r = (c.FileAppendData)(&self, *track_id, ...
{ return 0 }
conditional_block
filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
pub fn file_open(&mut self, cfg: &'static SuricataFileContext, track_id: &u32, name: &[u8], flags: u16) -> i32 { match unsafe {SC} { None => panic!("BUG no suricata_config"), Some(c) => { SCLogDebug!("FILE {:p} OPEN flags {:04X}", &self, flags); let...
{ SCLogDebug!("freeing self"); match unsafe {SC} { None => panic!("BUG no suricata_config"), Some(c) => { (c.FileContainerRecycle)(&self); }, } }
identifier_body
util.rs
// Copyright (c) 2014, 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, modifi...
() -> Vec<NetworkInterface> { use std::ffi::c_str_to_bytes; use std::str::from_utf8; use bindings::winpcap; let mut adapters_size = 0u32; unsafe { let mut tmp: winpcap::IP_ADAPTER_INFO = mem::zeroed(); // FIXME [windows] This only gets IPv4 addresses - should use GetAdaptersAddres...
get_network_interfaces_impl
identifier_name
util.rs
// Copyright (c) 2014, 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, modifi...
vec }
random_line_split
task.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 ...
} #[cfg(test)] mod test { use super::*; use prelude::*; use task; #[test] fn local_heap() { let a = @5; let b = a; assert!(*a == 5); assert!(*b == 5); } #[test] fn tls() { use local_data; local_data_key!(key: @~str) local_data::...
{ // make this type noncopyable }
identifier_body
task.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 ...
(self) -> Option<~Task> { match self { Owned(task) => Some(task), Shared(arc) => unsafe { match (*arc.get()).swap(0, SeqCst) { 0 => None, n => Some(cast::transmute(n)), } } } } // This as...
wake
identifier_name
task.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 ...
} } /// Convert from an unsafe uint value. Useful for retrieving a pipe's state /// flag. #[inline] pub unsafe fn cast_from_uint(blocked_task_ptr: uint) -> BlockedTask { if blocked_task_ptr & 0x1 == 0 { Owned(cast::transmute(blocked_task_ptr)) } else { ...
{ let blocked_task_ptr: uint = cast::transmute(~arc); rtassert!(blocked_task_ptr & 0x1 == 0); blocked_task_ptr | 0x1 }
conditional_block
task.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 ...
use ops::Drop; use option::{Option, Some, None}; use prelude::drop; use result::{Result, Ok, Err}; use rt::Runtime; use rt::borrowck::BorrowRecord; use rt::borrowck; use rt::local::Local; use rt::local_heap::LocalHeap; use rt::rtio::LocalIo; use rt::unwind::Unwinder; use send_str::SendStr; use sync::arc::UnsafeArc; use...
use iter::{Iterator, Take}; use local_data; use logging::Logger;
random_line_split
mipsel_unknown_linux_gnu.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 ...
target_word_size: "32".to_string(), arch: "mips".to_string(), target_os: "linux".to_string(), options: super::linux_base::opts() } }
-f32:32:32-f64:64:64\ -v64:64:64-v128:64:128\ -a0:0:64-n32".to_string(), llvm_target: "mipsel-unknown-linux-gnu".to_string(), target_endian: "little".to_string(),
random_line_split
mipsel_unknown_linux_gnu.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 ...
{ Target { data_layout: "e-p:32:32:32\ -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\ -f32:32:32-f64:64:64\ -v64:64:64-v128:64:128\ -a0:0:64-n32".to_string(), llvm_target: "mipsel-unknown-linux-gnu".to_string(), ...
identifier_body
mipsel_unknown_linux_gnu.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 ...
() -> Target { Target { data_layout: "e-p:32:32:32\ -i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\ -f32:32:32-f64:64:64\ -v64:64:64-v128:64:128\ -a0:0:64-n32".to_string(), llvm_target: "mipsel-unknown-linux-gnu".t...
target
identifier_name
issue-46023.rs
// Copyright 2016 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
issue-46023.rs
// Copyright 2016 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 x = 0; (move || { x = 1; //[mir]~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] //[ast]~^^ ERROR cannot assign to captured outer variable in an `FnMut` closure [E0594] })() }
identifier_body
issue-46023.rs
// Copyright 2016 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 x = 0; (move || { x = 1; //[mir]~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] //[ast]~^^ ERROR cannot assign to captured outer variable in an `FnMut` closure [E0594] })() }
main
identifier_name
util.rs
// Small functions of utility use core::SearchType::{self, ExactMatch, StartsWith}; use core::Session; use std; use std::cmp; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub fn getline(filepath: &Path, linenum: usize, session: &Session) -> String { let reader = BufReader::new(sessio...
() { assert_eq!(5, find_ident_end("ident", 0)); assert_eq!(6, find_ident_end("(ident)", 1)); assert_eq!(17, find_ident_end("let an_identifier = 100;", 4)); } #[test] fn find_ident_end_unicode() { assert_eq!(7, find_ident_end("num_µs", 0)); assert_eq!(10, find_ident_end("ends_in_µ", 0)); } // PD: s...
find_ident_end_ascii
identifier_name
util.rs
// Small functions of utility use core::SearchType::{self, ExactMatch, StartsWith}; use core::Session; use std; use std::cmp; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub fn getline(filepath: &Path, linenum: usize, session: &Session) -> String { let reader = BufReader::new(sessio...
// PD: short term replacement for path.exists() (PathExt trait). Replace once // that stabilizes pub fn path_exists<P: AsRef<Path>>(path: P) -> bool { is_dir(&path) || File::open(path).is_ok() } // PD: short term replacement for path.is_dir() (PathExt trait). Replace once // that stabilizes pub fn is_dir<P: AsRef<...
src[i..].chars().next().unwrap() }
identifier_body
util.rs
// Small functions of utility use core::SearchType::{self, ExactMatch, StartsWith}; use core::Session; use std; use std::cmp; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub fn getline(filepath: &Path, linenum: usize, session: &Session) -> String { let reader = BufReader::new(sessio...
pub fn is_search_expr_char(c: char) -> bool { c.is_alphanumeric() || (c == '_') || (c == ':') || (c == '.') } pub fn is_ident_char(c: char) -> bool { c.is_alphanumeric() || (c == '_') } pub fn txt_matches(stype: SearchType, needle: &str, haystack: &str) -> bool { match stype { ExactMatch => { ...
} pub fn is_pattern_char(c: char) -> bool { c.is_alphanumeric() || c.is_whitespace() || (c == '_') || (c == ':') || (c == '.') }
random_line_split
util.rs
// Small functions of utility use core::SearchType::{self, ExactMatch, StartsWith}; use core::Session; use std; use std::cmp; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; pub fn getline(filepath: &Path, linenum: usize, session: &Session) -> String { let reader = BufReader::new(sessio...
} s.len() } #[test] fn find_ident_end_ascii() { assert_eq!(5, find_ident_end("ident", 0)); assert_eq!(6, find_ident_end("(ident)", 1)); assert_eq!(17, find_ident_end("let an_identifier = 100;", 4)); } #[test] fn find_ident_end_unicode() { assert_eq!(7, find_ident_end("num_µs", 0)); assert...
{ return pos + i; }
conditional_block
new-box.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 ...
(&self) { println!("hello world!"); } } fn g(x: Box<Trait>) { x.printme(); let y: &Trait = &*x; y.printme(); } fn main() { f(box 1234); g(box Struct as Box<Trait>); }
printme
identifier_name
new-box.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 ...
x.printme(); let y: &Trait = &*x; y.printme(); } fn main() { f(box 1234); g(box Struct as Box<Trait>); }
fn g(x: Box<Trait>) {
random_line_split
new-box.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 ...
trait Trait { fn printme(&self); } struct Struct; impl Trait for Struct { fn printme(&self) { println!("hello world!"); } } fn g(x: Box<Trait>) { x.printme(); let y: &Trait = &*x; y.printme(); } fn main() { f(box 1234); g(box Struct as Box<Trait>); }
{ let y: &int = &*x; println!("{}", *x); println!("{}", *y); }
identifier_body
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS ...
input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule( "-moz-document".into(), )), ); } Ok(condition) } /// Evaluate a document condition. pub fn evaluate(&self, device: &Device) -> bool { self.0 .ite...
input.parse_comma_separated(|input| DocumentMatchingFunction::parse(context, input))?; let condition = DocumentCondition(conditions); if !condition.allowed_in(context) { return Err(
random_line_split
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS ...
device: &Device) -> bool { self.0 .iter() .any(|url_matching_function| url_matching_function.evaluate(device)) } #[cfg(feature = "servo")] fn allowed_in(&self, _: &ParserContext) -> bool { false } #[cfg(feature = "gecko")] fn allowed_in(&self, context: &Pa...
(&self,
identifier_name
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS ...
MediaDocumentKind::All => "all", MediaDocumentKind::Image => "image", MediaDocumentKind::Plugin => "plugin", MediaDocumentKind::Video => "video", }, }); unsafe { Gecko_DocumentRule_UseForPresentation(device.document(), &*pattern...
use crate::gecko_bindings::bindings::Gecko_DocumentRule_UseForPresentation; use crate::gecko_bindings::structs::DocumentMatchingFunction as GeckoDocumentMatchingFunction; use nsstring::nsCStr; let func = match *self { DocumentMatchingFunction::Url(_) => GeckoDocumentMatchingFuncti...
identifier_body
fs.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 read(&self, buf: &mut [u8]) -> IoResult<uint> { let mut read = 0; let ret = unsafe { libc::ReadFile(self.handle(), buf.as_ptr() as libc::LPVOID, buf.len() as libc::DWORD, &mut read, ptr::null_mut()) }; if ret!...
{ FileDesc { fd: fd, close_on_drop: close_on_drop } }
identifier_body
fs.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 ...
(p: &Path) -> IoResult<()> { let p = try!(to_utf16(p)); mkerr_libc(unsafe { libc::wrmdir(p.as_ptr()) }) } pub fn chown(_p: &Path, _uid: int, _gid: int) -> IoResult<()> { // libuv has this as a no-op, so seems like this should as well? Ok(()) } pub fn readlink(p: &Path) -> IoResult<Path> { // FIXME...
rmdir
identifier_name
fs.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 ...
else { Err(super::last_error()) } } pub fn write(&self, buf: &[u8]) -> IoResult<()> { let mut cur = buf.as_ptr(); let mut remaining = buf.len(); while remaining > 0 { let mut amt = 0; let ret = unsafe { libc::WriteFile(self.ha...
{ Ok(read as uint) }
conditional_block
fs.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 mkdir(p: &Path, _mode: uint) -> IoResult<()> { let p = try!(to_utf16(p)); super::mkerr_winbool(unsafe { // FIXME: turn mode into something useful? #2623 libc::CreateDirectoryW(p.as_ptr(), ptr::null_mut()) }) } pub fn readdir(p: &Path) -> IoResult<Vec<Path>> { fn prune(root: &Path...
} } }
random_line_split
lagrange.rs
use gf256::Gf256; use poly::Poly; /// Evaluates an interpolated polynomial at `Gf256::zero()` where /// the polynomial is determined using barycentric Lagrange /// interpolation based on the given `points` in /// the G(2^8) Galois field. pub(crate) fn interpolate_at(k: u8, points: &[(u8, u8)]) -> u8 { barycentric_...
(points: &[(Gf256, Gf256)]) -> Poly { let len = points.len(); let mut poly = vec![Gf256::zero(); len]; for &(x, y) in points { assert_ne!(x.poly, 0, "Invalid share x = 0"); let mut coeffs = vec![Gf256::zero(); len]; coeffs[0] = y; let mut prod = Gf256::one(); for &...
interpolate
identifier_name