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
shard.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 anyhow::Error; use context::{CoreContext, PerfCounterType}; use futures_stats::TimedTryFutureExt; use std::collections::hash_map::Defau...
stats.completion_time.as_millis_unchecked() as i64, ); Ok(permit) } } pub struct Shards { semaphores: Vec<Semaphore>, perf_counter_type: PerfCounterType, } impl Shards { pub fn new(shard_count: NonZeroUsize, perf_counter_type: PerfCounterType) -> Self { let semapho...
random_line_split
keymap.rs
. /// /// Note that most of the time, we don't want to pursue autoloads. /// Functions like `Faccessible_keymaps` which scan entire keymap trees /// shouldn't load every autoloaded keymap. I'm not sure about this, /// but it seems to me that only `read_key_sequence`, `Flookup_key`, and /// `Fdefine_key` should cause k...
key_binding
identifier_name
keymap.rs
` #[no_mangle] pub extern "C" fn get_where_is_cache() -> LispObject { unsafe { where_is_cache } } /// Allows the C code to set the value of `where_is_cache` #[no_mangle] pub extern "C" fn set_where_is_cache(val: LispObject) { unsafe { where_is_cache = val; } } // Which keymaps are reverse-stored i...
/// Return t if OBJECT is a keymap. /// /// A keymap is a list (keymap. ALIST), /// or a symbol whose function definition is itself a keymap. /// ALIST elements look like (CHAR. DEFN) or (SYMBOL. DEFN); /// a vector of densely packed bindings for small character codes /// is also allowed as an element. #[lisp_fn] pub...
{ let tail: LispObject = if string.is_not_nil() { list!(string) } else { Qnil }; let char_table = unsafe { Fmake_char_table(Qkeymap, Qnil) }; (Qkeymap, (char_table, tail)) }
identifier_body
keymap.rs
` #[no_mangle] pub extern "C" fn get_where_is_cache() -> LispObject { unsafe { where_is_cache } } /// Allows the C code to set the value of `where_is_cache` #[no_mangle] pub extern "C" fn set_where_is_cache(val: LispObject) { unsafe { where_is_cache = val; } } // Which keymaps are reverse-stored i...
} if!map.is_cons() { map = get_keymap(map, false, autoload); } } } /// Call FUNCTION once for each event binding in KEYMAP. /// FUNCTION is called with two arguments: the event that is bound, and /// the definition it is bound to. The event may be a character range. /// /// I...
{ map = map_keymap_internal(map, fun, args, data); }
conditional_block
keymap.rs
cache` #[no_mangle] pub extern "C" fn get_where_is_cache() -> LispObject { unsafe { where_is_cache } } /// Allows the C code to set the value of `where_is_cache` #[no_mangle] pub extern "C" fn set_where_is_cache(val: LispObject) { unsafe { where_is_cache = val; } } // Which keymaps are reverse-sto...
/// (define-key map...) ///...) /// /// After performing `copy-keymap', the copy starts out with the same definitions /// of KEYMAP, but changing either the copy or KEYMAP does not affect the other. /// Any key definitions that are subkeymaps are recursively copied. /// However, a key definition which is a symbol whose...
/// (set-keymap-parent map <theirmap>)
random_line_split
slice.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let b = [1, 2, 4, 6, 8, 9]; assert!(b.binary_search_by(|v| v.cmp(&6)) == Ok(3)); let b = [1, 2, 4, 6, 8, 9]; assert!(b.binary_search_by(|v| v.cmp(&5)) == Err(3)); let b = [1, 2, 4, 6, 7, 8, 9]; assert!(b.binary_search_by(|v| v.cmp(&6)) == Ok(3)); let b = [1, 2, 4, 6, 7, 8, 9]; assert!(b....
random_line_split
slice.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut iter = data.iter_mut(); assert_eq!(&iter[], &other_data[]); // mutability: assert!(&mut iter[] == other_data); iter.next(); assert_eq!(&iter[], &other_data[1..]); assert!(&mut iter[] ==...
{ macro_rules! test { ($data: expr) => {{ let data: &mut [_] = &mut $data; let other_data: &mut [_] = &mut $data; { let mut iter = data.iter(); assert_eq!(&iter[], &other_data[]); iter.next(); assert_eq!(&i...
identifier_body
slice.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 ...
() { macro_rules! test { ($data: expr) => {{ let data: &mut [_] = &mut $data; let other_data: &mut [_] = &mut $data; { let mut iter = data.iter(); assert_eq!(&iter[], &other_data[]); iter.next(); assert_eq!...
iterator_to_slice
identifier_name
main.rs
use std::fs::File; use std::io::prelude::*; fn get_input() -> Vec<u8> { let mut file = File::open("input.txt").unwrap(); let mut content = Vec::new(); file.read_to_end(&mut content).unwrap(); for i in 0.. content.len() { content[i] = content[i] - ('0' as u8); } content } fn offset_su...
} sum } fn main() { let input = get_input(); println!("Part 1 total: {}", offset_sum(&input, 1)); println!("Part 2 total: {}", offset_sum(&input, input.len()/2)); }
}
random_line_split
main.rs
use std::fs::File; use std::io::prelude::*; fn get_input() -> Vec<u8>
fn offset_sum(input: &[u8], offset: usize) -> i32 { let len = input.len(); let mut sum = 0; for i in 0.. len { let j = (i + offset) % len; if input[i] == input[j] { sum += input[i] as i32; } } sum } fn main() { let input = get_input(); println!("Part...
{ let mut file = File::open("input.txt").unwrap(); let mut content = Vec::new(); file.read_to_end(&mut content).unwrap(); for i in 0 .. content.len() { content[i] = content[i] - ('0' as u8); } content }
identifier_body
main.rs
use std::fs::File; use std::io::prelude::*; fn get_input() -> Vec<u8> { let mut file = File::open("input.txt").unwrap(); let mut content = Vec::new(); file.read_to_end(&mut content).unwrap(); for i in 0.. content.len() { content[i] = content[i] - ('0' as u8); } content } fn offset_su...
} sum } fn main() { let input = get_input(); println!("Part 1 total: {}", offset_sum(&input, 1)); println!("Part 2 total: {}", offset_sum(&input, input.len()/2)); }
{ sum += input[i] as i32; }
conditional_block
main.rs
use std::fs::File; use std::io::prelude::*; fn get_input() -> Vec<u8> { let mut file = File::open("input.txt").unwrap(); let mut content = Vec::new(); file.read_to_end(&mut content).unwrap(); for i in 0.. content.len() { content[i] = content[i] - ('0' as u8); } content } fn offset_su...
() { let input = get_input(); println!("Part 1 total: {}", offset_sum(&input, 1)); println!("Part 2 total: {}", offset_sum(&input, input.len()/2)); }
main
identifier_name
osc_writer.rs
use std::convert::TryInto; use std::io::Write; use byteorder::{BigEndian, WriteBytesExt}; use error::ResultE; /// auto-implemented trait to write OSC data to a Write object. pub trait OscWriter: Write { fn osc_write_i32(&mut self, value: i32) -> ResultE<()> { Ok(self.write_i32::<BigEndian>(value)?) } ...
let zeros = b"\0\0\0\0"; Ok(self.write_all(&zeros[..pad_bytes])?) } fn write_blob_tag(&mut self) -> ResultE<()> { Ok(self.write_u8(b'b')?) } /// Write the OSC timetag, characterized by a (u32, u32) pair. /// The first u32 is the seconds, second is fraction of seconds. fn ...
random_line_split
osc_writer.rs
use std::convert::TryInto; use std::io::Write; use byteorder::{BigEndian, WriteBytesExt}; use error::ResultE; /// auto-implemented trait to write OSC data to a Write object. pub trait OscWriter: Write { fn osc_write_i32(&mut self, value: i32) -> ResultE<()> { Ok(self.write_i32::<BigEndian>(value)?) } ...
/// Write the OSC timetag, characterized by a (u32, u32) pair. /// The first u32 is the seconds, second is fraction of seconds. fn osc_write_timetag(&mut self, tag: (u32, u32)) -> ResultE<()> { self.write_u32::<BigEndian>(tag.0)?; self.write_u32::<BigEndian>(tag.1)?; Ok(()) } } ...
{ Ok(self.write_u8(b'b')?) }
identifier_body
osc_writer.rs
use std::convert::TryInto; use std::io::Write; use byteorder::{BigEndian, WriteBytesExt}; use error::ResultE; /// auto-implemented trait to write OSC data to a Write object. pub trait OscWriter: Write { fn osc_write_i32(&mut self, value: i32) -> ResultE<()> { Ok(self.write_i32::<BigEndian>(value)?) } ...
(&mut self, value: &str) -> ResultE<()> { self.write_all(value.as_bytes())?; // pad to 4-byte boundary, PLUS ensure we have at least one null terminator. let pad_bytes = 4 - (value.len() % 4); let zeros = b"\0\0\0\0"; Ok(self.write_all(&zeros[..pad_bytes])?) } fn write_st...
osc_write_str
identifier_name
bginit.rs
// Copyright 2021 The Evcxr Authors. // // 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 agree...
// The inititalization state. The states here more-or-less directly correspond // to different states of the `Once` inside the parent. // // - when `BgInitMutex::init` is in `OnceState::New`, the state should be // `BgInitState::Pending` // - when `BgInitMutex::init` is in `OnceState::Done`, the state should be // ...
self.ensure_ready(); let state = self.state.lock(); parking_lot::MutexGuard::map(state, |state| match state { BgInitState::Ready(v) => v, st => wrong_state(st, "Ready"), }) } }
identifier_body
bginit.rs
// Copyright 2021 The Evcxr Authors. // // 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 //
// See the License for the specific language governing permissions and // limitations under the License. use parking_lot::{MappedMutexGuard, Mutex, Once}; use std::thread::JoinHandle; // We're using `parking_lot`'s mutex so that we can get the mapped guards — it's // already in our dependency tree, and this lets us hi...
// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
random_line_split
bginit.rs
// Copyright 2021 The Evcxr Authors. // // 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 agree...
> { // guards us `join()`ing the background thread, and transitioning from // `BgInitState::Pending` to `BgInitState::Ready`. init: Once, // Call `ensure_ready()` before accessing. state: Mutex<BgInitState<T>>, } impl<T> BgInitMutex<T> { pub fn new<F>(f: F) -> Self where F: Send +'s...
InitMutex<T
identifier_name
member.rs
use super::client::{MemberClient, ObserverClient}; use super::heartbeat_rpc::*; use super::raft::client::SMClient; use super::DEFAULT_SERVICE_ID; use bifrost_hasher::hash_str; use raft::client::RaftClient; use raft::state_machine::master::ExecError; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use...
thread::sleep(time::Duration::from_millis(PING_INTERVAL)) } }); return service; } pub fn close(&self) { self.closed.store(true, Ordering::Relaxed); } pub fn leave(&self) -> impl Future<Item = Result<(), ()>, Error = ExecError> { se...
{ let heartbeat_client = AsyncServiceClient::new(DEFAULT_SERVICE_ID, &rpc_client); heartbeat_client.ping(service_clone.id); }
conditional_block
member.rs
use super::client::{MemberClient, ObserverClient}; use super::heartbeat_rpc::*; use super::raft::client::SMClient; use super::DEFAULT_SERVICE_ID; use bifrost_hasher::hash_str; use raft::client::RaftClient; use raft::state_machine::master::ExecError; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use...
(&self) -> impl Future<Item = Result<(), ()>, Error = ExecError> { self.close(); self.sm_client.leave(&self.id) } pub fn join_group( &self, group: &String, ) -> impl Future<Item = Result<(), ()>, Error = ExecError> { self.member_client.join_group(group) } pub ...
leave
identifier_name
member.rs
use super::client::{MemberClient, ObserverClient}; use super::heartbeat_rpc::*; use super::raft::client::SMClient; use super::DEFAULT_SERVICE_ID; use bifrost_hasher::hash_str; use raft::client::RaftClient; use raft::state_machine::master::ExecError; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use...
use futures::prelude::*; static PING_INTERVAL: u64 = 100; pub struct MemberService { member_client: MemberClient, sm_client: Arc<SMClient>, raft_client: Arc<RaftClient>, address: String, closed: AtomicBool, id: u64, } impl MemberService { pub fn new(server_address: &String, raft_client: &...
random_line_split
member.rs
use super::client::{MemberClient, ObserverClient}; use super::heartbeat_rpc::*; use super::raft::client::SMClient; use super::DEFAULT_SERVICE_ID; use bifrost_hasher::hash_str; use raft::client::RaftClient; use raft::state_machine::master::ExecError; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use...
pub fn client(&self) -> ObserverClient { ObserverClient::new_from_sm(&self.sm_client) } pub fn get_server_id(&self) -> u64 { self.id } } impl Drop for MemberService { fn drop(&mut self) { self.leave(); } }
{ self.member_client.leave_group(group) }
identifier_body
diagnostic.rs
with_code(Some((&self.cm, sp)), msg, code, Error); self.handler.bump_err_count(); } pub fn span_warn(&self, sp: Span, msg: &str) { self.handler.emit(Some((&self.cm, sp)), msg, Warning); } pub fn span_warn_with_code(&self, sp: Span, msg: &str, code: &str) { self.handler.emit_with_...
pub fn fileline_note(&self, sp: Span, msg: &str) { self.handler.custom_emit(&self.cm, FileLine(sp), msg, Note); } pub fn fileline_help(&self, sp: Span, msg: &str) { self.handler.custom_emit(&self.cm, FileLine(sp), msg, Help); } pub fn span_bug(&self, sp: Span, msg: &str) ->! { ...
{ self.handler.custom_emit(&self.cm, Suggestion(sp, suggestion), msg, Help); }
identifier_body
diagnostic.rs
self.handler.bump_err_count(); } pub fn span_warn(&self, sp: Span, msg: &str) { self.handler.emit(Some((&self.cm, sp)), msg, Warning); } pub fn span_warn_with_code(&self, sp: Span, msg: &str, code: &str) { self.handler.emit_with_code(Some((&self.cm, sp)), msg, code, Warning); ...
self.handler.emit(Some((&self.cm, sp)), msg, Error); self.handler.bump_err_count(); } pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) { self.handler.emit_with_code(Some((&self.cm, sp)), msg, code, Error);
random_line_split
diagnostic.rs
with_code(Some((&self.cm, sp)), msg, code, Error); self.handler.bump_err_count(); } pub fn span_warn(&self, sp: Span, msg: &str) { self.handler.emit(Some((&self.cm, sp)), msg, Warning); } pub fn span_warn_with_code(&self, sp: Span, msg: &str, code: &str) { self.handler.emit_with_...
(&self) { self.err_count.set(self.err_count.get() + 1); } pub fn err_count(&self) -> usize { self.err_count.get() } pub fn has_errors(&self) -> bool { self.err_count.get() > 0 } pub fn abort_if_errors(&self) { let s; match self.err_count.get() { ...
bump_err_count
identifier_name
diagnostic.rs
lvl == Warning &&!self.can_emit_warnings { return } self.emit.borrow_mut().emit(cmsp, msg, None, lvl); } pub fn emit_with_code(&self, cmsp: Option<(&codemap::CodeMap, Span)>, msg: &str, code: &str, l...
{ try!(write!(&mut w.dst, "{}:{} {}\n", fm.name, line_info.line_index + 1, line)); }
conditional_block
monomorphize.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...
obligations.repr(tcx)); let mut fulfill_cx = traits::FulfillmentContext::new(); for obligation in obligations { fulfill_cx.register_predicate_obligation(&infcx, obligation); } let result = drain_fulfillment_cx_or_panic(DUMMY_SP, &infcx, &mut fulfill_cx, &result); result }
{ debug!("normalize_associated_type(t={})", value.repr(tcx)); let value = erase_regions(tcx, value); if !value.has_projection_types() { return value; } // FIXME(#20304) -- cache let infcx = infer::new_infer_ctxt(tcx); let typer = NormalizingClosureTyper::new(tcx); let mut sel...
identifier_body
monomorphize.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-MIT or http://opensource.org/licenses/MIT>, at your // option. This file...
random_line_split
monomorphize.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...
<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_id: ast::DefId, psubsts: &'tcx subst::Substs<'tcx>, ref_id: Option<ast::NodeId>) -> (ValueRef, Ty<'tcx>, bool) { debug!("monomorphic_fn(\ fn_id={}, \ ...
monomorphic_fn
identifier_name
struct_add_field.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 ...
() { }
main
identifier_name
struct_add_field.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let x: Y = Y { y: 'c' }; } pub fn main() { }
embed.x.x as u32 } #[rustc_clean(label="TypeckTables", cfg="rpass2")] pub fn use_Y() {
random_line_split
error.rs
/* diosix error codes * * (c) Chris Williams, 2019-2021. * * See LICENSE for usage and copying. */ /* how things can go wrong */ #[derive(Debug)] pub enum Cause { /* misc */ NotImplemented, /* debug */ DebugInitFailed, /* devices */ DeviceTreeBad,
/* physical CPU cores */ PhysicalCoreBadID, PhysicalCoreCountUnknown, /* capsule services */ ServiceAlreadyRegistered, ServiceAlreadyOwner, ServiceNotAllowed, ServiceNotFound, /* messages */ MessageBadType, /* heap */ HeapNotInUse, HeapBadBlock, HeapNoFreeMem, ...
CantCloneDevices, BootDeviceTreeBad,
random_line_split
error.rs
/* diosix error codes * * (c) Chris Williams, 2019-2021. * * See LICENSE for usage and copying. */ /* how things can go wrong */ #[derive(Debug)] pub enum
{ /* misc */ NotImplemented, /* debug */ DebugInitFailed, /* devices */ DeviceTreeBad, CantCloneDevices, BootDeviceTreeBad, /* physical CPU cores */ PhysicalCoreBadID, PhysicalCoreCountUnknown, /* capsule services */ ServiceAlreadyRegistered, ServiceAlreadyOw...
Cause
identifier_name
uploader.rs
//! # Jaeger Span Uploader #[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))] use crate::exporter::collector; use crate::exporter::{agent, jaeger}; use async_trait::async_trait; use opentelemetry::sdk::export::trace; use crate::exporter::JaegerTraceRuntime; #[async_trait] pub(crate) trait Up...
{ Agent(agent::AgentSyncClientUdp), } #[async_trait] impl Uploader for SyncUploader { async fn upload(&mut self, batch: jaeger::Batch) -> trace::ExportResult { match self { SyncUploader::Agent(client) => { // TODO Implement retry behaviour client ...
SyncUploader
identifier_name
uploader.rs
//! # Jaeger Span Uploader #[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))] use crate::exporter::collector; use crate::exporter::{agent, jaeger}; use async_trait::async_trait; use opentelemetry::sdk::export::trace; use crate::exporter::JaegerTraceRuntime; #[async_trait] pub(crate) trait Up...
.map_err::<crate::Error, _>(Into::into)?; } } Ok(()) } }
{ match self { AsyncUploader::Agent(client) => { // TODO Implement retry behaviour client .emit_batch(batch) .await .map_err::<crate::Error, _>(Into::into)?; } #[cfg(feature = "collect...
identifier_body
uploader.rs
//! # Jaeger Span Uploader #[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))] use crate::exporter::collector; use crate::exporter::{agent, jaeger}; use async_trait::async_trait; use opentelemetry::sdk::export::trace; use crate::exporter::JaegerTraceRuntime; #[async_trait] pub(crate) trait Up...
} Ok(()) } } /// Uploads a batch of spans to Jaeger #[derive(Debug)] pub(crate) enum AsyncUploader<R: JaegerTraceRuntime> { /// Agent async client Agent(agent::AgentAsyncClientUdp<R>), /// Collector sync client #[cfg(any(feature = "collector_client", feature = "wasm_collector_clien...
{ // TODO Implement retry behaviour client .emit_batch(batch) .map_err::<crate::Error, _>(Into::into)?; }
conditional_block
uploader.rs
//! # Jaeger Span Uploader #[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))] use crate::exporter::collector; use crate::exporter::{agent, jaeger}; use async_trait::async_trait; use opentelemetry::sdk::export::trace; use crate::exporter::JaegerTraceRuntime; #[async_trait] pub(crate) trait Up...
} #[async_trait] impl<R: JaegerTraceRuntime> Uploader for AsyncUploader<R> { /// Emit a jaeger batch for the given uploader async fn upload(&mut self, batch: jaeger::Batch) -> trace::ExportResult { match self { AsyncUploader::Agent(client) => { // TODO Implement retry behavi...
/// Collector sync client #[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))] Collector(collector::CollectorAsyncClientHttp),
random_line_split
mod.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::SourceLocationKey; use fixture_tests::Fixture; use graphql_ir::{build, ExecutableDefinition}; use graphql_syntax::par...
ExecutableDefinition::Fragment(fragment) => { let mut import_statements = Default::default(); let fragment = print_fragment( &TEST_SCHEMA, fragment, &ProjectConfig { ...
{ let mut import_statements = Default::default(); let operation = print_operation( &TEST_SCHEMA, operation, &ProjectConfig { js_module_format: JsModuleForma...
conditional_block
mod.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::SourceLocationKey; use fixture_tests::Fixture; use graphql_ir::{build, ExecutableDefinition}; use graphql_syntax::par...
ExecutableDefinition::Fragment(fragment) => { let mut import_statements = Default::default(); let fragment = print_fragment( &TEST_SCHEMA, fragment, &ProjectConfig { ...
}
random_line_split
mod.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::SourceLocationKey; use fixture_tests::Fixture; use graphql_ir::{build, ExecutableDefinition}; use graphql_syntax::par...
&mut import_statements, ); format!("{}{}", import_statements, operation) } ExecutableDefinition::Fragment(fragment) => { let mut import_statements = Default::default(); ...
{ let ast = parse_executable( fixture.content, SourceLocationKey::standalone(fixture.file_name), ) .unwrap(); build(&TEST_SCHEMA, &ast.definitions) .map(|definitions| { definitions .iter() .map(|def| match def { Exec...
identifier_body
mod.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::SourceLocationKey; use fixture_tests::Fixture; use graphql_ir::{build, ExecutableDefinition}; use graphql_syntax::par...
(fixture: &Fixture<'_>) -> Result<String, String> { let ast = parse_executable( fixture.content, SourceLocationKey::standalone(fixture.file_name), ) .unwrap(); build(&TEST_SCHEMA, &ast.definitions) .map(|definitions| { definitions .iter() ....
transform_fixture
identifier_name
filesystem.rs
use std::ffi::{CStr, CString}; use SdlResult; use get_error; use util::CStringExt; use sys::filesystem as ll; pub fn base_path() -> SdlResult<String> { let result = unsafe { let buf = ll::SDL_GetBasePath(); String::from_utf8_lossy(CStr::from_ptr(buf).to_bytes()).to_string() }; if result.l...
(org: &str, app: &str) -> SdlResult<String> { let result = unsafe { let org = try!(CString::new(org).unwrap_or_sdlresult()); let app = try!(CString::new(app).unwrap_or_sdlresult()); let buf = ll::SDL_GetPrefPath(org.as_ptr(), app.as_ptr()); String::from_utf8_lossy(CStr::from_ptr(buf)...
pref_path
identifier_name
filesystem.rs
use std::ffi::{CStr, CString}; use SdlResult; use get_error; use util::CStringExt; use sys::filesystem as ll; pub fn base_path() -> SdlResult<String>
pub fn pref_path(org: &str, app: &str) -> SdlResult<String> { let result = unsafe { let org = try!(CString::new(org).unwrap_or_sdlresult()); let app = try!(CString::new(app).unwrap_or_sdlresult()); let buf = ll::SDL_GetPrefPath(org.as_ptr(), app.as_ptr()); String::from_utf8_lossy(C...
{ let result = unsafe { let buf = ll::SDL_GetBasePath(); String::from_utf8_lossy(CStr::from_ptr(buf).to_bytes()).to_string() }; if result.len() == 0 { Err(get_error()) } else { Ok(result) } }
identifier_body
filesystem.rs
use std::ffi::{CStr, CString}; use SdlResult; use get_error; use util::CStringExt; use sys::filesystem as ll; pub fn base_path() -> SdlResult<String> { let result = unsafe { let buf = ll::SDL_GetBasePath(); String::from_utf8_lossy(CStr::from_ptr(buf).to_bytes()).to_string() }; if result.l...
else { Ok(result) } }
{ Err(get_error()) }
conditional_block
filesystem.rs
use std::ffi::{CStr, CString}; use SdlResult; use get_error; use util::CStringExt; use sys::filesystem as ll;
String::from_utf8_lossy(CStr::from_ptr(buf).to_bytes()).to_string() }; if result.len() == 0 { Err(get_error()) } else { Ok(result) } } pub fn pref_path(org: &str, app: &str) -> SdlResult<String> { let result = unsafe { let org = try!(CString::new(org).unwrap_or_sdlr...
pub fn base_path() -> SdlResult<String> { let result = unsafe { let buf = ll::SDL_GetBasePath();
random_line_split
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLBufferId, Web...
} } pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) -> Option<Root<WebGLBuffer>> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateBuffer(sender)).unwrap(); let result = receiver.recv().unwrap(); resu...
capacity: Cell::new(0), is_deleted: Cell::new(false), vao_references: DOMRefCell::new(None), pending_delete: Cell::new(false), renderer: renderer,
random_line_split
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLBufferId, Web...
(&self, target: u32) -> WebGLResult<()> { if let Some(previous_target) = self.target.get() { if target!= previous_target { return Err(WebGLError::InvalidOperation); } } else { self.target.set(Some(target)); } let msg = WebGLCommand::Bin...
bind
identifier_name
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLBufferId, Web...
let mut map = HashSet::new(); map.insert(id); *vao_refs = Some(map); } pub fn remove_vao_reference(&self, id: WebGLVertexArrayId) { if let Some(ref mut vao_refs) = *self.vao_references.borrow_mut() { if vao_refs.take(&id).is_some() && self.pending_delete.get() { ...
{ vao_refs.insert(id); return; }
conditional_block
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLBufferId, Web...
} impl WebGLBuffer { pub fn id(&self) -> WebGLBufferId { self.id } // NB: Only valid buffer targets come here pub fn bind(&self, target: u32) -> WebGLResult<()> { if let Some(previous_target) = self.target.get() { if target!= previous_target { return Err(W...
{ reflect_dom_object(box WebGLBuffer::new_inherited(renderer, id), window, WebGLBufferBinding::Wrap) }
identifier_body
htmlframesetelement.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::HTMLFrameSetElementBinding; use dom::bindings::codegen::InheritTypes::HTMLFr...
(&self) -> bool { *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement))) } } impl HTMLFrameSetElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLFrameSetElement { ...
is_htmlframesetelement
identifier_name
htmlframesetelement.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::HTMLFrameSetElementBinding; use dom::bindings::codegen::InheritTypes::HTMLFr...
impl HTMLFrameSetElementDerived for EventTarget { fn is_htmlframesetelement(&self) -> bool { *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement))) } } impl HTMLFrameSetElement { fn new_inherited(localName: DOMString, pre...
htmlelement: HTMLElement }
random_line_split
htmlframesetelement.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::HTMLFrameSetElementBinding; use dom::bindings::codegen::InheritTypes::HTMLFr...
} impl HTMLFrameSetElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLFrameSetElement { HTMLFrameSetElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLFrameSetElement, localName, prefix, document) } } ...
{ *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement))) }
identifier_body
lib.rs
pub mod rustyham { use std::iter::repeat; pub enum Hamming { Encode, Decode, EncodeBinary, DecodeBinary } pub fn
(action: Hamming, s: String) -> String { match action { Hamming::Encode | Hamming::EncodeBinary => { // get an iterator over the individual bits let mut bytes; let bytes_str = match action { Hamming::EncodeBinary => s + "1", // the...
hamming
identifier_name
lib.rs
pub mod rustyham { use std::iter::repeat; pub enum Hamming { Encode, Decode, EncodeBinary, DecodeBinary } pub fn hamming(action: Hamming, s: String) -> String
let lenpow = (2..).find(|&r| 2u32.pow(r) - r - 1 >= mlen).unwrap(); let len = 2us.pow(lenpow) - 1; // the thing we're storing the hamming code in let mut code: Vec<bool> = repeat(false).take(len).collect(); // set data bits ...
{ match action { Hamming::Encode | Hamming::EncodeBinary => { // get an iterator over the individual bits let mut bytes; let bytes_str = match action { Hamming::EncodeBinary => s + "1", // the final 1 signifies EOS ...
identifier_body
lib.rs
pub mod rustyham { use std::iter::repeat; pub enum Hamming { Encode, Decode, EncodeBinary, DecodeBinary } pub fn hamming(action: Hamming, s: String) -> String { match action { Hamming::Encode | Hamming::EncodeBinary => { // get an iterator over the individual bits ...
} } } } fn calc_parity(code: &Vec<bool>, i: u32) -> bool { let bi = 2us.pow(i) - 1; let (mut parity, mut ignore, mut counter) = (false, false, 0); for j in bi..code.len() { if!ignore && code[j] { parity =!parity } counter += 1...
{ // we have to chop off the 0 padding if it exists let cslice = &data.collect::<Vec<char>>()[..]; let mut chunks = cslice.chunks(7).map(|x| { x.iter().cloned().collect::<String>() }).collect::<Ve...
conditional_block
lib.rs
pub mod rustyham { use std::iter::repeat; pub enum Hamming { Encode, Decode, EncodeBinary, DecodeBinary } pub fn hamming(action: Hamming, s: String) -> String { match action { Hamming::Encode | Hamming::EncodeBinary => { // get an iterator over the individual bits ...
} flipped_bit += 1; chars[flipped_bit as usize] =!chars[flipped_bit as usize]; } // collect all bits at non-powers-of-2 let data = chars.iter().enumerate() .filter(|x| ((x.0 + 1) & x.0)!= 0) ...
let mut chars = s.chars().map(|x| x == '1').collect::<Vec<bool>>(); let mut flipped_bit = -1i32; while (0..lenpow).any(|i| calc_parity(&chars, i)) { if flipped_bit != -1 { chars[flipped_bit as usize] = !chars[flipped_bit as usiz...
random_line_split
windows.rs
extern crate winapi; use std::fs::File; use std::io; use std::io::{Write, Seek, SeekFrom}; use std::mem; use std::ptr; use std::cmp::min; use std::os::windows::fs::FileExt; use std::os::windows::io::AsRawHandle; use self::winapi::shared::basetsd::SIZE_T; use self::winapi::shared::minwindef::{BOOL, DWORD}; use self::w...
let len = min(file_len - pos, buf.len() as u64) as usize; unsafe { let alignment = pos % allocation_granularity() as u64; let aligned_pos = pos - alignment; let aligned_len = len + alignment as usize; let mapping = CreateFileMappingW( s...
{ return Ok(0); }
conditional_block
windows.rs
extern crate winapi; use std::fs::File; use std::io; use std::io::{Write, Seek, SeekFrom}; use std::mem; use std::ptr; use std::cmp::min; use std::os::windows::fs::FileExt; use std::os::windows::io::AsRawHandle; use self::winapi::shared::basetsd::SIZE_T; use self::winapi::shared::minwindef::{BOOL, DWORD}; use self::w...
ptr::null(), ); if mapping.is_null() { return Err(io::Error::last_os_error()); } let aligned_ptr = MapViewOfFile( mapping, FILE_MAP_READ, (aligned_pos >> 32) as DWORD, (align...
{ let file_len = self.metadata()?.len(); if buf.is_empty() || pos >= file_len { return Ok(0); } let len = min(file_len - pos, buf.len() as u64) as usize; unsafe { let alignment = pos % allocation_granularity() as u64; let aligned_pos = pos -...
identifier_body
windows.rs
extern crate winapi; use std::fs::File; use std::io; use std::io::{Write, Seek, SeekFrom}; use std::mem; use std::ptr; use std::cmp::min; use std::os::windows::fs::FileExt; use std::os::windows::io::AsRawHandle; use self::winapi::shared::basetsd::SIZE_T; use self::winapi::shared::minwindef::{BOOL, DWORD}; use self::w...
(&self, pos: u64, buf: &mut [u8]) -> io::Result<usize> { let file_len = self.metadata()?.len(); if buf.is_empty() || pos >= file_len { return Ok(0); } let len = min(file_len - pos, buf.len() as u64) as usize; unsafe { let alignment = pos % allocation_gr...
read_at
identifier_name
windows.rs
extern crate winapi; use std::fs::File; use std::io; use std::io::{Write, Seek, SeekFrom}; use std::mem; use std::ptr; use std::cmp::min; use std::os::windows::fs::FileExt; use std::os::windows::io::AsRawHandle; use self::winapi::shared::basetsd::SIZE_T; use self::winapi::shared::minwindef::{BOOL, DWORD}; use self::w...
} } impl WriteAt for File { fn write_at(&mut self, pos: u64, buf: &[u8]) -> io::Result<usize> { let cursor = self.seek(SeekFrom::Current(0))?; let result = self.seek_write(buf, pos)?; self.seek(SeekFrom::Start(cursor))?; Ok(result) } fn flush(&mut self) -> io::Result<()...
random_line_split
first-trait3.rs
// trait3.rs struct FRange { val: f64, end: f64, incr: f64 } fn range(x1: f64, x2: f64, skip: f64) -> FRange { FRange {val: x1, end: x2, incr: skip} } impl Iterator for FRange { type Item = f64; fn next(&mut self) -> Option<Self::Item> { let res = self.val; if res >= sel...
(self) -> Vec<T> { FromIterator::from_iter(self) } } fn main() { for x in range(0.0, 1.0, 0.1) { println!("{:.1} ",x); } let v: Vec<f64> = range(0.0, 1.0, 0.1).collect(); println!("{:?}",v); let v = range(0.0, 1.0, 0.1).to_vec(); println!("{:?}",v); }
to_vec
identifier_name
first-trait3.rs
// trait3.rs struct FRange { val: f64, end: f64, incr: f64 } fn range(x1: f64, x2: f64, skip: f64) -> FRange { FRange {val: x1, end: x2, incr: skip} } impl Iterator for FRange { type Item = f64; fn next(&mut self) -> Option<Self::Item> { let res = self.val; if res >= sel...
} } pub trait ToVec<T> { fn to_vec(self) -> Vec<T>; } use std::iter::FromIterator; impl <T: Sized, I: Iterator<Item=T>> ToVec<T> for I { fn to_vec(self) -> Vec<T> { FromIterator::from_iter(self) } } fn main() { for x in range(0.0, 1.0, 0.1) { println!("{:.1} ",x); } le...
{ self.val += self.incr; Some(res) }
conditional_block
first-trait3.rs
// trait3.rs struct FRange { val: f64, end: f64, incr: f64 } fn range(x1: f64, x2: f64, skip: f64) -> FRange { FRange {val: x1, end: x2, incr: skip} } impl Iterator for FRange { type Item = f64; fn next(&mut self) -> Option<Self::Item> { let res = self.val; if res >= sel...
fn main() { for x in range(0.0, 1.0, 0.1) { println!("{:.1} ",x); } let v: Vec<f64> = range(0.0, 1.0, 0.1).collect(); println!("{:?}",v); let v = range(0.0, 1.0, 0.1).to_vec(); println!("{:?}",v); }
fn to_vec(self) -> Vec<T> { FromIterator::from_iter(self) } }
random_line_split
opcodes.rs
use {Node, ValueInfo}; #[derive(Copy,Clone,Debug,PartialEq,Eq)] pub enum OpCode { Add, Sub, Mul, Div, Shl, Shr, Ret, /// Signed extension, /// `(sext 16 %value)` Sext, /// Zero extension. /// `(sext 16 %value)` Zext, /// Set a register. /// `(set %reg, %value...
pub fn value_infos(&self, operands: &[Node]) -> Vec<ValueInfo> { match *self { OpCode::Set => { assert_eq!(operands.len(), 2); vec![ValueInfo::Output, ValueInfo::Input] }, // Everything else is all-inputs. _ => { ...
{ format!("{:?}", self).to_lowercase() }
identifier_body
opcodes.rs
use {Node, ValueInfo}; #[derive(Copy,Clone,Debug,PartialEq,Eq)] pub enum OpCode { Add, Sub, Mul, Div, Shl, Shr, Ret, /// Signed extension, /// `(sext 16 %value)` Sext, /// Zero extension. /// `(sext 16 %value)` Zext, /// Set a register. /// `(set %reg, %value...
, // Everything else is all-inputs. _ => { operands.iter().map(|_| ValueInfo::Input).collect() }, } } }
{ assert_eq!(operands.len(), 2); vec![ValueInfo::Output, ValueInfo::Input] }
conditional_block
opcodes.rs
use {Node, ValueInfo}; #[derive(Copy,Clone,Debug,PartialEq,Eq)] pub enum OpCode { Add, Sub, Mul, Div, Shl, Shr,
Ret, /// Signed extension, /// `(sext 16 %value)` Sext, /// Zero extension. /// `(sext 16 %value)` Zext, /// Set a register. /// `(set %reg, %value)` Set, } impl OpCode { pub fn mnemonic(&self) -> String { format!("{:?}", self).to_lowercase() } pub fn value_...
random_line_split
opcodes.rs
use {Node, ValueInfo}; #[derive(Copy,Clone,Debug,PartialEq,Eq)] pub enum OpCode { Add, Sub, Mul, Div, Shl, Shr, Ret, /// Signed extension, /// `(sext 16 %value)` Sext, /// Zero extension. /// `(sext 16 %value)` Zext, /// Set a register. /// `(set %reg, %value...
(&self, operands: &[Node]) -> Vec<ValueInfo> { match *self { OpCode::Set => { assert_eq!(operands.len(), 2); vec![ValueInfo::Output, ValueInfo::Input] }, // Everything else is all-inputs. _ => { operands.iter().map(...
value_infos
identifier_name
build.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use protoc_grpcio; use std::path::{Path, PathBuf}; use build_utils::BuildRoot; use std::collections::HashSet; fn main() { let build_root = BuildRoot::find().unwrap(); let thirdpar...
(thirdpartyprotobuf: &Path, out_dir: &Path) { tower_grpc_build::Config::new() .enable_server(true) .enable_client(true) .build( &[PathBuf::from( "build/bazel/remote/execution/v2/remote_execution.proto", )], &std::fs::read_dir(&thirdpartyprotobuf) .unwrap() .map(|d| d.u...
generate_for_tower
identifier_name
build.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use protoc_grpcio; use std::path::{Path, PathBuf}; use build_utils::BuildRoot; use std::collections::HashSet; fn main() { let build_root = BuildRoot::find().unwrap(); let thirdpar...
.status() .unwrap() .success(); if!success { panic!("Cargo formatting failed for generated protos. Output should be above."); } } } }
{ let mut rustfmt = PathBuf::from(env!("CARGO")); rustfmt.pop(); rustfmt.push("rustfmt"); let mut rustfmt_config = PathBuf::from(env!("CARGO_MANIFEST_DIR")); rustfmt_config.pop(); // bazel_protos rustfmt_config.pop(); // process_execution rustfmt_config.push("rustfmt.toml"); if !rustfmt_config.exists()...
identifier_body
build.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use protoc_grpcio; use std::path::{Path, PathBuf}; use build_utils::BuildRoot; use std::collections::HashSet; fn main() { let build_root = BuildRoot::find().unwrap(); let thirdpar...
std::fs::create_dir_all(path.parent().unwrap()).unwrap(); copy_dir::copy_dir(tempdir.path(), path).unwrap(); } fn format(path: &Path) { let mut rustfmt = PathBuf::from(env!("CARGO")); rustfmt.pop(); rustfmt.push("rustfmt"); let mut rustfmt_config = PathBuf::from(env!("CARGO_MANIFEST_DIR")); rustfmt_conf...
{ std::fs::remove_dir_all(path).unwrap(); }
conditional_block
build.rs
// Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use protoc_grpcio; use std::path::{Path, PathBuf}; use build_utils::BuildRoot; use std::collections::HashSet; fn main() { let build_root = BuildRoot::find().unwrap(); let thirdpar...
/// fn disable_clippy_in_generated_code(dir: &Path) -> Result<(), String> { for file in walkdir::WalkDir::new(&dir) .into_iter() .filter_map(|entry| entry.ok()) .filter(|entry| { entry.file_type().is_file() && entry.file_name().to_string_lossy().ends_with(".rs") }) { let lines: Vec<_> = std::...
/// warnings/errors from generated code not meeting our standards.
random_line_split
operation.rs
use std::collections::HashMap; use soap::{ Fault, Part, Request, Response }; pub struct
{ pub doc: String, pub name: String, pub inputs: HashMap<String, Part>, pub outputs: HashMap<String, Part>, pub closure: Box<FnMut(Request) -> Response> } impl Operation { pub fn not_found() -> Operation { Operation { doc: String::from("Handler for unknown opera...
Operation
identifier_name
operation.rs
use std::collections::HashMap; use soap::{ Fault, Part, Request, Response }; pub struct Operation { pub doc: String, pub name: String, pub inputs: HashMap<String, Part>, pub outputs: HashMap<String, Part>, pub closure: Box<FnMut(Request) -> Response> } impl Operation { pub fn not_foun...
unsafe impl Send for Operation {}
}
random_line_split
architecture.rs
/* * Panopticon - A libre disassembler * Copyright (C) 2015, 2017 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...
fn decode(reg: &Region, start: u64, cfg: &Self::Configuration) -> Result<Match<Self>> { let data = reg.iter(); let mut buf: Vec<u8> = vec![]; let mut i = data.seek(start); let p = start; while let Some(Some(b)) = i.next() { buf.push(b); if buf.len()...
{ Ok(vec![]) }
identifier_body
architecture.rs
/* * Panopticon - A libre disassembler * Copyright (C) 2015, 2017 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...
#[derive(Clone,PartialEq,Copy,Debug)] pub enum Mode { Real, // Real mode / Virtual 8086 mode Protected, // Protected mode / Long compatibility mode Long, // Long 64-bit mode } impl Mode { pub fn alt_bits(&self) -> usize { match self { &Mode::Real => 32, &Mode::Protected...
pub enum Amd64 {}
random_line_split
architecture.rs
/* * Panopticon - A libre disassembler * Copyright (C) 2015, 2017 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...
(_: &Region, _: &Self::Configuration) -> Result<Vec<(&'static str, u64, &'static str)>> { Ok(vec![]) } fn decode(reg: &Region, start: u64, cfg: &Self::Configuration) -> Result<Match<Self>> { let data = reg.iter(); let mut buf: Vec<u8> = vec![]; let mut i = data.seek(start); ...
prepare
identifier_name
mod.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...
pub use unicode::tables::property::Pattern_White_Space; }
pub mod property {
random_line_split
lib.rs
extern crate bytes; extern crate futures; extern crate tokio_core; extern crate tokio_io; extern crate tokio_proto; extern crate tokio_service; use futures::{future, Future}; use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::codec::{Decoder, Encoder, Framed}; use tokio_core::net::TcpStream; use tokio_core::reactor::...
impl<T: AsyncRead + AsyncWrite +'static> ServerProto<T> for CollatzProto { type Request = String; type Response = String; type Transport = Framed<T, CollatzCodec>; type BindTransport = Result<Self::Transport, io::Error>; fn bind_transport(&self, io: T) -> Self::BindTransport { ...
}
random_line_split
lib.rs
extern crate bytes; extern crate futures; extern crate tokio_core; extern crate tokio_io; extern crate tokio_proto; extern crate tokio_service; use futures::{future, Future}; use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::codec::{Decoder, Encoder, Framed}; use tokio_core::net::TcpStream; use tokio_core::reactor::...
let newline = buf[4..].iter().position(|b| *b==b'\n'); if let Some(n) = newline { let line = buf.split_to(n + 4); buf.split_to(1); let request_id = io::Cursor::new(&line[0..4]).get_u32::<BigEndian> (); return match str::from_utf8(&line.as_ref()[4..]) { ...
{ return Ok(None); }
conditional_block
lib.rs
extern crate bytes; extern crate futures; extern crate tokio_core; extern crate tokio_io; extern crate tokio_proto; extern crate tokio_service; use futures::{future, Future}; use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::codec::{Decoder, Encoder, Framed}; use tokio_core::net::TcpStream; use tokio_core::reactor::...
(&self, io: T) -> Self::BindTransport { Ok(io.framed(CollatzCodec)) } } impl<T: AsyncRead + AsyncWrite +'static> ServerProto<T> for CollatzProto { type Request = String; type Response = String; type Transport = Framed<T, CollatzCodec>; type BindTransport = Result<Self::Trans...
bind_transport
identifier_name
neurons_layer.rs
/* This file is part of Mulp. Mulp 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. Mulp is distributed in the hope that it will be useful, ...
(dim_neurons: uint, nb_neurons: uint) -> NeuronsLayer{ let mut neurons: Vec<Neuron> = Vec::new(); for _ in range(0u, nb_neurons) { let n: Neuron = Neuron::new(dim_neurons); neurons.push(n); } return NeuronsLayer { dim_neurons:...
new
identifier_name
neurons_layer.rs
/* This file is part of Mulp. Mulp 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. Mulp is distributed in the hope that it will be useful, ...
pub fn get_weights(&mut self) -> Vec<Vec<f64>> { let mut weights: Vec<Vec<f64>> = Vec::new(); let mut it = self.neurons.iter_mut(); loop { match it.next() { Some(ref mut n) => { weights.push(n.get_weights().clone()); } ...
{ let mut activations: Vec<f64> = Vec::new(); let mut it = self.neurons.iter_mut(); loop { match it.next() { Some(ref mut n) => { activations.push(n.get_activation()); } None => { break } } } ...
identifier_body
neurons_layer.rs
/* This file is part of Mulp. Mulp 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. Mulp is distributed in the hope that it will be useful, ...
// propagation pub fn propagate(&mut self, input: &[f64]) { let mut it = self.neurons.iter_mut(); loop { match it.next() { Some(ref mut n) => { n.propagate(input); } None => { break } } ...
random_line_split
lib.rs
extern crate pcd8544_sys; extern crate wiringpi; use wiringpi::WiringPi; use wiringpi::pin::Pin; // We take a WiringPi as a parameter to ensure that wiringpi was setup prior to this function call #[allow(unused_variables)] pub fn init<P: Pin>(pi: &WiringPi<P>, sclk: u8, din: u8, dc: u8, cs: u8, rst: u8, contrast: u8...
{ unsafe { pcd8544_sys::LCDclear(); } }
identifier_body
lib.rs
extern crate pcd8544_sys; extern crate wiringpi; use wiringpi::WiringPi; use wiringpi::pin::Pin; // We take a WiringPi as a parameter to ensure that wiringpi was setup prior to this function call #[allow(unused_variables)] pub fn init<P: Pin>(pi: &WiringPi<P>, sclk: u8, din: u8, dc: u8, cs: u8, rst: u8, contrast: u8...
else { pcd8544_sys::BLACK } ); } } pub fn display() { unsafe { pcd8544_sys::LCDdisplay(); } } pub fn clear() { unsafe { pcd8544_sys::LCDclear(); } }
{ pcd8544_sys::WHITE }
conditional_block
lib.rs
extern crate pcd8544_sys; extern crate wiringpi; use wiringpi::WiringPi; use wiringpi::pin::Pin; // We take a WiringPi as a parameter to ensure that wiringpi was setup prior to this function call #[allow(unused_variables)] pub fn init<P: Pin>(pi: &WiringPi<P>, sclk: u8, din: u8, dc: u8, cs: u8, rst: u8, contrast: u8...
() { unsafe { pcd8544_sys::LCDdisplay(); } } pub fn clear() { unsafe { pcd8544_sys::LCDclear(); } }
display
identifier_name
lib.rs
extern crate pcd8544_sys; extern crate wiringpi; use wiringpi::WiringPi;
// We take a WiringPi as a parameter to ensure that wiringpi was setup prior to this function call #[allow(unused_variables)] pub fn init<P: Pin>(pi: &WiringPi<P>, sclk: u8, din: u8, dc: u8, cs: u8, rst: u8, contrast: u8) { unsafe { pcd8544_sys::LCDInit(sclk, din, dc, cs, rst, contrast); } } pub fn set...
use wiringpi::pin::Pin;
random_line_split
gdt.rs
use core::ptr::RawPtr; use core::mem::{size_of, transmute}; use core; use cpu::DtReg; use kernel::heap; define_flags!(GdtAccess: u8 { ACCESSED = 1 << 0, EXTEND = 1 << 1, CONFORM = 1 << 2, CODE = 1 << 3, STORAGE = 1 << 4, // not TSS DPL0 = 0 << 5, DPL1 = 1 << 5, DPL2 = 2 << 5, ...
(&self) { unsafe { asm!("lgdt [$0]" :: "r"(self) :: "intel"); } } }
load
identifier_name
gdt.rs
use core::ptr::RawPtr; use core::mem::{size_of, transmute}; use core; use cpu::DtReg; use kernel::heap; define_flags!(GdtAccess: u8 { ACCESSED = 1 << 0, EXTEND = 1 << 1, CONFORM = 1 << 2, CODE = 1 << 3, STORAGE = 1 << 4, // not TSS DPL0 = 0 << 5, DPL1 = 1 << 5, DPL2 = 2 << 5, ...
unsafe { entry.access |= PRESENT.get(); *self.table.offset(n as int) = entry; } } pub unsafe fn disable(&self, n: uint) { (*self.table.offset(n as int)).access &=!PRESENT.get(); } pub fn load(&self, code: u16, data: u16, local: u16) { unsafe { ...
pub fn enable(&self, n: uint, mut entry: GdtEntry) {
random_line_split
errors.rs
// * This file is part of the uutils coreutils package. // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use std::{ error::Error, fmt::{Debug, Display}, }; use uucore::error::UError; #[derive(Debug)] pub enum NumfmtErro...
IllegalArgument(String), FormattingError(String), } impl UError for NumfmtError { fn code(&self) -> i32 { match self { NumfmtError::IoError(_) => 1, NumfmtError::IllegalArgument(_) => 1, NumfmtError::FormattingError(_) => 2, } } } impl Error for Numf...
IoError(String),
random_line_split
errors.rs
// * This file is part of the uutils coreutils package. // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use std::{ error::Error, fmt::{Debug, Display}, }; use uucore::error::UError; #[derive(Debug)] pub enum NumfmtErro...
(&self) -> i32 { match self { NumfmtError::IoError(_) => 1, NumfmtError::IllegalArgument(_) => 1, NumfmtError::FormattingError(_) => 2, } } } impl Error for NumfmtError {} impl Display for NumfmtError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::...
code
identifier_name
error.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
(err: IoError) -> Error { Error::Io(err) } } impl From<TrieError> for Error { fn from(err: TrieError) -> Error { Error::Trie(err) } } impl From<::std::io::Error> for Error { fn from(err: ::std::io::Error) -> Error { Error::StdIo(err) } } impl From<BlockImportError> for Error { fn from(err: BlockImportErr...
from
identifier_name
error.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
#[derive(Debug, Clone, Copy, PartialEq)] /// Import to the block queue result pub enum ImportError { /// Already in the block chain. AlreadyInChain, /// Already in the block queue. AlreadyQueued, /// Already marked as bad from a previous import (could mean parent is bad). KnownBad, } impl fmt::Display for Import...
f.write_fmt(format_args!("Block error ({})", msg)) } }
random_line_split
build.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 std::env; use std::path::Path; use std::process::{Command, exit}; #[cfg(windows)] fn find_python() -> String ...
() -> String { if Command::new("python2.7").arg("--version").output().unwrap().status.success() { "python2.7" } else { "python" }.to_owned() } fn main() { let python = env::var("PYTHON").ok().unwrap_or_else(find_python); // Mako refuses to load templates outside the scope of the cu...
find_python
identifier_name
build.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 std::env; use std::path::Path; use std::process::{Command, exit}; #[cfg(windows)] fn find_python() -> String ...
.to_owned() } fn main() { let python = env::var("PYTHON").ok().unwrap_or_else(find_python); // Mako refuses to load templates outside the scope of the current working directory, // so we need to run it from the top source directory. let geckolib_dir = Path::new(file!()).parent().unwrap(); let top_...
{ "python" }
conditional_block
build.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 std::env; use std::path::Path; use std::process::{Command, exit}; #[cfg(windows)] fn find_python() -> String ...
// Mako refuses to load templates outside the scope of the current working directory, // so we need to run it from the top source directory. let geckolib_dir = Path::new(file!()).parent().unwrap(); let top_dir = geckolib_dir.join("..").join(".."); let properties_dir = Path::new("components").join(...
fn main() { let python = env::var("PYTHON").ok().unwrap_or_else(find_python);
random_line_split
build.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 std::env; use std::path::Path; use std::process::{Command, exit}; #[cfg(windows)] fn find_python() -> String ...
exit(1) } }
{ let python = env::var("PYTHON").ok().unwrap_or_else(find_python); // Mako refuses to load templates outside the scope of the current working directory, // so we need to run it from the top source directory. let geckolib_dir = Path::new(file!()).parent().unwrap(); let top_dir = geckolib_dir.join("...
identifier_body
rand.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...
use ast; use ast::{MetaItem, item, Expr, Ident}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::{AstBuilder}; use ext::deriving::generic::*; use std::vec; pub fn expand_deriving_rand(cx: @ExtCtxt, span: Span, mitem: @MetaItem, ...
random_line_split
rand.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...
StaticEnum(_, ref variants) => { if variants.is_empty() { cx.span_fatal(span, "`Rand` cannot be derived for enums with no variants"); } let variant_count = cx.expr_uint(span, variants.len()); let rand_name = cx.path_all(span, ...
{ rand_thing(cx, span, substr.type_ident, summary, rand_call) }
conditional_block
scorer_regression.rs
#[cfg(test)] mod scorer_regression_test { use zip::read::ZipArchive; use std::fs::File; use std::io::Read; use base::gametree::*; use base::game::*; use base::*; //#[test] fn it_scores_all_games_in_regression_tests() { let mut total = 0; let mut total_conservative_ra...
if cons_r.includes(gt.result()) { conservative_ok = conservative_ok + 1 } if opt_r.includes(gt.result()) { optimistic_ok = optimistic_ok + 1; }...
{ if let Ok(gt) = sgf::parse(content) { if !gt.result().is_resign() && !gt.result().is_time() { println!("Filename: {}", file.name()); let mut ok = true; let mut game = game::Game::new_for_gametree(&gt); ...
conditional_block