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 |
|---|---|---|---|---|
deprecated_fields.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. | use common::{Diagnostic, DiagnosticTag, DiagnosticsResult, NamedItem, WithLocation};
use graphql_ir::{
ExecutableDefinition, LinkedField, Program, ScalarField, ValidationMessage, Validator, Value,
};
use intern::string_key::{Intern, StringKey};
use lazy_static::lazy_static;
use schema::{FieldID, SDLSchema, Schema};... | */
use std::sync::Arc;
| random_line_split |
deprecated_fields.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::sync::Arc;
use common::{Diagnostic, DiagnosticTag, DiagnosticsResult, NamedItem, WithLocation};
use graphql_ir::{
E... | (&mut self, field: &ScalarField) -> DiagnosticsResult<()> {
self.validate_field(&field.definition);
self.default_validate_scalar_field(field)
}
fn validate_value(&mut self, value: &Value) -> DiagnosticsResult<()> {
// TODO: `@deprecated` is allowed on Enum values, so technically we
... | validate_scalar_field | identifier_name |
deprecated_fields.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::sync::Arc;
use common::{Diagnostic, DiagnosticTag, DiagnosticsResult, NamedItem, WithLocation};
use graphql_ir::{
E... |
pub fn deprecated_fields_for_executable_definition(
schema: &Arc<SDLSchema>,
definition: &ExecutableDefinition,
) -> DiagnosticsResult<Vec<Diagnostic>> {
let mut validator = DeprecatedFields::new(schema);
match definition {
ExecutableDefinition::Fragment(fragment) => validator.validate_fragme... | {
let mut validator = DeprecatedFields::new(schema);
validator.validate_program(program)?;
Ok(validator.warnings)
} | identifier_body |
mod.rs | //! Serialization and encodings.
//!
//! This module provides encoding support enabled via Cargo features. Each
//! enabled encoding has a corresponding sub-module. For example, when [PLY]
//! support is enabled, the `ply` module is exposed. The following table
//! summarizes the encodings supported by Plexus:
//!
//! ... | // features to be supported, such as edge geometry for `MeshGraph`s.
pub trait FromEncoding<E>: Sized
where
E: FaceDecoder + VertexDecoder,
{
type Error: Debug;
fn from_encoding(
vertices: <E as VertexDecoder>::Output,
faces: <E as FaceDecoder>::Output,
) -> Result<Self, Self::Err... |
// TODO: This trait is a bit limiting. Consider implementing more specific
// traits like `FromPly` directly. This could allow more specific | random_line_split |
perftest.rs | use std::fs::File;
use std::path::Path;
use std::time::Instant;
use perftest_data::PerftestData;
use protobuf::Message;
use protobuf::MessageFull;
use rand::Rng;
use rand::SeedableRng;
use rand::StdRng;
mod perftest_data;
fn measure_ns<R, F: FnMut() -> R>(mut f: F) -> (u64, R) {
let start = Instant::now();
l... | random_data.len() as u64,
|| {
for m in &random_data {
m.write_length_delimited_to_vec(&mut buf).unwrap();
}
},
);
let read_data =
measure_and_print(&format!("{}: read", name), random_data.len() as u64, ... | measure_and_print(
&format!("{}: write", name), | random_line_split |
perftest.rs | use std::fs::File;
use std::path::Path;
use std::time::Instant;
use perftest_data::PerftestData;
use protobuf::Message;
use protobuf::MessageFull;
use rand::Rng;
use rand::SeedableRng;
use rand::StdRng;
mod perftest_data;
fn measure_ns<R, F: FnMut() -> R>(mut f: F) -> (u64, R) {
let start = Instant::now();
l... |
struct TestRunner {
data_size: u32,
selected: Option<String>,
any_matched: bool,
}
impl TestRunner {
fn run_test<M: MessageFull + Clone + PartialEq>(&self, name: &str, data: &[M]) {
assert!(data.len() > 0, "empty string for test: {}", name);
let mut rng: StdRng = SeedableRng::from_se... | {
let (ns, r) = measure_ns(f);
let ns_per_iter = ns / iter;
println!("{}: {} ns per iter", title, ns_per_iter);
r
} | identifier_body |
perftest.rs | use std::fs::File;
use std::path::Path;
use std::time::Instant;
use perftest_data::PerftestData;
use protobuf::Message;
use protobuf::MessageFull;
use rand::Rng;
use rand::SeedableRng;
use rand::StdRng;
mod perftest_data;
fn measure_ns<R, F: FnMut() -> R>(mut f: F) -> (u64, R) {
let start = Instant::now();
l... | {
data_size: u32,
selected: Option<String>,
any_matched: bool,
}
impl TestRunner {
fn run_test<M: MessageFull + Clone + PartialEq>(&self, name: &str, data: &[M]) {
assert!(data.len() > 0, "empty string for test: {}", name);
let mut rng: StdRng = SeedableRng::from_seed([
10... | TestRunner | identifier_name |
perftest.rs | use std::fs::File;
use std::path::Path;
use std::time::Instant;
use perftest_data::PerftestData;
use protobuf::Message;
use protobuf::MessageFull;
use rand::Rng;
use rand::SeedableRng;
use rand::StdRng;
mod perftest_data;
fn measure_ns<R, F: FnMut() -> R>(mut f: F) -> (u64, R) {
let start = Instant::now();
l... |
}
}
fn main() {
let args = std::env::args().collect::<Vec<_>>();
if args.len() > 3 {
panic!("usage: {} [data_size] [test]", args[0])
}
let data_size = args
.iter()
.nth(1)
.map(|x| x.parse().unwrap())
.unwrap_or(1000000);
let selected = args.iter().nth(2).cl... | {
let name = self.selected.as_ref().map(|s| &s[..]).unwrap_or("bug");
panic!("no tests found with name {}", name);
} | conditional_block |
main.rs | use amiquip::{Connection, ConsumerMessage, ConsumerOptions, QueueDeclareOptions, Result};
fn main() -> Result<()> | other => {
println!("Consumer ended: {:?}", other);
break;
}
}
}
connection.close()
} | {
// Open connection.
let mut connection = Connection::insecure_open("amqp://guest:guest@mkstack_rabbitmq:5672")?;
// Open a channel - None says let the library choose the channel ID.
let channel = connection.open_channel(None)?;
// Declare the "hello" queue.
let queue = channel.queue_declare(... | identifier_body |
main.rs | use amiquip::{Connection, ConsumerMessage, ConsumerOptions, QueueDeclareOptions, Result};
fn main() -> Result<()> {
// Open connection.
let mut connection = Connection::insecure_open("amqp://guest:guest@mkstack_rabbitmq:5672")?;
// Open a channel - None says let the library choose the channel ID.
let ... | match message {
ConsumerMessage::Delivery(delivery) => {
let body = String::from_utf8_lossy(&delivery.body);
println!("({:>3}) Received [{}]", i, body);
consumer.ack(delivery)?;
}
other => {
println!("Consumer en... | random_line_split | |
main.rs | use amiquip::{Connection, ConsumerMessage, ConsumerOptions, QueueDeclareOptions, Result};
fn | () -> Result<()> {
// Open connection.
let mut connection = Connection::insecure_open("amqp://guest:guest@mkstack_rabbitmq:5672")?;
// Open a channel - None says let the library choose the channel ID.
let channel = connection.open_channel(None)?;
// Declare the "hello" queue.
let queue = chann... | main | identifier_name |
main.rs | //
// Copyright (C) 2017 Kubos Corporation
//
// 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 agree... |
fn main() {
let graphql_endpoint =
GraphQLHandler::new(context_factory, schema::QueryRoot, schema::MutationRoot);
let graphiql_endpoint = GraphiQLHandler::new("/grapihql");
let mut mount = mount::Mount::new();
mount.mount("/", graphql_endpoint);
mount.mount("/graphiql", graphiql_endpoint... | {
schema::Context { subsystem: model::Subsystem::new() }
} | identifier_body |
main.rs | //
// Copyright (C) 2017 Kubos Corporation
//
// 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 agree... | () {
let graphql_endpoint =
GraphQLHandler::new(context_factory, schema::QueryRoot, schema::MutationRoot);
let graphiql_endpoint = GraphiQLHandler::new("/grapihql");
let mut mount = mount::Mount::new();
mount.mount("/", graphql_endpoint);
mount.mount("/graphiql", graphiql_endpoint);
l... | main | identifier_name |
main.rs | //
// Copyright (C) 2017 Kubos Corporation
//
// 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 agree... | let graphql_endpoint =
GraphQLHandler::new(context_factory, schema::QueryRoot, schema::MutationRoot);
let graphiql_endpoint = GraphiQLHandler::new("/grapihql");
let mut mount = mount::Mount::new();
mount.mount("/", graphql_endpoint);
mount.mount("/graphiql", graphiql_endpoint);
let (l... |
fn main() { | random_line_split |
cfg.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 ... | <'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'static> {
let mut p = cx.new_parser_from_tts(tts);
let cfg = p.parse_meta_item();
if!p.eat(&token::Eof) {
cx.span_err(sp, "expected 1 cfg-pattern");... | expand_cfg | identifier_name |
cfg.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 mut p = cx.new_parser_from_tts(tts);
let cfg = p.parse_meta_item();
if !p.eat(&token::Eof) {
cx.span_err(sp, "expected 1 cfg-pattern");
return DummyResult::expr(sp);
}
let matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, &cx.cfg, &*cfg);
MacExpr::new(cx.exp... | identifier_body | |
cfg.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 attr;
use attr::*;
use parse::attr::ParserAttr;
use parse::token;
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'static> {
let mut p = cx.new_parser_from_tts(tts);
let cfg = p.parse_meta... | random_line_split | |
cfg.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 matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, &cx.cfg, &*cfg);
MacExpr::new(cx.expr_bool(sp, matches_cfg))
}
| {
cx.span_err(sp, "expected 1 cfg-pattern");
return DummyResult::expr(sp);
} | conditional_block |
mimetypearray.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
use dom::bindings::codegen::Bindings::MimeTypeArrayBin... | (global: &GlobalScope) -> DomRoot<MimeTypeArray> {
reflect_dom_object(
Box::new(MimeTypeArray::new_inherited()),
global,
MimeTypeArrayBinding::Wrap,
)
}
}
impl MimeTypeArrayMethods for MimeTypeArray {
// https://html.spec.whatwg.org/multipage/#dom-mimetypearr... | new | identifier_name |
mimetypearray.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
use dom::bindings::codegen::Bindings::MimeTypeArrayBin... |
// https://html.spec.whatwg.org/multipage/#dom-mimetypearray-item
fn IndexedGetter(&self, _index: u32) -> Option<DomRoot<MimeType>> {
None
}
// check-tidy: no specs after this line
fn NamedGetter(&self, _name: DOMString) -> Option<DomRoot<MimeType>> {
None
}
// https://he... | {
None
} | identifier_body |
mimetypearray.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
use dom::bindings::codegen::Bindings::MimeTypeArrayBin... |
impl MimeTypeArray {
pub fn new_inherited() -> MimeTypeArray {
MimeTypeArray {
reflector_: Reflector::new(),
}
}
pub fn new(global: &GlobalScope) -> DomRoot<MimeTypeArray> {
reflect_dom_object(
Box::new(MimeTypeArray::new_inherited()),
global,
... | } | random_line_split |
loader.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015, 2016 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your opti... | /// CPU the binary file is intended for.
#[derive(Clone,Copy,Debug)]
pub enum Machine {
/// 8-bit AVR
Avr,
/// AMD64
Amd64,
/// Intel x86
Ia32,
}
/// Parses a non-fat Mach-o binary from `bytes` at `offset` and creates a `Project` from it. Returns the `Project` instance and
/// the CPU its inten... | use uuid::Uuid;
| random_line_split |
loader.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015, 2016 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your opti... | (bytes: &[u8], offset: usize, name: String) -> Result<(Project, Machine)> {
let binary = mach::MachO::parse(&bytes, offset)?;
debug!("mach: {:#?}", &binary);
let mut base = 0x0;
let cputype = binary.header.cputype;
let (machine, mut reg) = match cputype {
mach::cputype::CPU_TYPE_X86 => {
... | load_mach | identifier_name |
loader.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015, 2016 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your opti... |
elf::header::EM_AVR => {
let reg = Region::undefined("Flash".to_string(), 0x2_0000);
(Machine::Avr, reg)
}
machine => return Err(format!("Unsupported machine: {}", machine).into()),
};
for ph in &binary.program_headers {
if ph.p_type == program_header::P... | {
let reg = Region::undefined("RAM".to_string(), 0x1_0000_0000);
(Machine::Ia32, reg)
} | conditional_block |
loader.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015, 2016 Panopticon authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your opti... | );
(Layer::undefined(0), 0)
} else {
debug!("mapped '{}': {:?}", name, offset..offset + size);
(Layer::wrap(bytes[offset..offset + size].to_vec()), size as u64)
}
} else {
debug!("... | {
let pe = pe::PE::parse(&bytes)?;
debug!("pe: {:#?}", &pe);
let image_base = pe.image_base as u64;
let mut ram = Region::undefined("RAM".to_string(), 0x100000000);
for section in &pe.sections {
let name = String::from_utf8_lossy(§ion.name);
debug!("section: {}", name);
l... | identifier_body |
c_str.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 ... | #[deprecated(since = "1.0.0", reason = "use CStr::from_ptr(p).to_bytes() instead")]
pub unsafe fn c_str_to_bytes<'a>(raw: &'a *const libc::c_char) -> &'a [u8] {
let len = libc::strlen(*raw);
slice::from_raw_parts(*(raw as *const _ as *const *const u8), len as usize)
}
/// Deprecated in favor of `CStr`
#[unstab... | }
}
/// Deprecated in favor of `CStr`
#[unstable(feature = "std_misc")] | random_line_split |
c_str.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, other: &CStr) -> Option<Ordering> {
self.to_bytes().partial_cmp(&other.to_bytes())
}
}
impl Ord for CStr {
fn cmp(&self, other: &CStr) -> Ordering {
self.to_bytes().cmp(&other.to_bytes())
}
}
/// Deprecated in favor of `CStr`
#[unstable(feature = "std_misc")]
#[deprecated(since = "1... | partial_cmp | identifier_name |
c_str.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 ... |
}
impl Error for NulError {
fn description(&self) -> &str { "nul byte found in data" }
}
impl fmt::Display for NulError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "nul byte found in provided data at position: {}", self.0)
}
}
impl FromError<NulError> for io::Error {
f... | { self.1 } | identifier_body |
test.rs | attr::first_attr_value_str_by_name(&krate.attrs,
"reexport_test_harness_main");
if should_test {
generate_test_harness(sess, reexport_test_harness_main, krate, cfg, span_diagnostic)
} else {
strip_test_functions(krate)
}
}
struct TestHarness... | (i: &ast::Item) -> bool {
i.attrs.iter().any(|attr| attr.check_name("ignore"))
}
fn should_panic(i: &ast::Item) -> ShouldPanic {
match i.attrs.iter().find(|attr| attr.check_name("should_panic")) {
Some(attr) => {
let msg = attr.meta_item_list()
.and_then(|list| list.iter().fi... | is_ignored | identifier_name |
test.rs | attr::first_attr_value_str_by_name(&krate.attrs,
"reexport_test_harness_main");
if should_test {
generate_test_harness(sess, reexport_test_harness_main, krate, cfg, span_diagnostic)
} else {
strip_test_functions(krate)
}
}
struct TestHarne... |
(it, sym)
}
fn generate_test_harness(sess: &ParseSess,
reexport_test_harness_main: Option<InternedString>,
krate: ast::Crate,
cfg: &ast::CrateConfig,
sd: &diagnostic::SpanHandler) -> ast::Crate {
let mut featur... | id: ast::DUMMY_NODE_ID,
node: ast::ItemMod(reexport_mod),
vis: ast::Public,
span: DUMMY_SP,
}); | random_line_split |
test.rs | attr::first_attr_value_str_by_name(&krate.attrs,
"reexport_test_harness_main");
if should_test | else {
strip_test_functions(krate)
}
}
struct TestHarnessGenerator<'a> {
cx: TestCtxt<'a>,
tests: Vec<ast::Ident>,
// submodule name, gensym'd identifier for re-exports
tested_submods: Vec<(ast::Ident, ast::Ident)>,
}
impl<'a> fold::Folder for TestHarnessGenerator<'a> {
fn fold_crate... | {
generate_test_harness(sess, reexport_test_harness_main, krate, cfg, span_diagnostic)
} | conditional_block |
test.rs |
struct TestHarnessGenerator<'a> {
cx: TestCtxt<'a>,
tests: Vec<ast::Ident>,
// submodule name, gensym'd identifier for re-exports
tested_submods: Vec<(ast::Ident, ast::Ident)>,
}
impl<'a> fold::Folder for TestHarnessGenerator<'a> {
fn fold_crate(&mut self, c: ast::Crate) -> ast::Crate {
... | {
// We generate the test harness when building in the 'test'
// configuration, either with the '--test' or '--cfg test'
// command line options.
let should_test = attr::contains_name(&krate.config, "test");
// Check for #[reexport_test_harness_main = "some_name"] which
// creates a `use some_n... | identifier_body | |
cache.rs | use crate::{
Context, ExecuteProcessRequest, ExecuteProcessRequestMetadata,
FallibleExecuteProcessResultWithPlatform, MultiPlatformExecuteProcessRequest, Platform,
};
use std::sync::Arc;
use bincode;
use bytes::Bytes;
use futures01::{future, Future};
use log::{debug, warn};
use protobuf::Message;
use boxfuture::{... | use serde::{Deserialize, Serialize};
use sharded_lmdb::ShardedLmdb;
use store::Store;
#[allow(dead_code)]
#[derive(Serialize, Deserialize)]
struct PlatformAndResponseBytes {
platform: Platform,
response_bytes: Vec<u8>,
}
#[derive(Clone)]
pub struct CommandRunner {
underlying: Arc<dyn crate::CommandRunner>,
pr... | random_line_split | |
cache.rs | use crate::{
Context, ExecuteProcessRequest, ExecuteProcessRequestMetadata,
FallibleExecuteProcessResultWithPlatform, MultiPlatformExecuteProcessRequest, Platform,
};
use std::sync::Arc;
use bincode;
use bytes::Bytes;
use futures01::{future, Future};
use log::{debug, warn};
use protobuf::Message;
use boxfuture::{... | .file_store
.store_file_bytes(result.stdout.clone(), true)
.join(
self
.file_store
.store_file_bytes(result.stderr.clone(), true),
)
.and_then(move |(stdout_digest, stderr_digest)| {
let action_result = execute_response.mut_result();
action_result.set_... | {
let mut execute_response = bazel_protos::remote_execution::ExecuteResponse::new();
execute_response.set_cached_result(true);
let action_result = execute_response.mut_result();
action_result.set_exit_code(result.exit_code);
action_result.mut_output_directories().push({
let mut directory = baz... | identifier_body |
cache.rs | use crate::{
Context, ExecuteProcessRequest, ExecuteProcessRequestMetadata,
FallibleExecuteProcessResultWithPlatform, MultiPlatformExecuteProcessRequest, Platform,
};
use std::sync::Arc;
use bincode;
use bytes::Bytes;
use futures01::{future, Future};
use log::{debug, warn};
use protobuf::Message;
use boxfuture::{... | (
&self,
fingerprint: Fingerprint,
result: &FallibleExecuteProcessResultWithPlatform,
) -> impl Future<Item = (), Error = String> {
let mut execute_response = bazel_protos::remote_execution::ExecuteResponse::new();
execute_response.set_cached_result(true);
let action_result = execute_response.... | store | identifier_name |
cache.rs | use crate::{
Context, ExecuteProcessRequest, ExecuteProcessRequestMetadata,
FallibleExecuteProcessResultWithPlatform, MultiPlatformExecuteProcessRequest, Platform,
};
use std::sync::Arc;
use bincode;
use bytes::Bytes;
use futures01::{future, Future};
use log::{debug, warn};
use protobuf::Message;
use boxfuture::{... |
},
)
}
fn store(
&self,
fingerprint: Fingerprint,
result: &FallibleExecuteProcessResultWithPlatform,
) -> impl Future<Item = (), Error = String> {
let mut execute_response = bazel_protos::remote_execution::ExecuteResponse::new();
execute_response.set_cached_result(true);
le... | {
future::ok(None).to_boxed()
} | conditional_block |
zip_longest.rs | use std::cmp::Ordering::{Equal, Greater, Less};
use super::size_hint;
use std::iter::Fuse;
use crate::either_or_both::EitherOrBoth;
// ZipLongest originally written by SimonSapin,
// and dedicated to itertools https://github.com/rust-lang/rust/pull/19283 | /// This iterator is *fused*.
///
/// See [`.zip_longest()`](../trait.Itertools.html#method.zip_longest) for more information.
#[derive(Clone, Debug)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct ZipLongest<T, U> {
a: Fuse<T>,
b: Fuse<U>,
}
/// Create a new `ZipLongest` ... |
/// An iterator which iterates two other iterators simultaneously
/// | random_line_split |
zip_longest.rs | use std::cmp::Ordering::{Equal, Greater, Less};
use super::size_hint;
use std::iter::Fuse;
use crate::either_or_both::EitherOrBoth;
// ZipLongest originally written by SimonSapin,
// and dedicated to itertools https://github.com/rust-lang/rust/pull/19283
/// An iterator which iterates two other iterators simultaneou... | <T, U>(a: T, b: U) -> ZipLongest<T, U>
where T: Iterator,
U: Iterator
{
ZipLongest {
a: a.fuse(),
b: b.fuse(),
}
}
impl<T, U> Iterator for ZipLongest<T, U>
where T: Iterator,
U: Iterator
{
type Item = EitherOrBoth<T::Item, U::Item>;
#[inline]
fn next(&m... | zip_longest | identifier_name |
zip_longest.rs | use std::cmp::Ordering::{Equal, Greater, Less};
use super::size_hint;
use std::iter::Fuse;
use crate::either_or_both::EitherOrBoth;
// ZipLongest originally written by SimonSapin,
// and dedicated to itertools https://github.com/rust-lang/rust/pull/19283
/// An iterator which iterates two other iterators simultaneou... |
}
impl<T, U> ExactSizeIterator for ZipLongest<T, U>
where T: ExactSizeIterator,
U: ExactSizeIterator
{}
| {
match self.a.len().cmp(&self.b.len()) {
Equal => match (self.a.next_back(), self.b.next_back()) {
(None, None) => None,
(Some(a), Some(b)) => Some(EitherOrBoth::Both(a, b)),
// These can only happen if .len() is inconsistent with .next_back()
... | identifier_body |
panic-recover-propagate.rs | // Copyright 2015 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 ... | {
panic::set_hook(Box::new(|_| {
A.fetch_add(1, Ordering::SeqCst);
}));
let result = thread::spawn(|| {
let result = panic::catch_unwind(|| {
panic!("hi there");
});
panic::resume_unwind(result.unwrap_err());
}).join();
let msg = *result.unwrap_err().do... | identifier_body | |
panic-recover-propagate.rs | // Copyright 2015 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 ... | () {
panic::set_hook(Box::new(|_| {
A.fetch_add(1, Ordering::SeqCst);
}));
let result = thread::spawn(|| {
let result = panic::catch_unwind(|| {
panic!("hi there");
});
panic::resume_unwind(result.unwrap_err());
}).join();
let msg = *result.unwrap_err()... | main | identifier_name |
panic-recover-propagate.rs | // Copyright 2015 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.
// run-pass
// igno... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
caller-location-fnptr-rt-ctfe-equiv.rs | // Ensure that a `#[track_caller]` function, returning `caller_location()`,
// which coerced (to a function pointer) and called, inside a `const fn`,
// in turn called, results in the same output irrespective of whether
// we're in a const or runtime context.
// run-pass
// compile-flags: -Z unleash-the-miri-inside-of... | type L = &'static std::panic::Location<'static>;
#[track_caller]
const fn attributed() -> L {
std::intrinsics::caller_location()
}
const fn calling_attributed() -> L {
// We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
let ptr: fn() -> L = attributed;
ptr()
}... | random_line_split | |
caller-location-fnptr-rt-ctfe-equiv.rs | // Ensure that a `#[track_caller]` function, returning `caller_location()`,
// which coerced (to a function pointer) and called, inside a `const fn`,
// in turn called, results in the same output irrespective of whether
// we're in a const or runtime context.
// run-pass
// compile-flags: -Z unleash-the-miri-inside-of... |
fn main() {
const CONSTANT: L = calling_attributed();
let runtime = calling_attributed();
assert_eq!(
(runtime.file(), runtime.line(), runtime.column()),
(CONSTANT.file(), CONSTANT.line(), CONSTANT.column()),
);
}
| {
// We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
let ptr: fn() -> L = attributed;
ptr()
} | identifier_body |
caller-location-fnptr-rt-ctfe-equiv.rs | // Ensure that a `#[track_caller]` function, returning `caller_location()`,
// which coerced (to a function pointer) and called, inside a `const fn`,
// in turn called, results in the same output irrespective of whether
// we're in a const or runtime context.
// run-pass
// compile-flags: -Z unleash-the-miri-inside-of... | () -> L {
// We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
let ptr: fn() -> L = attributed;
ptr()
}
fn main() {
const CONSTANT: L = calling_attributed();
let runtime = calling_attributed();
assert_eq!(
(runtime.file(), runtime.line(), runtim... | calling_attributed | identifier_name |
main.rs | // Copyright 2014-2016 Martin Kojtal (0xc0170)
//
// 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... | {
use kl25z_map::*;
let sim = Sim::get();
sim.scgc5.bitwise_inc_or(0x400);
let portb = Port::get(1);
portb.pcr[18].set(1 << 8);
let ptb = Gpio::get(1);
ptb.pddr.set(1 << 18);
ptb.psor.set(1 << 18);
loop {
delay(500000);
ptb.ptor.set(1 << 18);
}
} | identifier_body | |
main.rs | // Copyright 2014-2016 Martin Kojtal (0xc0170)
//
// 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
// | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![no_std]
#![crate_type = "rlib"]
#![feature(lang_items, asm)]
#![feature(core_intrinsics)]
#![allow(dead_code)]
#![allow(non_snake_case... | // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, | random_line_split |
main.rs | // Copyright 2014-2016 Martin Kojtal (0xc0170)
//
// 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... | (mut cycles: u32)
{
while cycles > 0 {
unsafe {
asm!("nop" :::: "volatile");
}
cycles -= 1;
}
}
#[no_mangle]
pub fn main()
{
use kl25z_map::*;
let sim = Sim::get();
sim.scgc5.bitwise_inc_or(0x400);
let portb = Port::get(1);
portb.pcr[18].set(1 << 8);
... | delay | identifier_name |
sparc64.rs | // Copyright 2014-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-MI... | <'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>)
-> Option<Uniform>
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
arg.layout.homogeneous_aggregate(cx).and_then(|unit| {
// Ensure we have at most e... | is_homogeneous_aggregate | identifier_name |
sparc64.rs | // Copyright 2014-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-MI... | })
}
fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
if!ret.layout.is_aggregate() {
ret.extend_integer_width_to(64);
return;
}
if let Some(uniform... | None
} | random_line_split |
sparc64.rs | // Copyright 2014-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-MI... |
// don't return aggregates in registers
ret.make_indirect();
}
fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
if!arg.layout.is_aggregate() {
arg.extend_inte... | {
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(64);
return;
}
if let Some(uniform) = is_homogeneous_aggregate(cx, ret) {
ret.cast_to(uniform);
return;
}
let size = ret.layout.size;
let bits = size.bits();
if bits <= 256 {
let unit = Reg... | identifier_body |
method-ufcs-2.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn annot_reference_any_lifetime() {
let a = 22;
let b = 44;
let c = 66;
<_ as Bazoom<&u32>>::method(a, &b, c); // OK
}
fn annot_reference_static_lifetime() {
let a = 22;
let b = 44;
let c = 66;
let x = <&'static u32 as Bazoom<_>>::method;
x(&a, b, c); //~ ERROR
}
fn annot_referen... | {
let a = 22;
let b = 44;
let c = 66;
<_ as Bazoom<_>>::method(a, &b, c); // OK
} | identifier_body |
method-ufcs-2.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let a = 22;
let b = 44;
let c = 66;
<_ as Bazoom<&u32>>::method(a, &b, c); // OK
}
fn annot_reference_static_lifetime() {
let a = 22;
let b = 44;
let c = 66;
let x = <&'static u32 as Bazoom<_>>::method;
x(&a, b, c); //~ ERROR
}
fn annot_reference_named_lifetime<'a>(_d: &'a u32... | annot_reference_any_lifetime | identifier_name |
method-ufcs-2.rs | // Copyright 2017 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.
// Unit test for... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | random_line_split |
compute_squared_distance.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 animate::AnimationVariantAttrs;
use cg;
use quote::Tokens;
use syn::{DeriveInput, Path};
pub fn derive(input:... | ;
Some(quote! {
(&#this_pattern, &#other_pattern) => {
Ok(#sum)
}
})
}));
if append_error_clause {
if let Some(fallback) = input_attrs.fallback {
match_body.append(quote! {
(this, other) => #fallback(this, other)
... | {
let mut sum = quote!();
sum.append_separated(this_info.iter().zip(&other_info).map(|(this, other)| {
where_clause.add_trait_bound(&this.field.ty);
quote! {
::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)?
... | conditional_block |
compute_squared_distance.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 animate::AnimationVariantAttrs;
use cg;
use quote::Tokens;
use syn::{DeriveInput, Path};
pub fn | (input: DeriveInput) -> Tokens {
let name = &input.ident;
let trait_path = &["values", "distance", "ComputeSquaredDistance"];
let (impl_generics, ty_generics, mut where_clause) =
cg::trait_parts(&input, trait_path);
let input_attrs = cg::parse_input_attrs::<DistanceInputAttrs>(&input);
let ... | derive | identifier_name |
compute_squared_distance.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 animate::AnimationVariantAttrs;
use cg;
use quote::Tokens;
use syn::{DeriveInput, Path};
pub fn derive(input:... | let attrs = cg::parse_variant_attrs::<AnimationVariantAttrs>(variant);
if attrs.error {
append_error_clause = true;
return None;
}
let name = cg::variant_ctor(&input, variant);
let (this_pattern, this_info) = cg::ref_pattern(&name, &variant, "this");
... | let mut match_body = quote!();
let mut append_error_clause = variants.len() > 1;
match_body.append_all(variants.iter().map(|variant| { | random_line_split |
storage.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/metadevs/storage.rs
// - Storage (block device) subsystem
use prelude::*;
use core::sync::atomic::{AtomicUsize,ATOMIC_USIZE_INIT};
use sync::mutex::LazyMutex;
use lib::{VecMap};
use lib::mem::Arc;
module_define!{Storage, [], init}
pub type AsyncIoResul... | (&mut self)
{
todo!("PhysicalVolumeReg::drop idx={}", self.idx);
}
}
impl ::core::fmt::Display for SizePrinter
{
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result
{
const THRESHOLD: u64 = 4096; // Largest value
if self.0 < THRESHOLD
{
write!(f, "{}B", self.0)
}
else if self.0 < TH... | drop | identifier_name |
storage.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/metadevs/storage.rs
// - Storage (block device) subsystem
use prelude::*;
use core::sync::atomic::{AtomicUsize,ATOMIC_USIZE_INIT};
use sync::mutex::LazyMutex;
use lib::{VecMap};
use lib::mem::Arc;
module_define!{Storage, [], init}
pub type AsyncIoResul... |
else {
idx_rem -= v.block_count as u64;
}
}
}
None
}
#[allow(dead_code)]
/// Read a series of blocks from the volume into the provided buffer.
///
/// The buffer must be a multiple of the logical block size
pub fn read_blocks(&self, idx: u64, dst: &mut [u8]) -> Result<(),IoError> {
log_t... | {
let ret_count = ::core::cmp::min(
v.block_count as u64 - idx_rem,
count as u64
) as usize;
return Some( (v.volume, v.first_block + idx_rem, ret_count) );
} | conditional_block |
storage.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/metadevs/storage.rs
// - Storage (block device) subsystem
use prelude::*;
use core::sync::atomic::{AtomicUsize,ATOMIC_USIZE_INIT};
use sync::mutex::LazyMutex;
use lib::{VecMap};
use lib::mem::Arc;
module_define!{Storage, [], init}
pub type AsyncIoResul... | }
}
}
None
}
#[allow(dead_code)]
/// Read a series of blocks from the volume into the provided buffer.
///
/// The buffer must be a multiple of the logical block size
pub fn read_blocks(&self, idx: u64, dst: &mut [u8]) -> Result<(),IoError> {
log_trace!("VolumeHandle::read_blocks(idx={}, dst={{len... | return Some( (v.volume, v.first_block + idx_rem, ret_count) );
}
else {
idx_rem -= v.block_count as u64; | random_line_split |
storage.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/metadevs/storage.rs
// - Storage (block device) subsystem
use prelude::*;
use core::sync::atomic::{AtomicUsize,ATOMIC_USIZE_INIT};
use sync::mutex::LazyMutex;
use lib::{VecMap};
use lib::mem::Arc;
module_define!{Storage, [], init}
pub type AsyncIoResul... |
/// Register a physical volume
pub fn register_pv(dev: Box<PhysicalVolume>) -> PhysicalVolumeReg
{
log_trace!("register_pv(pv = \"{}\")", dev.name());
let pv_id = S_NEXT_PV_IDX.fetch_add(1, ::core::sync::atomic::Ordering::Relaxed);
// Now that a new PV has been inserted, handlers should be informed
let mut best_... | {
S_PHYSICAL_VOLUMES.init( || VecMap::new() );
S_LOGICAL_VOLUMES.init( || VecMap::new() );
S_MAPPERS.init( || Vec::new() );
// Default mapper just exposes the PV as a single LV
//S_MAPPERS.lock().push_back(&default_mapper::Mapper);
} | identifier_body |
file_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 http://mozilla.org/MPL/2.0/. */
use resource_task::{ProgressMsg, Metadata, Payload, Done, LoaderTask, start_sending};
use std::io;
use std::io::F... | (reader: &mut io::Stream, progress_chan: &Sender<ProgressMsg>)
-> Result<(), ()> {
loop {
let mut buf = ~[];
match reader.push_exact(&mut buf, READ_SIZE) {
Ok(_) => progress_chan.send(Payload(buf)),
Err(e) => match e.kind {
io::EndOfFile => return Ok((... | read_all | identifier_name |
file_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 http://mozilla.org/MPL/2.0/. */
use resource_task::{ProgressMsg, Metadata, Payload, Done, LoaderTask, start_sending};
use std::io;
use std::io::F... | }
};
});
};
f
} | let res = read_all(reader as &mut io::Stream, &progress_chan);
progress_chan.send(Done(res));
}
Err(_) => {
progress_chan.send(Done(Err(()))); | random_line_split |
file_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 http://mozilla.org/MPL/2.0/. */
use resource_task::{ProgressMsg, Metadata, Payload, Done, LoaderTask, start_sending};
use std::io;
use std::io::F... |
pub fn factory() -> LoaderTask {
let f: LoaderTask = proc(url, start_chan) {
assert!("file" == url.scheme);
let progress_chan = start_sending(start_chan, Metadata::default(url.clone()));
spawn_named("file_loader", proc() {
match File::open_mode(&Path::new(url.path), io::Open, i... | {
loop {
let mut buf = ~[];
match reader.push_exact(&mut buf, READ_SIZE) {
Ok(_) => progress_chan.send(Payload(buf)),
Err(e) => match e.kind {
io::EndOfFile => return Ok(()),
_ => return Err(()),
}
}
}
} | identifier_body |
build.rs | extern crate protoc;
extern crate protoc_rust;
use std::env;
use std::fs;
fn main() {
if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() {
generate_protocols();
}
}
fn generate_protocols() |
fn protocol_files() -> Vec<String> {
let mut files = vec![];
for entry in fs::read_dir("protocols").unwrap() {
let file = entry.unwrap();
// skip vim temp files
if file.file_name().to_str().unwrap().starts_with(".") {
continue;
}
if file.metadata().unwrap().... | {
let protocols = protocol_files();
protoc_rust::run(protoc_rust::Args {
out_dir: "src/generated",
input: protocols
.iter()
.map(AsRef::as_ref)
.collect::<Vec<&str>>()
.as_slice(),
includes: &["protocols"],
}).expect("protoc");
} | identifier_body |
build.rs | extern crate protoc;
extern crate protoc_rust;
use std::env;
use std::fs;
fn | () {
if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() {
generate_protocols();
}
}
fn generate_protocols() {
let protocols = protocol_files();
protoc_rust::run(protoc_rust::Args {
out_dir: "src/generated",
input: protocols
.iter()
.map(AsRef::as_ref)
... | main | identifier_name |
build.rs | extern crate protoc;
extern crate protoc_rust;
use std::env;
use std::fs;
fn main() {
if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() |
}
fn generate_protocols() {
let protocols = protocol_files();
protoc_rust::run(protoc_rust::Args {
out_dir: "src/generated",
input: protocols
.iter()
.map(AsRef::as_ref)
.collect::<Vec<&str>>()
.as_slice(),
includes: &["protocols"],
}).ex... | {
generate_protocols();
} | conditional_block |
build.rs | extern crate protoc;
extern crate protoc_rust;
use std::env;
use std::fs;
fn main() {
if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() {
generate_protocols();
}
}
fn generate_protocols() {
let protocols = protocol_files();
protoc_rust::run(protoc_rust::Args {
out_dir: "src/generated",
... | fn protocol_files() -> Vec<String> {
let mut files = vec![];
for entry in fs::read_dir("protocols").unwrap() {
let file = entry.unwrap();
// skip vim temp files
if file.file_name().to_str().unwrap().starts_with(".") {
continue;
}
if file.metadata().unwrap().is... | }).expect("protoc");
}
| random_line_split |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... |
/// A class that performs whatever setup we need to safely make a call while
/// this class is on the stack. After `new` returns, the call is safe to make.
pub struct CallSetup {
/// The compartment for reporting exceptions.
/// As a RootedObject, this must be the first field in order to
/// determine the... | {
rval.set(p.reflector().get_jsobject().get());
assert!(!rval.get().is_null());
unsafe {
if !JS_WrapObject(cx, rval) {
rval.set(ptr::null_mut());
}
}
} | identifier_body |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... | () -> CallbackFunction {
CallbackFunction {
object: CallbackObject {
callback: Heap::default(),
},
}
}
/// Initialize the callback function with a value.
/// Should be called once this object is done moving.
pub fn init(&mut self, callback: *mut J... | new | identifier_name |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... |
unsafe {
JS_EndRequest(self.cx);
}
}
}
| {
unsafe {
let old_global = RootedObject::new(self.cx, self.exception_compartment.ptr);
let saved = JS_SaveFrameChain(self.cx);
{
let _ac = JSAutoCompartment::new(self.cx, old_global.ptr);
JS_ReportPendingException(self.... | conditional_block |
callback.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/. */
//! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible};
use dom::bindings::glob... | }
}
/// A class that performs whatever setup we need to safely make a call while
/// this class is on the stack. After `new` returns, the call is safe to make.
pub struct CallSetup {
/// The compartment for reporting exceptions.
/// As a RootedObject, this must be the first field in order to
/// determ... | if !JS_WrapObject(cx, rval) {
rval.set(ptr::null_mut());
} | random_line_split |
main.rs | extern crate liner;
extern crate termion;
use std::mem::replace;
use std::env::{args, current_dir};
use std::io;
use liner::{Context, CursorPosition, Event, EventKind, FilenameCompleter};
fn main() | // Figure out of we are completing a command (the first word) or a filename.
let filename = match pos {
CursorPosition::InWord(i) => i > 0,
CursorPosition::InSpace(Some(_), _) => true,
CursorPosition::InSpace(None, _) => false,
... | {
let mut con = Context::new();
let history_file = args().nth(1);
match history_file {
Some(ref file_name) => println!("History file: {}", file_name),
None => println!("No history file"),
}
con.history.set_file_name(history_file);
if con.history.file_name().is_some() {
... | identifier_body |
main.rs | extern crate liner;
extern crate termion;
use std::mem::replace;
use std::env::{args, current_dir};
use std::io;
use liner::{Context, CursorPosition, Event, EventKind, FilenameCompleter};
fn | () {
let mut con = Context::new();
let history_file = args().nth(1);
match history_file {
Some(ref file_name) => println!("History file: {}", file_name),
None => println!("No history file"),
}
con.history.set_file_name(history_file);
if con.history.file_name().is_some() {
... | main | identifier_name |
main.rs | extern crate liner;
extern crate termion;
use std::mem::replace;
use std::env::{args, current_dir};
use std::io;
use liner::{Context, CursorPosition, Event, EventKind, FilenameCompleter};
fn main() {
let mut con = Context::new();
let history_file = args().nth(1);
match history_file {
Some(ref fi... | // ctrl-d pressed
io::ErrorKind::UnexpectedEof => {
println!("exiting...");
break;
}
_ => {
// Ensure that all writes to the history file
// are... | match e.kind() {
// ctrl-c pressed
io::ErrorKind::Interrupted => {} | random_line_split |
lib.rs | //! Airbrake Rust is an [Airbrake][airbrake.io] notifier library for the Rust
//! Programming language. The library provides minimalist API that enables the
//! ability to send Rust errors to the Airbrake dashboard.
//!
//! Installation
//! ------------
//!
//! Add the crate to your Cargo.toml:
//!
//! ```toml
//! [dep... | <F>(builder_callback: F) -> AirbrakeClient
where
F: Fn(&mut AirbrakeClientBuilder),
{
AirbrakeClient::builder()
.configure(builder_callback)
.build()
.expect("Airbrake configuration failed")
}
| configure | identifier_name |
lib.rs | //! Airbrake Rust is an [Airbrake][airbrake.io] notifier library for the Rust
//! Programming language. The library provides minimalist API that enables the
//! ability to send Rust errors to the Airbrake dashboard.
//!
//! Installation
//! ------------
//!
//! Add the crate to your Cargo.toml:
//!
//! ```toml
//! [dep... | //!
//!
//! The Notice module contains the various structs that make up an Airbrake
//! Notice. A Notice primarily contains NoticeErrors, which represents the error
//! itself. Other parts of the of Notice are Context, Environment, Session and
//! Parameters.
//!
//! Typically you won't need to work with the NoticeErro... | //!
//! | random_line_split |
lib.rs | //! Airbrake Rust is an [Airbrake][airbrake.io] notifier library for the Rust
//! Programming language. The library provides minimalist API that enables the
//! ability to send Rust errors to the Airbrake dashboard.
//!
//! Installation
//! ------------
//!
//! Add the crate to your Cargo.toml:
//!
//! ```toml
//! [dep... | {
AirbrakeClient::builder()
.configure(builder_callback)
.build()
.expect("Airbrake configuration failed")
} | identifier_body | |
mysql.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use clap::Args;
/// Command line arguments for controlling MySql
// Defaults are derived from `sql_ext::facebook::mysql`
// https://fburl.... | /// MySql connection pool per key limit
#[clap(long, default_value = "100")]
pub mysql_pool_per_key_limit: u64,
/// Number of threads in MySql connection pool (number of real pools)
#[clap(long, default_value = "10")]
pub mysql_pool_threads_num: i32,
/// Mysql connection pool age timeout i... |
/// Size of the MySql connection pool
#[clap(long, default_value = "10000")]
pub mysql_pool_limit: usize,
| random_line_split |
mysql.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use clap::Args;
/// Command line arguments for controlling MySql
// Defaults are derived from `sql_ext::facebook::mysql`
// https://fburl.... | {
/// Connect to MySql master only.
#[clap(long)]
pub mysql_master_only: bool,
/// Size of the MySql connection pool
#[clap(long, default_value = "10000")]
pub mysql_pool_limit: usize,
/// MySql connection pool per key limit
#[clap(long, default_value = "100")]
pub mysql_pool_per_... | MysqlArgs | identifier_name |
ratings.rs | use super::*;
use crate::{core::util, infrastructure::flows::prelude as flows};
#[post("/ratings", format = "application/json", data = "<data>")]
pub fn post_rating(
connections: sqlite::Connections,
mut search_engine: tantivy::SearchEngine,
data: Json<usecases::NewPlaceRating>,
) -> Result<()> {
let ... | json::Rating {
id: r.id.into(),
created: r.created_at.into_seconds(),
title: r.title,
value: r.value.into(),
context: r.context.into(),
source: r.source.unwrap_or_default(),
comments,
... | {
// TODO: RESTful API
// - Only lookup and return a single entity
// - Add a new action and method for getting multiple ids at once
let ids = util::split_ids(&ids);
if ids.is_empty() {
return Ok(Json(vec![]));
}
let ratings_with_comments = usecases::load_ratings_with_comments(&*... | identifier_body |
ratings.rs | use super::*;
use crate::{core::util, infrastructure::flows::prelude as flows};
#[post("/ratings", format = "application/json", data = "<data>")]
pub fn | (
connections: sqlite::Connections,
mut search_engine: tantivy::SearchEngine,
data: Json<usecases::NewPlaceRating>,
) -> Result<()> {
let _ = flows::create_rating(&connections, &mut search_engine, data.into_inner())?;
Ok(Json(()))
}
#[get("/ratings/<ids>")]
pub fn load_rating(db: sqlite::Connection... | post_rating | identifier_name |
ratings.rs | use super::*;
use crate::{core::util, infrastructure::flows::prelude as flows};
#[post("/ratings", format = "application/json", data = "<data>")]
pub fn post_rating(
connections: sqlite::Connections, | Ok(Json(()))
}
#[get("/ratings/<ids>")]
pub fn load_rating(db: sqlite::Connections, ids: String) -> Result<Vec<json::Rating>> {
// TODO: RESTful API
// - Only lookup and return a single entity
// - Add a new action and method for getting multiple ids at once
let ids = util::split_ids(&ids);
... | mut search_engine: tantivy::SearchEngine,
data: Json<usecases::NewPlaceRating>,
) -> Result<()> {
let _ = flows::create_rating(&connections, &mut search_engine, data.into_inner())?; | random_line_split |
ratings.rs | use super::*;
use crate::{core::util, infrastructure::flows::prelude as flows};
#[post("/ratings", format = "application/json", data = "<data>")]
pub fn post_rating(
connections: sqlite::Connections,
mut search_engine: tantivy::SearchEngine,
data: Json<usecases::NewPlaceRating>,
) -> Result<()> {
let ... |
let ratings_with_comments = usecases::load_ratings_with_comments(&*db.shared()?, &ids)?;
let result = ratings_with_comments
.into_iter()
.map(|(r, cs)| {
let comments = cs
.into_iter()
.map(|c| json::Comment {
id: c.id.clone().into(),
... | {
return Ok(Json(vec![]));
} | conditional_block |
bitops.rs | //Thanks to sanxiyn at irc.orinzer.org
pub trait Bitops {
fn bit_length() -> usize;
fn bit_mask() -> Self;
}
impl Bitops for u8 {
fn bit_length() -> usize { 8usize }
fn bit_mask() -> u8 { 0xFFu8 }
}
impl Bitops for u16 {
fn bit_length() -> usize { 16usize }
fn bit_mask() -> u16 { 0xFFFFu16 }... | }
pub fn bit_mask<T: Bitops>() -> T {
T::bit_mask()
} | random_line_split | |
bitops.rs | //Thanks to sanxiyn at irc.orinzer.org
pub trait Bitops {
fn bit_length() -> usize;
fn bit_mask() -> Self;
}
impl Bitops for u8 {
fn bit_length() -> usize { 8usize }
fn bit_mask() -> u8 { 0xFFu8 }
}
impl Bitops for u16 {
fn bit_length() -> usize { 16usize }
fn bit_mask() -> u16 { 0xFFFFu16 }... | <T: Bitops>() -> T {
T::bit_mask()
}
| bit_mask | identifier_name |
bitops.rs | //Thanks to sanxiyn at irc.orinzer.org
pub trait Bitops {
fn bit_length() -> usize;
fn bit_mask() -> Self;
}
impl Bitops for u8 {
fn bit_length() -> usize { 8usize }
fn bit_mask() -> u8 { 0xFFu8 }
}
impl Bitops for u16 {
fn bit_length() -> usize { 16usize }
fn bit_mask() -> u16 { 0xFFFFu16 }... | {
T::bit_mask()
} | identifier_body | |
sepcomp-lib.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 ... | {
assert_eq!(one(), 1);
assert_eq!(two(), 2);
assert_eq!(three(), 3);
} | identifier_body | |
sepcomp-lib.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 ... | } | assert_eq!(two(), 2);
assert_eq!(three(), 3); | random_line_split |
sepcomp-lib.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 ... | () {
assert_eq!(one(), 1);
assert_eq!(two(), 2);
assert_eq!(three(), 3);
}
| main | identifier_name |
connection_interface.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use interner::{Intern, StringKey};
use serde::{Deserialize, Serialize};
/// Configuration where Relay should expect some fields i... |
}
| {
ConnectionInterface {
cursor: "cursor".intern(),
edges: "edges".intern(),
end_cursor: "endCursor".intern(),
has_next_page: "hasNextPage".intern(),
has_previous_page: "hasPreviousPage".intern(),
node: "node".intern(),
page_info... | identifier_body |
connection_interface.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use interner::{Intern, StringKey};
use serde::{Deserialize, Serialize};
/// Configuration where Relay should expect some fields i... | start_cursor: "startCursor".intern(),
}
}
} | random_line_split | |
connection_interface.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use interner::{Intern, StringKey};
use serde::{Deserialize, Serialize};
/// Configuration where Relay should expect some fields i... | () -> Self {
ConnectionInterface {
cursor: "cursor".intern(),
edges: "edges".intern(),
end_cursor: "endCursor".intern(),
has_next_page: "hasNextPage".intern(),
has_previous_page: "hasPreviousPage".intern(),
node: "node".intern(),
... | default | identifier_name |
class-separate-impl.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 ... |
impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
}
i... | }
} | random_line_split |
class-separate-impl.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&mut self) {
error!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
}
impl ToStr for cat {
... | meow | identifier_name |
class-separate-impl.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 {
error!("Not hungry!");
return false;
}
}
}
impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> ... | {
error!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} | conditional_block |
class-separate-impl.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 print_out(thing: @ToStr, expected: ~str) {
let actual = thing.to_str();
info!("%s", actual);
assert_eq!(actual, expected);
}
pub fn main() {
let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
print_out(nyan, ~"nyan");
}
| {
self.name.clone()
} | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
/// Data that the style system associates with a node. When the
/// style system is being used standalone, this is all that hangs
/// off the node. This must be first to permit the various
/// transmutations between ElementData and PersistentLayoutData.
pub style_data: ElementData,
/// Infor... | PartialPersistentLayoutData | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
static TYPES: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
TYPES.iter().any(|&type_| uri.starts_with(type_))
} | identifier_body | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | }
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum LayoutNodeType {
Element(LayoutElementType),
Text,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum LayoutElementType {
Element,
HTMLCanvasElement,
HTMLIFrameElement,
HTMLImageElement,
HTMLInputElement,
HTM... | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.