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 |
|---|---|---|---|---|
characterdata.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/. */
//! DOM bindings for `CharacterData`.
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::... |
pub fn clone_with_data(&self, data: DOMString, document: &Document) -> Root<Node> {
match self.upcast::<Node>().type_id() {
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
Root::upcast(Comment::new(data, &document))
}
NodeTypeId::CharacterDa... | {
CharacterData {
node: Node::new_inherited(document),
data: DOMRefCell::new(data),
}
} | identifier_body |
characterdata.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/. */
//! DOM bindings for `CharacterData`.
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::... |
code_units += 1;
if c > '\u{FFFF}' {
if code_units == offset {
if opts::get().replace_surrogates {
debug_assert!(c.len_utf8() == 4);
return Ok((&s[..i], Some(c), &s[i + c.len_utf8()..]))
}
panic!("\n\n\
... | {
let (a, b) = s.split_at(i);
return Ok((a, None, b));
} | conditional_block |
issue-16747.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 ... | <'a, T: ListItem<'a>> {
//~^ ERROR the parameter type `T` may not live long enough
//~^^ HELP consider adding an explicit lifetime bound
//~^^^ NOTE...so that the reference type `&'a [T]` does not outlive the data it points at
slice: &'a [T]
}
impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
fn len(&self... | List | identifier_name |
issue-16747.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() {} | random_line_split | |
import-glob-0.rs | // Copyright 2012 The Rust Project Developers. See the 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | random_line_split |
import-glob-0.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 ... | () {
f1();
f2();
f999(); // 'export' currently doesn't work?
f4();
}
| main | identifier_name |
import-glob-0.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 main() {
f1();
f2();
f999(); // 'export' currently doesn't work?
f4();
}
| { debug!("f4"); } | identifier_body |
main.rs | extern crate prometheus;
extern crate hyper;
extern crate dotenv;
extern crate rusoto;
extern crate ctrlc;
#[macro_use]
extern crate serde_derive;
extern crate serde_yaml;
extern crate time;
extern crate env_logger;
mod config;
mod poller;
mod periodic;
mod server;
mod termination;
mod pagination;
mod aws_poller;
use... | .unwrap();
let _aws_instances_runner = AsyncPeriodicRunner::new(aws_instances_poller, polling_period.clone());
let _aws_spot_prices_runner = AsyncPeriodicRunner::new(aws_spot_prices_poller, polling_period.clone());
TerminationGuard::new();
let _ = listening.close();
}
| {
inject_environment();
env_logger::init().unwrap();
let config = config::DeucalionSettings::from_filename("config.yml")
.expect("Could not load configuration");
let polling_period = config.polling_period()
.unwrap_or(Duration::from_secs(60));
let aws_instances_poller = AwsInstances... | identifier_body |
main.rs | extern crate prometheus;
extern crate hyper;
extern crate dotenv;
extern crate rusoto;
extern crate ctrlc;
#[macro_use]
extern crate serde_derive;
extern crate serde_yaml;
extern crate time;
extern crate env_logger;
mod config;
mod poller;
mod periodic;
mod server;
mod termination;
mod pagination;
mod aws_poller;
use... | TerminationGuard::new();
let _ = listening.close();
} | random_line_split | |
main.rs | extern crate prometheus;
extern crate hyper;
extern crate dotenv;
extern crate rusoto;
extern crate ctrlc;
#[macro_use]
extern crate serde_derive;
extern crate serde_yaml;
extern crate time;
extern crate env_logger;
mod config;
mod poller;
mod periodic;
mod server;
mod termination;
mod pagination;
mod aws_poller;
use... | () {
match dotenv::dotenv() {
Ok(_) | Err(dotenv::DotenvError::Io) => // it is ok if the.env file was not found
return,
Err(dotenv::DotenvError::Parsing {line}) =>
panic!(".env file parsing failed at {:?}", line),
Err(err) => panic!(err)
}
}
fn main() {
injec... | inject_environment | identifier_name |
lib.rs | // Copyright 2016 Google Inc.
//
// 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 in... | match_attr_data!(a, rhs, keep)
}
}
pub fn get_attribute_vec<'a, T>(
&'a self,
key: impl AsRef<str>,
) -> std::result::Result<&'a Vec<T>, String>
where
&'a Vec<T>: TryFrom<&'a AttributeData, Error = String>,
{
self.attributes
.get(key.as... | ($dtype:ident, $data:ident, $keep:expr) => {
$data.retain(|_| $keep.next().unwrap())
};
} | random_line_split |
lib.rs | // Copyright 2016 Google Inc.
//
// 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 in... | <T>(
&mut self,
key: impl AsRef<str>,
) -> std::result::Result<Vec<T>, String>
where
Vec<T>: TryFrom<AttributeData, Error = String>,
{
self.attributes
.remove(key.as_ref())
.ok_or_else(|| format!("Attribute '{}' not found.", key.as_ref()))
.an... | remove_attribute_vec | identifier_name |
lib.rs | // Copyright 2016 Google Inc.
//
// 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 in... | else {
assert_eq!(self.attributes.len(), other.attributes.len());
self.position.append(&mut other.position);
for (s, o) in self
.attributes
.values_mut()
.zip(other.attributes.values_mut())
{
s.append(o)?;
... | {
*self = other.split_off(0);
} | conditional_block |
lib.rs | // Copyright 2016 Google Inc.
//
// 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 in... |
pub fn split_off(&mut self, at: usize) -> Self {
let position = self.position.split_off(at);
let attributes = self
.attributes
.iter_mut()
.map(|(n, a)| (n.clone(), a.split_off(at)))
.collect();
Self {
position,
attributes... | {
if self.position.is_empty() {
*self = other.split_off(0);
} else {
assert_eq!(self.attributes.len(), other.attributes.len());
self.position.append(&mut other.position);
for (s, o) in self
.attributes
.values_mut()
... | identifier_body |
create_entry.rs | use super::*;
use crate::core::error::RepoError;
use diesel::Connection;
pub fn create_entry(
connections: &sqlite::Connections,
indexer: &mut EntryIndexer,
new_entry: usecases::NewEntry,
) -> Result<String> {
// Create and add new entry
let (entry, ratings) = {
let connection = connectio... | diesel::result::Error::RollbackTransaction
})?;
Ok((entry, ratings))
}
Err(err) => {
prepare_err = Some(err);
Err(diesel::result::Error::RollbackTra... | warn!("Failed to store newly created entry: {}", err); | random_line_split |
create_entry.rs | use super::*;
use crate::core::error::RepoError;
use diesel::Connection;
pub fn create_entry(
connections: &sqlite::Connections,
indexer: &mut EntryIndexer,
new_entry: usecases::NewEntry,
) -> Result<String> {
// Create and add new entry
let (entry, ratings) = {
let connection = connectio... |
})
}?;
// Index newly added entry
// TODO: Move to a separate task/thread that doesn't delay this request
if let Err(err) = usecases::index_entry(indexer, &entry, &ratings).and_then(|_| indexer.flush())
{
error!("Failed to index newly added entry {}: {}", entry.id, err);
}
... | {
RepoError::from(err).into()
} | conditional_block |
create_entry.rs | use super::*;
use crate::core::error::RepoError;
use diesel::Connection;
pub fn create_entry(
connections: &sqlite::Connections,
indexer: &mut EntryIndexer,
new_entry: usecases::NewEntry,
) -> Result<String> {
// Create and add new entry
let (entry, ratings) = {
let connection = connectio... | {
let (email_addresses, all_categories) = {
let connection = connections.shared()?;
let email_addresses =
usecases::email_addresses_by_coordinate(&*connection, entry.location.pos)?;
let all_categories = connection.all_categories()?;
(email_addresses, all_categories)
}... | identifier_body | |
create_entry.rs | use super::*;
use crate::core::error::RepoError;
use diesel::Connection;
pub fn create_entry(
connections: &sqlite::Connections,
indexer: &mut EntryIndexer,
new_entry: usecases::NewEntry,
) -> Result<String> {
// Create and add new entry
let (entry, ratings) = {
let connection = connectio... | (connections: &sqlite::Connections, entry: &Entry) -> Result<()> {
let (email_addresses, all_categories) = {
let connection = connections.shared()?;
let email_addresses =
usecases::email_addresses_by_coordinate(&*connection, entry.location.pos)?;
let all_categories = connection.a... | notify_entry_added | identifier_name |
sprite.rs | /*
use glium::texture::Texture2d;
use glium;
use glium::backend::glutin_backend::GlutinFacade;
use glium::{VertexBuffer, IndexBuffer};
use graphics::vertex::Vertex;
pub struct Sprite {
texture: Texture2d,
vertex_buffer: VertexBuffer<Vertex>,
index_buffer: IndexBuffer<u16>,
}
impl Sprite {
pub fn new(... | pos: [-0.5, -0.5],
tex_coords: [0.0, 0.0],
};
let tr = Vertex {
pos: [0.5, -0.5],
tex_coords: [0.0, 1.0],
};
let shape = [tl, tr, bl, br];
let vertex_buffer = VertexBuffer::new(display, &shape).unwrap();
let indices = [0, ... | pos: [0.5, 0.5],
tex_coords: [1.0, 1.0],
};
let tl = Vertex { | random_line_split |
csssupportsrule.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 cssparser::{Parser, ParserInput};
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
use dom::bindi... | cssconditionrule: CSSConditionRule,
#[ignore_heap_size_of = "Arc"]
supportsrule: Arc<Locked<SupportsRule>>,
}
impl CSSSupportsRule {
fn new_inherited(parent_stylesheet: &CSSStyleSheet, supportsrule: Arc<Locked<SupportsRule>>)
-> CSSSupportsRule {
let guard = parent_styleshe... | random_line_split | |
csssupportsrule.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 cssparser::{Parser, ParserInput};
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
use dom::bindi... | (&self) -> DOMString {
let guard = self.cssconditionrule.shared_lock().read();
let rule = self.supportsrule.read_with(&guard);
rule.condition.to_css_string().into()
}
/// https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface
pub fn set_condition_text(&self, text:... | get_condition_text | identifier_name |
csssupportsrule.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 cssparser::{Parser, ParserInput};
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
use dom::bindi... |
}
}
impl SpecificCSSRule for CSSSupportsRule {
fn ty(&self) -> u16 {
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;
CSSRuleConstants::SUPPORTS_RULE
}
fn get_css(&self) -> DOMString {
let guard = self.cssconditionrule.shared_lock().read();
self.... | {
let global = self.global();
let win = global.as_window();
let url = win.Document().url();
let quirks_mode = win.Document().quirks_mode();
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
... | conditional_block |
csssupportsrule.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 cssparser::{Parser, ParserInput};
use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding;
use dom::bindi... |
}
impl SpecificCSSRule for CSSSupportsRule {
fn ty(&self) -> u16 {
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;
CSSRuleConstants::SUPPORTS_RULE
}
fn get_css(&self) -> DOMString {
let guard = self.cssconditionrule.shared_lock().read();
self.suppor... | {
let mut input = ParserInput::new(&text);
let mut input = Parser::new(&mut input);
let cond = SupportsCondition::parse(&mut input);
if let Ok(cond) = cond {
let global = self.global();
let win = global.as_window();
let url = win.Document().url();
... | identifier_body |
router.rs | extern crate iron;
extern crate iron_mountrouter;
// To run, $ cargo run --example router
// To use, go to http://127.0.0.1:3000/
use std::fs::File;
use std::io::Read;
use iron::{Iron, Request, Response, IronResult};
use iron::headers::ContentType;
use iron::status;
use iron_mountrouter::{Router, StrippedUrl};
fn g... |
} | {
let ref query = req.extensions.get::<Router>()
.unwrap();
let mut res = Response::with((
status::Ok,
get_output(
&format!(
"<p>Url: {:?}<p>Query parts: {:?}<p>Stripped url: {:?}",
req.url.path,
*query,
req.extensions.get::<StrippedUrl>()
)
)
));
... | identifier_body |
router.rs | use std::fs::File;
use std::io::Read;
use iron::{Iron, Request, Response, IronResult};
use iron::headers::ContentType;
use iron::status;
use iron_mountrouter::{Router, StrippedUrl};
fn get_output(content: &str) -> String {
let mut res = String::new();
File::open("examples/router.html").unwrap().read_to_string(&mut... | extern crate iron;
extern crate iron_mountrouter;
// To run, $ cargo run --example router
// To use, go to http://127.0.0.1:3000/ | random_line_split | |
router.rs | extern crate iron;
extern crate iron_mountrouter;
// To run, $ cargo run --example router
// To use, go to http://127.0.0.1:3000/
use std::fs::File;
use std::io::Read;
use iron::{Iron, Request, Response, IronResult};
use iron::headers::ContentType;
use iron::status;
use iron_mountrouter::{Router, StrippedUrl};
fn | (content: &str) -> String {
let mut res = String::new();
File::open("examples/router.html").unwrap().read_to_string(&mut res).unwrap();
res.replace("<!-- content -->", content)
}
fn main() {
let mut router = Router::new();
router.add_route("/", handler, false);
router.add_route("/:query/:sub-query/", ha... | get_output | identifier_name |
token.rs | (NtExpr(..)) => true,
Interpolated(NtIdent(..)) => true,
Interpolated(NtBlock(..)) => true,
Interpolated(NtPath(..)) => true,
_ => false,
}
}
/// Returns `true` if the token is any literal
pub fn is_lit(&self) -> bo... | new_from_rc_str | identifier_name | |
token.rs | Underscore => true,
Tilde => true,
Literal(_, _) => true,
Pound => true,
At => true,
Not => true,
BinOp(Minus) ... | pub type IdentInterner = StrInterner; | random_line_split | |
dark_mode.rs | /// This is a simple implementation of support for Windows Dark Mode,
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use winapi::{
shared::{
basetsd::SIZE_T,
minwindef::{BOOL, DWORD, FALSE, UINT, ULONG, WO... | cbData: SIZE_T,
}
lazy_static! {
static ref SET_WINDOW_COMPOSITION_ATTRIBUTE: Option<SetWindowCompositionAttribute> =
get_function!("user32.dll", SetWindowCompositionAttribute);
}
if let Some(set_window_composition_attribute) = *SET_WINDOW_COMPOSITION_ATTRIBUTE {
un... | struct WINDOWCOMPOSITIONATTRIBDATA {
Attrib: WINDOWCOMPOSITIONATTRIB,
pvData: PVOID, | random_line_split |
dark_mode.rs | /// This is a simple implementation of support for Windows Dark Mode,
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use winapi::{
shared::{
basetsd::SIZE_T,
minwindef::{BOOL, DWORD, FALSE, UINT, ULONG, WO... | (hwnd: HWND, is_dark_mode: bool) -> bool {
// Uses Windows undocumented API SetWindowCompositionAttribute,
// as seen in win32-darkmode example linked at top of file.
type SetWindowCompositionAttribute =
unsafe extern "system" fn(HWND, *mut WINDOWCOMPOSITIONATTRIBDATA) -> BOOL;
#[allow(non_sna... | set_dark_mode_for_window | identifier_name |
dark_mode.rs | /// This is a simple implementation of support for Windows Dark Mode,
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use winapi::{
shared::{
basetsd::SIZE_T,
minwindef::{BOOL, DWORD, FALSE, UINT, ULONG, WO... |
fn widestring(src: &'static str) -> Vec<u16> {
OsStr::new(src)
.encode_wide()
.chain(Some(0).into_iter())
.collect()
}
| {
let mut hc = HIGHCONTRASTA {
cbSize: 0,
dwFlags: 0,
lpszDefaultScheme: std::ptr::null_mut(),
};
let ok = unsafe {
winuser::SystemParametersInfoA(
winuser::SPI_GETHIGHCONTRAST,
std::mem::size_of_val(&hc) as _,
&mut hc as *mut _ as _,
... | identifier_body |
sample_index_range.rs | use std::{fmt, ops::Div};
use metadata::Duration;
| #[derive(Clone, Copy, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct SampleIndexRange(usize);
impl SampleIndexRange {
pub const fn new(value: usize) -> Self {
SampleIndexRange(value)
}
#[track_caller]
pub fn from_duration(duration: Duration, sample_duration: Duration) -> Self {
... | random_line_split | |
sample_index_range.rs | use std::{fmt, ops::Div};
use metadata::Duration;
#[derive(Clone, Copy, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct SampleIndexRange(usize);
impl SampleIndexRange {
pub const fn new(value: usize) -> Self {
SampleIndexRange(value)
}
#[track_caller]
pub fn from_duration(duratio... |
#[track_caller]
pub fn duration(self, sample_duration: Duration) -> Duration {
sample_duration * (self.0 as u64)
}
#[track_caller]
pub fn scale(self, num: SampleIndexRange, denom: SampleIndexRange) -> Self {
SampleIndexRange(self.0 * num.0 / denom.0)
}
#[track_caller]
... | {
SampleIndexRange((duration / sample_duration).as_usize())
} | identifier_body |
sample_index_range.rs | use std::{fmt, ops::Div};
use metadata::Duration;
#[derive(Clone, Copy, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct SampleIndexRange(usize);
impl SampleIndexRange {
pub const fn new(value: usize) -> Self {
SampleIndexRange(value)
}
#[track_caller]
pub fn from_duration(duratio... | (self, sample_step: SampleIndexRange) -> usize {
self.0 / sample_step.0
}
pub fn as_f64(self) -> f64 {
self.0 as f64
}
pub fn as_usize(self) -> usize {
self.0
}
}
impl From<usize> for SampleIndexRange {
fn from(value: usize) -> Self {
Self(value)
}
}
impl ... | step_range | identifier_name |
pyramid.rs | use hitable::{
Hitable,
HitRecord,
HitableList,
};
use ray::Ray3;
use aabb::AABB;
use material::Material;
use triangle::Triangle;
use quad::Quad;
use cgmath::{
Point3,
Vector3,
Quaternion,
Rotation,
One,
};
use std::time::Instant;
pub struct | {
hitable_list: HitableList,
}
impl Pyramid {
pub fn new(position: Point3<f32>, base_length: f32, height: f32, rotation: Quaternion<f32>, material: Material) -> Self {
let base_vertices = [
position + rotation.rotate_vector(Vector3::new(-0.5, 0.0, 0.5) * base_length),
position ... | Pyramid | identifier_name |
pyramid.rs | use hitable::{
Hitable,
HitRecord,
HitableList,
};
use ray::Ray3;
use aabb::AABB;
use material::Material;
use triangle::Triangle;
use quad::Quad;
use cgmath::{
Point3, | Rotation,
One,
};
use std::time::Instant;
pub struct Pyramid {
hitable_list: HitableList,
}
impl Pyramid {
pub fn new(position: Point3<f32>, base_length: f32, height: f32, rotation: Quaternion<f32>, material: Material) -> Self {
let base_vertices = [
position + rotation.rotate_vec... | Vector3,
Quaternion, | random_line_split |
client.rs | // Copyright © 2014, Peter Atashian
use std::io::timer::sleep;
use std::io::{TcpStream};
use std::sync::Arc;
use std::sync::atomics::{AtomicUint, SeqCst};
use std::task::TaskBuilder;
use std::time::duration::Duration;
fn m | ) {
let count = Arc::new(AtomicUint::new(0));
loop {
let clone = count.clone();
TaskBuilder::new().stack_size(32768).spawn(proc() {
let mut tcp = match TcpStream::connect("127.0.0.1", 273) {
Ok(tcp) => tcp,
Err(_) => return,
};
... | ain( | identifier_name |
client.rs | // Copyright © 2014, Peter Atashian
use std::io::timer::sleep; | use std::io::{TcpStream};
use std::sync::Arc;
use std::sync::atomics::{AtomicUint, SeqCst};
use std::task::TaskBuilder;
use std::time::duration::Duration;
fn main() {
let count = Arc::new(AtomicUint::new(0));
loop {
let clone = count.clone();
TaskBuilder::new().stack_size(32768).spawn(proc() {
... | random_line_split | |
client.rs | // Copyright © 2014, Peter Atashian
use std::io::timer::sleep;
use std::io::{TcpStream};
use std::sync::Arc;
use std::sync::atomics::{AtomicUint, SeqCst};
use std::task::TaskBuilder;
use std::time::duration::Duration;
fn main() { |
let count = Arc::new(AtomicUint::new(0));
loop {
let clone = count.clone();
TaskBuilder::new().stack_size(32768).spawn(proc() {
let mut tcp = match TcpStream::connect("127.0.0.1", 273) {
Ok(tcp) => tcp,
Err(_) => return,
};
pri... | identifier_body | |
compiler_required.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | (pub fn() -> bool);
pub struct StaticTestName(pub &'static str);
pub struct TestDesc {
// Indicates a test case should run but not fail the overall test suite.
// This was introduced in https://github.com/rust-lang/rust/pull/42219. It
// is not expected to become stable:
// https://github.com/rust-lang... | StaticTestFn | identifier_name |
compiler_required.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | pub test_type: TestType,
}
pub struct TestDescAndFn {
pub desc: TestDesc,
pub testfn: StaticTestFn,
}
pub enum TestType { UnitTest }
// The test harness's equivalent of main() (it is called by a compiler-generated
// shim).
pub fn test_main_static(tests: &[&TestDescAndFn]) {
use libtock::println;
... | random_line_split | |
compiler_required.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
maybe_drivers.ok().unwrap().console.create_console();
println!("Starting tests.");
let mut overall_success = true;
for test_case in tests {
// Skip ignored test cases.
let desc = &test_case.desc;
let name = desc.name.0;
if desc.ignore {
println!("Skipping ig... | {
panic!("Could not retrieve drivers.");
} | conditional_block |
compiler_required.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
// -----------------------------------------------------------------------------
// Compiler-generated test list types. The compiler generates a [&TestDescAndFn]
// array and passes it to test_main_static.
// -----------------------------------------------------------------------------
// A ShouldPanic enum is requi... | { result } | identifier_body |
lib.rs | //! Implementation of `cpp_to_rust` generator that
//! analyzes a C++ library and produces a Rust crate for it.
//! See [README](https://github.com/rust-qt/cpp_to_rust/tree/master/cpp_to_rust/cpp_to_rust_generator)
//! for more information.
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", ... | mod launcher;
mod rust_generator;
mod rust_code_generator;
mod rust_info;
mod rust_type;
mod cpp_parser;
mod versions;
#[cfg(test)]
mod tests; | pub mod cpp_method;
pub mod cpp_type;
mod cpp_operator;
mod doc_formatter; | random_line_split |
nk.rs | %-------------------------------------------------------------
% Nonlinear New Keynesian Model
% Reference: Foerster, Rubio-Ramirez, Waggoner and Zha (2013)
% Perturbation Methods for Markov Switching Models.
%------------------------------------------------------------- |
exogenous EPS_R "Monetary policy shock"
parameters betta, eta, kappa, rhor sigr a_tp_1_2, a_tp_2_1
parameters(a,2) mu, psi
model
1=betta*(1-.5*kappa*(PAI-1)^2)*Y*R/((1-.5*kappa*(PAI{+1}-1)^2)*Y{+1}*exp(mu)*PAI{+1});
1-eta+eta*(1-.5*kappa*(PAI-1)^2)*Y+betta*kappa*(1-.5*kappa*(PAI-1)^2)*(PAI{+1}-1)*PAI{+1}/(1-.5*... |
endogenous PAI, "Inflation", Y, "Output gap", R, "Interest rate" | random_line_split |
shl.rs | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::i32x4;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
#[test]
fn | () {
let x: i32x4 = i32x4(
0, 1, 2, 3
);
let y: i32x4 = i32x4(
2, 2, 2, 2
);
let z: i32x4 = x << y;
let result: String = format!("{:?}", z);
assert_eq!(result, "i32x4(0, 4, 8, 12)".to_string());
}
}
| shl_test1 | identifier_name |
shl.rs | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::i32x4;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
#[test]
fn shl_test1() {
let x: i32x4 = i32x4(
0, 1, 2, 3
); | );
let z: i32x4 = x << y;
let result: String = format!("{:?}", z);
assert_eq!(result, "i32x4(0, 4, 8, 12)".to_string());
}
} | let y: i32x4 = i32x4(
2, 2, 2, 2 | random_line_split |
shl.rs | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::i32x4;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
#[test]
fn shl_test1() |
}
| {
let x: i32x4 = i32x4(
0, 1, 2, 3
);
let y: i32x4 = i32x4(
2, 2, 2, 2
);
let z: i32x4 = x << y;
let result: String = format!("{:?}", z);
assert_eq!(result, "i32x4(0, 4, 8, 12)".to_string());
} | identifier_body |
deriving-span-PartialOrd-tuple-struct.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 ... | ;
#[derive(PartialOrd,PartialEq)]
struct Struct(
Error //~ ERROR
//~^ ERROR
//~^^ ERROR
//~^^^ ERROR
//~^^^^ ERROR
//~^^^^^ ERROR
//~^^^^^^ ERROR
//~^^^^^^^ ERROR
//~^^^^^^^^ ERROR
);
fn main() {}
| Error | identifier_name |
deriving-span-PartialOrd-tuple-struct.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This file was... | random_line_split | |
call_request.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... |
/// Call request
#[derive(Debug, Default, PartialEq, Deserialize)]
pub struct CallRequest {
/// From
pub from: Option<H160>,
/// To
pub to: Option<H160>,
/// Gas Price
#[serde(rename="gasPrice")]
pub gas_price: Option<U256>,
/// Gas
pub gas: Option<U256>,
/// Value
pub value: Option<U256>,
/// Data
pub da... | // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use v1::helpers::CallRequest as Request;
use v1::types::{Bytes, H160, U256}; | random_line_split |
call_request.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | () {
let s = r#"{
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}"#;
let... | call_request_deserialize2 | identifier_name |
call_request.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... |
}
#[cfg(test)]
mod tests {
use std::str::FromStr;
use rustc_serialize::hex::FromHex;
use serde_json;
use v1::types::{U256, H160};
use super::CallRequest;
#[test]
fn call_request_deserialize() {
let s = r#"{
"from":"0x0000000000000000000000000000000000000001",
"to":"0x0000000000000000000000000000000000... | {
Request {
from: self.from.map(Into::into),
to: self.to.map(Into::into),
gas_price: self.gas_price.map(Into::into),
gas: self.gas.map(Into::into),
value: self.value.map(Into::into),
data: self.data.map(Into::into),
nonce: self.nonce.map(Into::into),
}
} | identifier_body |
token.rs | Question,
/// An opening delimiter, eg. `{`
OpenDelim(DelimToken),
/// A closing delimiter, eg. `}`
CloseDelim(DelimToken),
/* Literals */
Literal(Lit, Option<ast::Name>),
/* Name components */
Ident(ast::Ident, IdentStyle),
Underscore,
Lifetime(ast::Ident),
/* For interp... | (&self) -> bool {
match *self {
Literal(_, _) => true,
_ => false,
}
}
/// Returns `true` if the token is an identifier.
pub fn is_ident(&self) -> bool {
match *self {
Ident(_, _) => true,
_ => false,
}
}... | is_lit | identifier_name |
token.rs | => Some(ast::BiLe),
Ge => Some(ast::BiGe),
Gt => Some(ast::BiGt),
EqEq => Some(ast::BiEq),
Ne => Some(ast::BiNe),
AndAnd => Some(ast::BiAnd),
OrOr => Some(ast::BiOr)... | {
get_name(ident.name)
} | identifier_body | |
token.rs | Question,
/// An opening delimiter, eg. `{`
OpenDelim(DelimToken),
/// A closing delimiter, eg. `}`
CloseDelim(DelimToken),
/* Literals */
Literal(Lit, Option<ast::Name>),
/* Name components */
Ident(ast::Ident, IdentStyle),
Underscore,
Lifetime(ast::Ident),
/* For inter... | Tilde => true,
Literal(_, _) => true,
Not => true,
BinOp(Minus) => true,
BinOp(Star) => true,
BinOp(And) => true,
BinOp(Or) ... | OpenDelim(_) => true,
Ident(_, _) => true,
Underscore => true, | random_line_split |
lib.rs | #![crate_name = "input"]
#![deny(missing_docs)]
#![deny(missing_copy_implementations)]
//! A flexible structure for user interactions
//! to be used in window frameworks and widgets libraries.
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate viewport;
use s... | /// Time stamp is ignored both when comparing custom events for equality and order.
Custom(EventId, Arc<dyn Any + Send + Sync>, Option<TimeStamp>),
}
impl fmt::Debug for Event {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Event::Input(ref input, _) => write!(f, ... | /// When comparing partial order of two custom events,
/// the event ids are checked and if they are equal it returns `None`.
/// | random_line_split |
lib.rs | #![crate_name = "input"]
#![deny(missing_docs)]
#![deny(missing_copy_implementations)]
//! A flexible structure for user interactions
//! to be used in window frameworks and widgets libraries.
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate viewport;
use s... |
}
impl From<MouseButton> for Button {
fn from(btn: MouseButton) -> Self {
Button::Mouse(btn)
}
}
impl From<ControllerButton> for Button {
fn from(btn: ControllerButton) -> Self {
Button::Controller(btn)
}
}
impl From<ButtonArgs> for Input {
fn from(args: ButtonArgs) -> Self {
... | {
Button::Keyboard(key)
} | identifier_body |
lib.rs | #![crate_name = "input"]
#![deny(missing_docs)]
#![deny(missing_copy_implementations)]
//! A flexible structure for user interactions
//! to be used in window frameworks and widgets libraries.
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate viewport;
use s... | (key: Key) -> Self {
Button::Keyboard(key)
}
}
impl From<MouseButton> for Button {
fn from(btn: MouseButton) -> Self {
Button::Mouse(btn)
}
}
impl From<ControllerButton> for Button {
fn from(btn: ControllerButton) -> Self {
Button::Controller(btn)
}
}
impl From<ButtonArgs>... | from | identifier_name |
class-poly-methods-cross-crate.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
let mut nyan : cat<char> = cat::<char>(52_usize, 99, vec!['p']);
let mut kitty = cat(1000_usize, 2, vec!["tabby".to_string()]);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec![1_usize,2_usize,3_usize]);
assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!["meow"... | main | identifier_name |
class-poly-methods-cross-crate.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
let mut nyan : cat<char> = cat::<char>(52_usize, 99, vec!['p']);
let mut kitty = cat(1000_usize, 2, vec!["tabby".to_string()]);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec![1_usize,2_usize,3_usize]);
assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!["meow".to... | identifier_body | |
class-poly-methods-cross-crate.rs | // 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 distributed
// except according to those terms.
// run-pass
// aux-build:cci_class_6.rs
extern crate cci_class_6;
use cci_class_6::kitt... | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split | |
civ5map.rs | // Copyright 2015 Virgil Dupras
//
// This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
// which should be included with this package. The terms are also available at
// http://www.gnu.org/licenses/gpl-3.0.html
//
use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
us... | width: width,
height: height,
playercount: playercount,
flags: flags,
terrain: terrain_list,
features1: feature1_list,
features2: feature2_list,
resources: resource_list,
name: mapname,
description: mapdesc,
unknown: unknown,
}
... | random_line_split | |
civ5map.rs | // Copyright 2015 Virgil Dupras
//
// This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
// which should be included with this package. The terms are also available at
// http://www.gnu.org/licenses/gpl-3.0.html
//
use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
us... | (path: &Path) -> TerrainMap {
let mut fp = File::open(path).unwrap();
let mh = load_map_header(&mut fp);
let tiles = load_map_tiles(&mut fp, mh.width * mh.height);
let mut mapdata: Vec<Terrain> = Vec::new();
let name2terrain = HashMap::<&str, Terrain>::from_iter(vec![
("TERRAIN_COAST", T... | load_civ5map | identifier_name |
civ5map.rs | // Copyright 2015 Virgil Dupras
//
// This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
// which should be included with this package. The terms are also available at
// http://www.gnu.org/licenses/gpl-3.0.html
//
use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
us... |
fn load_map_header(fp: &mut File) -> MapHeader {
let version = fp.read_u8().unwrap();
let width = fp.read_u32::<LittleEndian>().unwrap();
let height = fp.read_u32::<LittleEndian>().unwrap();
let playercount = fp.read_u8().unwrap();
let flags = fp.read_u32::<LittleEndian>().unwrap();
let terrai... | {
let s = read_str(fp, len);
let result: Vec<String> = s.split('\0').map(|s| s.to_string()).collect();
result
} | identifier_body |
non-exhaustive-match-nested.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn main() {
let x = a(c);
match x { //~ ERROR non-exhaustive patterns: `a(c)` not covered
a(d) => { fail!("hello"); }
b => { fail!("goodbye"); }
}
}
| {
match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some([]), Err(_))` not covered
(Some([]), Ok([])) => "Some(empty), Ok(empty)",
(Some([_, ..]), Ok(_)) | (Some([_, ..]), Err(())) => "Some(non-empty), any",
(None, Ok([])) | (None, Err(())) | (None, Ok([_])) => "None, Ok(less than one el... | identifier_body |
non-exhaustive-match-nested.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | { c, d }
fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str {
match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some([]), Err(_))` not covered
(Some([]), Ok([])) => "Some(empty), Ok(empty)",
(Some([_,..]), Ok(_)) | (Some([_,..]), Err(())) => "Some(non-emp... | u | identifier_name |
non-exhaustive-match-nested.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | enum u { c, d }
fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str {
match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some([]), Err(_))` not covered
(Some([]), Ok([])) => "Some(empty), Ok(empty)",
(Some([_,..]), Ok(_)) | (Some([_,..]), Err(())) => "Some(n... | // <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.
enum t { a(u), b } | random_line_split |
deriving-show-2.rs | // Copyright 2012-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-MI... | { C1(int), C2(B), C3(String) }
#[derive(Show)]
enum D { D1{ a: int } }
#[derive(Show)]
struct E;
#[derive(Show)]
struct F(int);
#[derive(Show)]
struct G(int, int);
#[derive(Show)]
struct H { a: int }
#[derive(Show)]
struct I { a: int, b: int }
#[derive(Show)]
struct J(Custom);
struct Custom;
impl fmt::Show for Custom... | C | identifier_name |
deriving-show-2.rs | // Copyright 2012-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-MI... | struct F(int);
#[derive(Show)]
struct G(int, int);
#[derive(Show)]
struct H { a: int }
#[derive(Show)]
struct I { a: int, b: int }
#[derive(Show)]
struct J(Custom);
struct Custom;
impl fmt::Show for Custom {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "yay")
}
}
trait ToShow {
... | #[derive(Show)] | random_line_split |
ipc.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 crate::time;
use crate::time::ProfilerCategory;
use crate::time::ProfilerChan;
use ipc_channel::ipc;
use serde... | time::profile(
ProfilerCategory::IpcBytesReceiver,
None,
self.time_profile_chan.clone(),
move || self.ipc_bytes_receiver.recv(),
)
}
}
pub fn bytes_channel(
time_profile_chan: ProfilerChan,
) -> Result<(ipc::IpcBytesSender, IpcBytesReceiver), Erro... | random_line_split | |
ipc.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 crate::time;
use crate::time::ProfilerCategory;
use crate::time::ProfilerChan;
use ipc_channel::ipc;
use serde... |
pub fn try_recv(&self) -> Result<T, bincode::Error> {
self.ipc_receiver.try_recv()
}
pub fn to_opaque(self) -> ipc::OpaqueIpcReceiver {
self.ipc_receiver.to_opaque()
}
}
pub fn channel<T>(
time_profile_chan: ProfilerChan,
) -> Result<(ipc::IpcSender<T>, IpcReceiver<T>), Error>
wh... | {
time::profile(
ProfilerCategory::IpcReceiver,
None,
self.time_profile_chan.clone(),
move || self.ipc_receiver.recv(),
)
} | identifier_body |
ipc.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 crate::time;
use crate::time::ProfilerCategory;
use crate::time::ProfilerChan;
use ipc_channel::ipc;
use serde... | (&self) -> Result<Vec<u8>, bincode::Error> {
time::profile(
ProfilerCategory::IpcBytesReceiver,
None,
self.time_profile_chan.clone(),
move || self.ipc_bytes_receiver.recv(),
)
}
}
pub fn bytes_channel(
time_profile_chan: ProfilerChan,
) -> Result<... | recv | identifier_name |
mod.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/. */
pub mod dom_manipulation;
pub mod file_reading;
pub mod history_traversal;
pub mod networking;
pub mod user_intera... | msg: Box<T>,
wrapper: &RunnableWrapper)
-> Result<(), ()>
where T: Runnable + Send +'static;
fn queue<T: Runnable + Send +'static>(&self, msg: Box<T>, global: GlobalRef) -> Result<(), ()> {
se... | use script_thread::{Runnable, RunnableWrapper};
use std::result::Result;
pub trait TaskSource {
fn queue_with_wrapper<T>(&self, | random_line_split |
mod.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/. */
pub mod dom_manipulation;
pub mod file_reading;
pub mod history_traversal;
pub mod networking;
pub mod user_intera... | <T: Runnable + Send +'static>(&self, msg: Box<T>, global: GlobalRef) -> Result<(), ()> {
self.queue_with_wrapper(msg, &global.get_runnable_wrapper())
}
}
| queue | identifier_name |
mod.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/. */
pub mod dom_manipulation;
pub mod file_reading;
pub mod history_traversal;
pub mod networking;
pub mod user_intera... |
}
| {
self.queue_with_wrapper(msg, &global.get_runnable_wrapper())
} | identifier_body |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... |
}
}
let unsafe_layout_node = node.to_unsafe();
// Before running the children, we need to insert our nodes into the bloom
// filter.
debug!("[{}] + {:X}", tid(), unsafe_layout_node.0);
node.insert_into_bloom_filter(&mut *bf);
// NB: flow construction updates the bloom filter on t... | {
style_sharing_candidate_cache.touch(index);
node.set_restyle_damage(damage);
} | conditional_block |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... | context: &SharedStyleContext<Impl>)
-> Box<BloomFilter>
where N: TNode {
STYLE_BLOOM.with(|style_bloom| {
match (parent_node, st... | ///
/// If one does not exist, a new one will be made for you. If it is out of date,
/// it will be cleared and reused.
fn take_thread_local_bloom_filter<N, Impl: SelectorImplExt>(parent_node: Option<N>,
root: OpaqueNode, | random_line_split |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... | } else {
// Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing
// allocation to avoid malloc churn.
bloom_filter.clear();
insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, root);
... | {
STYLE_BLOOM.with(|style_bloom| {
match (parent_node, style_bloom.borrow_mut().take()) {
// Root node. Needs new bloom filter.
(None, _ ) => {
debug!("[{}] No parent, but new bloom filter!", tid());
Box::new(BloomFilter::new())
}
... | identifier_body |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... | <'a, N, C>(context: &'a C,
root: OpaqueNode,
node: N)
where N: TNode,
C: StyleContext<'a, <N::ConcreteElement as Element>::Impl>,
<N::ConcreteElement as Element>::Impl: SelectorImplExt<ComputedValues=N::ConcreteComputedValues> + '... | recalc_style_at | identifier_name |
mithril_config.rs | extern crate mithril;
use mithril::mithril_config;
use std::path::Path;
use std::time::{Duration, Instant};
#[test]
fn test_read_default_config() {
let config = read_default_config();
assert_eq!(config.pool_conf.pool_address, "xmrpool.eu:3333");
assert_eq!(config.pool_conf.wallet_address, "");
asser... |
//helper
fn read_default_config() -> mithril_config::MithrilConfig {
let path = &format!("{}{}", "./", "default_config.toml");
return mithril_config::read_config(Path::new(path), "default_config.toml").unwrap();
}
| {
let config = read_default_config();
let now = Instant::now();
let _ = now + Duration::from_secs(config.metric_conf.sample_interval_seconds);
//Ok if it doesn't panic
} | identifier_body |
mithril_config.rs | extern crate mithril;
use mithril::mithril_config;
use std::path::Path;
use std::time::{Duration, Instant};
| #[test]
fn test_read_default_config() {
let config = read_default_config();
assert_eq!(config.pool_conf.pool_address, "xmrpool.eu:3333");
assert_eq!(config.pool_conf.wallet_address, "");
assert_eq!(config.pool_conf.pool_password, "");
assert_eq!(config.worker_conf.num_threads, 8);
assert_eq!(c... | random_line_split | |
mithril_config.rs | extern crate mithril;
use mithril::mithril_config;
use std::path::Path;
use std::time::{Duration, Instant};
#[test]
fn test_read_default_config() {
let config = read_default_config();
assert_eq!(config.pool_conf.pool_address, "xmrpool.eu:3333");
assert_eq!(config.pool_conf.wallet_address, "");
asser... | () -> mithril_config::MithrilConfig {
let path = &format!("{}{}", "./", "default_config.toml");
return mithril_config::read_config(Path::new(path), "default_config.toml").unwrap();
}
| read_default_config | identifier_name |
htmlsourceelement.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::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElem... |
fn iterate_next_html_image_element_siblings(
next_siblings_iterator: impl Iterator<Item = Root<Dom<Node>>>,
) {
for next_sibling in next_siblings_iterator {
if let Some(html_image_element_sibling) = next_sibling.downcast::<HTMLImageElement>() {
html_image_element_si... | {
Node::reflect_node(
Box::new(HTMLSourceElement::new_inherited(
local_name, prefix, document,
)),
document,
)
} | identifier_body |
htmlsourceelement.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::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElem... | ,
}
}
/// <https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted>
fn bind_to_tree(&self, context: &BindContext) {
self.super_type().unwrap().bind_to_tree(context);
let parent = self.upcast::<Node>().GetParentNode().unwrap();
if let Some(media) = paren... | {} | conditional_block |
htmlsourceelement.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::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElem... | (
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLSourceElement {
HTMLSourceElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: ... | new_inherited | identifier_name |
htmlsourceelement.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::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElem... | &local_name!("srcset") |
&local_name!("sizes") |
&local_name!("media") |
&local_name!("type") => {
let next_sibling_iterator = self.upcast::<Node>().following_siblings();
HTMLSourceElement::iterate_next_html_image_element_siblings(next_sibl... | match attr.local_name() { | random_line_split |
htmloptgroupelement.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::attr::Attr;
use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;... | }
impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods)
}
fn after_set_attr(&self, attr: JSRef<Attr>) {
... |
// http://www.whatwg.org/html#dom-optgroup-disabled
make_bool_setter!(SetDisabled, "disabled") | random_line_split |
htmloptgroupelement.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::attr::Attr;
use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;... | ,
_ => ()
}
}
}
| {
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.set_disabled_state(false);
node.set_enabled_state(true);
for child in node.children().filter(|child| child.is_htmloptionelement()) {
child.check_disabled_attribute();
... | conditional_block |
htmloptgroupelement.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::attr::Attr;
use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;... |
fn after_set_attr(&self, attr: JSRef<Attr>) {
match self.super_type() {
Some(ref s) => s.after_set_attr(attr),
_ => ()
}
match attr.local_name() {
&atom!("disabled") => {
let node: JSRef<Node> = NodeCast::from_ref(*self);
... | {
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods)
} | identifier_body |
htmloptgroupelement.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::attr::Attr;
use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;... | (&self, attr: JSRef<Attr>) {
match self.super_type() {
Some(ref s) => s.after_set_attr(attr),
_ => ()
}
match attr.local_name() {
&atom!("disabled") => {
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.set_disabled_stat... | after_set_attr | identifier_name |
liveness-use-after-send.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | // 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | // file at the top-level directory of this distribution and at | random_line_split |
liveness-use-after-send.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 ... | () { fail!(); }
| main | identifier_name |
option_addition.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 ... | } | random_line_split | |
option_addition.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 ... | () {
let foo = 1;
let bar = 2;
let foobar = foo + bar;
let nope = optint(0) + optint(0);
let somefoo = optint(foo) + optint(0);
let somebar = optint(bar) + optint(0);
let somefoobar = optint(foo) + optint(bar);
match nope {
None => (),
Some(foo) => fail!(fmt!("expected ... | main | identifier_name |
option_addition.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 ... |
}
| {
return Some(in);
} | conditional_block |
option_addition.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 ... |
fn optint(in: int) -> Option<int> {
if in == 0 {
return None;
}
else {
return Some(in);
}
}
| {
let foo = 1;
let bar = 2;
let foobar = foo + bar;
let nope = optint(0) + optint(0);
let somefoo = optint(foo) + optint(0);
let somebar = optint(bar) + optint(0);
let somefoobar = optint(foo) + optint(bar);
match nope {
None => (),
Some(foo) => fail!(fmt!("expected Non... | identifier_body |
multipleblock.rs | //
/*
*/
#![feature(inclusive_range_syntax)]
#![feature(type_ascription)]
#![feature(more_struct_aliases)]
extern crate modbus_server;
extern crate futures;
extern crate tokio_proto;
extern crate tokio_service;
extern crate docopt;
extern crate rustc_serialize;
use std::sync::{Arc,Mutex};
use std::str;
use future... | () {
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.decode())
.unwrap_or_else(|e| {println!("DAMN {:?}",e); e.exit()});
println!("{:?}", args);
let mut blocks : HashMap<u8,Arc<Mutex<BlankRegisters>>> = HashMap::new();
for r in args.arg_resource {
let block = Arc::new(Mut... | main | identifier_name |
multipleblock.rs | //
/*
*/
#![feature(inclusive_range_syntax)]
#![feature(type_ascription)]
#![feature(more_struct_aliases)]
extern crate modbus_server;
extern crate futures;
extern crate tokio_proto;
extern crate tokio_service;
extern crate docopt;
extern crate rustc_serialize;
use std::sync::{Arc,Mutex};
use std::str;
use future... | let mut blocks : HashMap<u8,Arc<Mutex<BlankRegisters>>> = HashMap::new();
for r in args.arg_resource {
let block = Arc::new(Mutex::new(BlankRegisters::new()));
blocks.insert(r,block);
}
TcpServer::new(ModbusTCPProto, args.flag_addr.parse().unwrap())
.serve(move || Ok(Modbus... | random_line_split | |
md-butane.rs | // Lumol, an extensible molecular simulation engine
// Copyright (C) Lumol's contributors — BSD license
//! Testing molecular dynamics of butane
use lumol::input::Input;
use std::path::Path;
use std::sync::Once;
static START: Once = Once::new();
#[test]
fn bonds_detection() {
START.call_once(::env_logger::init)... | let mut config = Input::new(path).unwrap().read().unwrap();
let e_initial = config.system.total_energy();
config.simulation.run(&mut config.system, config.nsteps);
let e_final = config.system.total_energy();
assert!(f64::abs((e_initial - e_final) / e_final) < 1e-3);
} | .join("nve.toml"); | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.