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 |
|---|---|---|---|---|
guard.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Machinery to conditionally expose things.
use js::jsapi::JSContext;
use js::rust::HandleObject;
use servo_co... | /// The condition is satisfied if the function returns true.
Func(unsafe fn(*mut JSContext, HandleObject) -> bool),
/// The condition is satisfied if the preference is set.
Pref(&'static str),
/// The condition is always satisfied.
Satisfied,
}
impl Condition {
unsafe fn is_satisfied(&self,... |
/// A condition to expose things.
pub enum Condition { | random_line_split |
htmltablesectionelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{
self, HTMLTableSectionElementMe... | {
htmlelement: HTMLElement,
}
impl HTMLTableSectionElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLTableSectionElement {
HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix... | HTMLTableSectionElement | identifier_name |
htmltablesectionelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{
self, HTMLTableSectionElementMe... |
// https://html.spec.whatwg.org/multipage/#dom-tbody-insertrow
fn InsertRow(&self, index: i32) -> Fallible<DomRoot<HTMLElement>> {
let node = self.upcast::<Node>();
node.insert_cell_or_row(
index,
|| self.Rows(),
|| HTMLTableRowElement::new(local_name!("tr")... | {
HTMLCollection::create(&window_from_node(self), self.upcast(), Box::new(RowsFilter))
} | identifier_body |
htmltablesectionelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{
self, HTMLTableSectionElementMe... | htmlelement: HTMLElement,
}
impl HTMLTableSectionElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLTableSectionElement {
HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, d... | random_line_split | |
lib.rs | #![doc(
html_logo_url = "https://cdn.rawgit.com/urschrei/polyline-ffi/master/line.svg",
html_root_url = "https://docs.rs/polyline-ffi/"
)]
//! This module exposes functions for accessing the Polyline encoding and decoding functions via FFI
//!
//!
//! ## A Note on Coordinate Order
//! This crate uses `Coordinat... | ///
/// This function is unsafe because it accesses a raw pointer which could contain arbitrary data
#[no_mangle]
pub extern "C" fn drop_float_array(_: InternalArray) {}
/// Free `CString` memory which Rust has allocated across the FFI boundary
///
/// # Safety
///
/// This function is unsafe because it accesses a raw... |
/// Free Array memory which Rust has allocated across the FFI boundary
///
/// # Safety | random_line_split |
lib.rs | #![doc(
html_logo_url = "https://cdn.rawgit.com/urschrei/polyline-ffi/master/line.svg",
html_root_url = "https://docs.rs/polyline-ffi/"
)]
//! This module exposes functions for accessing the Polyline encoding and decoding functions via FFI
//!
//!
//! ## A Note on Coordinate Order
//! This crate uses `Coordinat... | {
use std::clone::Clone;
let arr = include!("../test_fixtures/berlin.rs");
let s = include!("../test_fixtures/berlin_decoded.rs");
for _ in 0..9999 {
let a = arr.clone();
let s_ = s.clone();
let n = 5;
let input_ls: ExternalArray = a.into()... | t_long_vec() | identifier_name |
lib.rs | #![doc(
html_logo_url = "https://cdn.rawgit.com/urschrei/polyline-ffi/master/line.svg",
html_root_url = "https://docs.rs/polyline-ffi/"
)]
//! This module exposes functions for accessing the Polyline encoding and decoding functions via FFI
//!
//!
//! ## A Note on Coordinate Order
//! This crate uses `Coordinat... |
#[cfg(test)]
mod tests {
use super::*;
use std::ptr;
#[test]
fn test_drop_empty_float_array() {
let original: LineString<_> = vec![[2.0, 1.0], [4.0, 3.0]].into();
// move into an Array, and leak it
let mut arr: InternalArray = original.into();
// zero Array contents
... | {
drop(CString::from_raw(p));
} | identifier_body |
test.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 ... | (f: ~fn()) -> Thread {
let f = Cell::new(f);
let thread = do Thread::start {
run_in_newsched_task_core(f.take());
};
return thread;
}
/// Get a ~Task for testing purposes other than actually scheduling it.
pub fn with_test_task(blk: ~fn(~Task) -> ~Task) {
do run_in_bare_thread {
... | spawntask_thread | identifier_name |
test.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 ... |
}
#[doc(hidden)]
pub fn prepare_for_lots_of_tests() {
// Bump the fd limit on OS X. See darwin_fd_limit for an explanation.
unsafe { darwin_fd_limit::raise_fd_limit() }
}
/// Create more than one scheduler and run a function in a task
/// in one of the schedulers. The schedulers will stay alive
/// until the... | {} | identifier_body |
test.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 sleepers = SleeperList::new();
let mut handles = ~[];
let mut scheds = ~[];
let mut work_queues = ~[];
for _ in range(0u, nthreads) {
let work_queue = WorkQueue::new();
work_queues.push(work_queue);
}
for i... | {
// Using more threads than cores in test code
// to force the OS to preempt them frequently.
// Assuming that this help stress test concurrent types.
util::num_cpus() * 2
} | conditional_block |
test.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 ... | // to force the OS to preempt them frequently.
// Assuming that this help stress test concurrent types.
util::num_cpus() * 2
}
}
};
let sleepers = SleeperList::new();
let mut handles = ~[];
let mut ... | if util::limit_thread_creation_due_to_osx_and_valgrind() {
1
} else {
// Using more threads than cores in test code | random_line_split |
trace.rs | //! The Trace trait must be implemented by every type that can be GC managed.
use heap::TraceStack;
/// Trace trait. Every type that can be managed by the GC must implement this trait.
/// This trait is unsafe in that incorrectly implementing it can cause Undefined Behavior.
pub unsafe trait Trace {
/// If the ... |
/// If the type can contain GC managed pointers, this must visit each pointer.
///
/// This function must be thread-safe!
///
/// It must read a snapshot of the data structure it is implemented for.
unsafe fn trace(&self, _stack: &mut TraceStack) {}
}
unsafe impl Trace for usize {}
unsafe im... | {
false
} | identifier_body |
trace.rs | //! The Trace trait must be implemented by every type that can be GC managed.
use heap::TraceStack;
/// Trace trait. Every type that can be managed by the GC must implement this trait.
/// This trait is unsafe in that incorrectly implementing it can cause Undefined Behavior.
pub unsafe trait Trace { |
/// If the type can contain GC managed pointers, this must visit each pointer.
///
/// This function must be thread-safe!
///
/// It must read a snapshot of the data structure it is implemented for.
unsafe fn trace(&self, _stack: &mut TraceStack) {}
}
unsafe impl Trace for usize {}
unsafe imp... | /// If the type can contain GC managed pointers, this must return true
fn traversible(&self) -> bool {
false
} | random_line_split |
trace.rs | //! The Trace trait must be implemented by every type that can be GC managed.
use heap::TraceStack;
/// Trace trait. Every type that can be managed by the GC must implement this trait.
/// This trait is unsafe in that incorrectly implementing it can cause Undefined Behavior.
pub unsafe trait Trace {
/// If the ... | (&self, _stack: &mut TraceStack) {}
}
unsafe impl Trace for usize {}
unsafe impl Trace for isize {}
unsafe impl Trace for i8 {}
unsafe impl Trace for u8 {}
unsafe impl Trace for i16 {}
unsafe impl Trace for u16 {}
unsafe impl Trace for i32 {}
unsafe impl Trace for u32 {}
unsafe impl Trace for i64 {}
unsafe impl Trace... | trace | identifier_name |
fixed_interval.rs | use std::iter::Iterator;
use std::time::Duration;
/// A retry strategy driven by a fixed interval.
#[derive(Debug, Clone)]
pub struct FixedInterval {
duration: Duration,
}
impl FixedInterval {
/// Constructs a new fixed interval strategy.
pub fn new(duration: Duration) -> FixedInterval {
FixedInte... |
}
#[test]
fn returns_some_fixed() {
let mut s = FixedInterval::new(Duration::from_millis(123));
assert_eq!(s.next(), Some(Duration::from_millis(123)));
assert_eq!(s.next(), Some(Duration::from_millis(123)));
assert_eq!(s.next(), Some(Duration::from_millis(123)));
}
| {
Some(self.duration)
} | identifier_body |
fixed_interval.rs | use std::iter::Iterator;
use std::time::Duration;
/// A retry strategy driven by a fixed interval.
#[derive(Debug, Clone)]
pub struct FixedInterval {
duration: Duration,
}
impl FixedInterval {
/// Constructs a new fixed interval strategy.
pub fn | (duration: Duration) -> FixedInterval {
FixedInterval { duration: duration }
}
/// Constructs a new fixed interval strategy,
/// given a duration in milliseconds.
pub fn from_millis(millis: u64) -> FixedInterval {
FixedInterval {
duration: Duration::from_millis(millis),
... | new | identifier_name |
fixed_interval.rs | use std::iter::Iterator;
use std::time::Duration;
/// A retry strategy driven by a fixed interval.
#[derive(Debug, Clone)]
pub struct FixedInterval {
duration: Duration,
}
impl FixedInterval {
/// Constructs a new fixed interval strategy.
pub fn new(duration: Duration) -> FixedInterval {
FixedInte... |
#[test]
fn returns_some_fixed() {
let mut s = FixedInterval::new(Duration::from_millis(123));
assert_eq!(s.next(), Some(Duration::from_millis(123)));
assert_eq!(s.next(), Some(Duration::from_millis(123)));
assert_eq!(s.next(), Some(Duration::from_millis(123)));
} | fn next(&mut self) -> Option<Duration> {
Some(self.duration)
}
} | random_line_split |
traits.rs | // * This file is part of the uutils coreutils package.
// *
// * (c) 2020 Alex Lyon <arcterus@mail.com> | // * (c) 2020 nicoo <nicoo@debian.org>
// *
// * For the full copyright and license information, please view the LICENSE file
// * that was distributed with this source code.
pub(crate) use num_traits::{
identities::{One, Zero},
ops::overflowing::OverflowingAdd,
};
use num_traits::{
int::PrimInt,
... | random_line_split | |
graph.rs | format!("bb {} is not in precessors: {:?}", bb.index(), predecessors)
}
);
}
}
basic_blocks.push(bb);
let term = data.terminator();
match term.kind {
TerminatorKind::Return {.. }
... | {
(Some(successor), Some(loop_header))
} | conditional_block | |
graph.rs | 's `successors()`. Coverage spans must map to actual source code,
// so compiler generated blocks and paths can be ignored. To that end, the CFG traversal
// intentionally omits unwind paths.
// FIXME(#78544): MIR InstrumentCoverage: Improve coverage of `#[should_panic]` tests and
// `ca... |
#[inline(always)]
pub fn iter_enumerated(
&self,
) -> impl Iterator<Item = (BasicCoverageBlock, &BasicCoverageBlockData)> {
self.bcbs.iter_enumerated()
}
#[inline(always)]
pub fn iter_enumerated_mut(
&mut self,
) -> impl Iterator<Item = (BasicCoverageBlock, &mut Ba... | {
let bcb = BasicCoverageBlock::from_usize(bcbs.len());
for &bb in basic_blocks.iter() {
bb_to_bcb[bb] = Some(bcb);
}
let bcb_data = BasicCoverageBlockData::from(basic_blocks);
debug!("adding bcb{}: {:?}", bcb.index(), bcb_data);
bcbs.push(bcb_data);
} | identifier_body |
graph.rs | terminator's `successors()`. Coverage spans must map to actual source code,
// so compiler generated blocks and paths can be ignored. To that end, the CFG traversal
// intentionally omits unwind paths.
// FIXME(#78544): MIR InstrumentCoverage: Improve coverage of `#[should_panic]` tests and
... |
impl BasicCoverageBlockData {
pub fn from(basic_blocks: Vec<BasicBlock>) -> Self {
assert!(basic_blocks.len() > 0);
Self { basic_blocks, counter_kind: None, edge_from_bcbs: None }
}
#[inline(always)]
pub fn leader_bb(&self) -> BasicBlock {
self.basic_blocks[0]
}
#[inli... | pub basic_blocks: Vec<BasicBlock>,
pub counter_kind: Option<CoverageKind>,
edge_from_bcbs: Option<FxHashMap<BasicCoverageBlock, CoverageKind>>,
} | random_line_split |
graph.rs | 's `successors()`. Coverage spans must map to actual source code,
// so compiler generated blocks and paths can be ignored. To that end, the CFG traversal
// intentionally omits unwind paths.
// FIXME(#78544): MIR InstrumentCoverage: Improve coverage of `#[should_panic]` tests and
// `ca... | (&self, node: BasicCoverageBlock, dom: BasicCoverageBlock) -> bool {
self.dominators.as_ref().unwrap().is_dominated_by(node, dom)
}
#[inline(always)]
pub fn dominators(&self) -> &Dominators<BasicCoverageBlock> {
self.dominators.as_ref().unwrap()
}
}
impl Index<BasicCoverageBlock> for C... | is_dominated_by | identifier_name |
encoder.rs | extern crate libc;
use std::io::Write;
use std::io::Result;
use std::cmp;
use std::ptr;
use super::liblz4::*;
use self::libc::size_t;
struct EncoderContext {
c: LZ4FCompressionContext,
}
#[derive(Clone)]
pub struct EncoderBuilder {
block_size: BlockSize,
block_mode: BlockMode,
checksum: ContentChecksum,
// 0 =... | }
pub fn checksum(&mut self, checksum: ContentChecksum) -> &mut Self {
self.checksum = checksum;
self
}
pub fn level(&mut self, level: u32) -> &mut Self {
self.level = level;
self
}
pub fn auto_flush(&mut self, auto_flush: bool) -> &mut Self {
self.auto_flush = auto_flush;
self
}
pub fn build<W:... |
pub fn block_mode(&mut self, block_mode: BlockMode) -> &mut Self {
self.block_mode = block_mode;
self | random_line_split |
encoder.rs | extern crate libc;
use std::io::Write;
use std::io::Result;
use std::cmp;
use std::ptr;
use super::liblz4::*;
use self::libc::size_t;
struct EncoderContext {
c: LZ4FCompressionContext,
}
#[derive(Clone)]
pub struct EncoderBuilder {
block_size: BlockSize,
block_mode: BlockMode,
checksum: ContentChecksum,
// 0 =... | c: try! (EncoderContext::new()),
limit: block_size,
buffer: Vec::with_capacity(try! (check_error(unsafe {LZ4F_compressBound(block_size as size_t, &preferences)})))
};
try! (encoder.write_header(&preferences));
Ok (encoder)
}
}
impl<W: Write> Encoder<W> {
fn write_header(&mut self, preferences: &LZ4FP... | {
let block_size = self.block_size.get_size();
let preferences = LZ4FPreferences
{
frame_info: LZ4FFrameInfo
{
block_size_id: self.block_size.clone(),
block_mode: self.block_mode.clone(),
content_checksum_flag: self.checksum.clone(),
reserved: [0; 5],
},
compression_level: self.level,
... | identifier_body |
encoder.rs | extern crate libc;
use std::io::Write;
use std::io::Result;
use std::cmp;
use std::ptr;
use super::liblz4::*;
use self::libc::size_t;
struct | {
c: LZ4FCompressionContext,
}
#[derive(Clone)]
pub struct EncoderBuilder {
block_size: BlockSize,
block_mode: BlockMode,
checksum: ContentChecksum,
// 0 == default (fast mode); values above 16 count as 16; values below 0 count as 0
level: u32,
// 1 == always flush (reduce need for tmp buffer)
auto_flush: boo... | EncoderContext | identifier_name |
test.rs | extern crate mio;
extern crate bytes;
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate tempdir;
pub use ports::localhost;
mod test_battery;
mod test_close_on_drop;
mod test_echo_server;
mod test_multicast;
mod test_notify;
mod test_register_deregister;
mod test_register_multiple_event_loops;
mod ... | () -> usize {
unsafe {
// If the atomic was never used, set it to the initial port
NEXT_PORT.compare_and_swap(0, FIRST_PORT, SeqCst);
// Get and increment the port list
NEXT_PORT.fetch_add(1, SeqCst)
}
}
pub fn localhost() -> SocketAddr {
... | next_port | identifier_name |
test.rs | extern crate mio;
extern crate bytes;
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate tempdir; | mod test_battery;
mod test_close_on_drop;
mod test_echo_server;
mod test_multicast;
mod test_notify;
mod test_register_deregister;
mod test_register_multiple_event_loops;
mod test_tcp_level;
mod test_tick;
mod test_timer;
mod test_udp_level;
mod test_udp_socket;
// ===== Unix only tests =====
#[cfg(unix)]
mod test_uni... |
pub use ports::localhost;
| random_line_split |
test.rs | extern crate mio;
extern crate bytes;
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate tempdir;
pub use ports::localhost;
mod test_battery;
mod test_close_on_drop;
mod test_echo_server;
mod test_multicast;
mod test_notify;
mod test_register_deregister;
mod test_register_multiple_event_loops;
mod ... | {
use std::thread;
thread::sleep_ms(ms as u32);
} | identifier_body | |
opt-in-copy.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 ... | struct CantCopyThis;
struct IWantToCopyThis {
but_i_cant: CantCopyThis,
}
impl Copy for IWantToCopyThis {}
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| ERROR E0277
enum CantCopyThisEither {
A,
B,
}
enum IWantToCopyThisToo {
ButICant(CantCopyThisEither),
}
impl Copy for IWan... | // option. This file may not be copied, modified, or distributed
// except according to those terms.
| random_line_split |
opt-in-copy.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 |
attrs-after-extern-mod.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 ... | () {}
| main | identifier_name |
attrs-after-extern-mod.rs | // Copyright 2013 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.
// Constants (stati... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
attrs-after-extern-mod.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 ... | {} | identifier_body | |
abilities.rs | // Copyright (c) 2018 Chef Software Inc. and/or applicable contributors
//
// 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
// | // See the License for the specific language governing permissions and
// limitations under the License.
//! Windows-equivalent for determining if the current user has certain
//! abilities.
// The Linux version uses Capabilities. Until we sort out the
// equivalent implementation on Windows, we assume that the curre... | // 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 |
abilities.rs | // Copyright (c) 2018 Chef Software Inc. and/or applicable contributors
//
// 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 r... | {
true
} | identifier_body | |
abilities.rs | // Copyright (c) 2018 Chef Software Inc. and/or applicable contributors
//
// 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 r... | () -> bool {
true
}
| can_run_services_as_svc_user | identifier_name |
scripts.rs | //! This integration test runs the test scripts found in
//! the scripts/ directory
//! See image-worker/README.md for a full description of
//! the test script syntax and details about this test
//! runner.
extern crate image;
use std::fs::{File, read_dir, remove_file, copy};
use std::io::{BufReader, BufRead, Write}... | (child: &mut Child, line: &str) -> Result<(), String> {
if let Some(ref mut stdin) = child.stdin {
match write!(stdin, "{}\n", line) {
Ok(_) => Ok(()),
Err(error) => Err(format!("{}", error)),
}
}
else {
// should not happen. This panic is just in case.
... | send_input | identifier_name |
scripts.rs | //! This integration test runs the test scripts found in
//! the scripts/ directory
//! See image-worker/README.md for a full description of
//! the test script syntax and details about this test
//! runner.
extern crate image;
use std::fs::{File, read_dir, remove_file, copy};
use std::io::{BufReader, BufRead, Write}... |
fn check_output(output: Option<&String>, arg: &str) -> Result<(), String> {
// This is brittle, but it doesn't seem worth it to implement something
// more robust for now. You will need to exactly match the output in your
// test script if you want to test output
if let Some(response) = output {
... | {
if let Some(response) = output {
// This check is not foolproof and may eventually cause problems.
// It is good enough for now though we're running with it
if response.starts_with("{\"Success\":") {
Ok(())
}
else {
Err(format!("Worker did not produc... | identifier_body |
scripts.rs | //! This integration test runs the test scripts found in
//! the scripts/ directory
//! See image-worker/README.md for a full description of
//! the test script syntax and details about this test
//! runner.
extern crate image;
use std::fs::{File, read_dir, remove_file, copy};
use std::io::{BufReader, BufRead, Write}... | let expected_path = expected_path.trim();
let output = image::open(output_path).map_err(|e| format!("{}", e))?;
let expected = image::open(expected_path).map_err(|e| format!("{}", e))?;
let output = output.raw_pixels();
let expected = expected.raw_pixels();
if output == expected {
rem... |
// ignore any extra whitespace
let output_path = output_path.trim(); | random_line_split |
simd.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (pub u64, pub u64);
#[experimental]
#[simd]
#[deriving(Show)]
#[repr(C)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
#[experimental]
#[simd]
#[deriving(Show)]
#[repr(C)]
pub struct f64x2(pub f64, pub f64);
| u64x2 | identifier_name |
simd.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | pub struct f64x2(pub f64, pub f64); | random_line_split | |
observable.rs | // Rx -- Reactive programming for Rust
// Copyright 2016 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
use observer::Observer;
use obs... | F>(&'s mut self, f: F) -> MapObservable<'s, Self, F>
where F: Fn(Self::Item) -> U {
MapObservable::new(self, f)
}
/// Transforms an observable by applying f the error in case of failure.
fn map_error<'s, F, G>(&'s mut self, f: G) -> MapErrorObservable<'s, Self, G>
where G: Fn(Self::... | U, | identifier_name |
observable.rs | // Rx -- Reactive programming for Rust | //
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
use observer::Observer;
use observer::{NextObserver, CompletedObserver, ErrorObserver, OptionObserver, Resu... | // Copyright 2016 Ruud van Asseldonk | random_line_split |
observable.rs | // Rx -- Reactive programming for Rust
// Copyright 2016 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
use observer::Observer;
use obs... | / Subscribes a function that takes an option.
///
/// The function translates into an observer as follows:
///
/// * `on_next(x)`: calls the functions with `Some(x)`.
/// * `on_completed()`: calls the function with `None`.
/// * `on_error(error)`: panics.
///
/// After the function ha... | let observer = ErrorObserver {
fn_next: on_next,
fn_completed: on_completed,
fn_error: on_error,
};
self.subscribe(observer)
}
// | identifier_body |
timer.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// 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/lice... | {
Timer2,
}
/// Structure describing a Timer.
#[derive(Copy)]
pub struct Timer {
reg: &'static reg::TIMER,
}
impl Timer {
/// Create and start a Timer.
pub fn new(peripheral: TimerPeripheral, counter: u32, div_shift: u16) -> Timer {
use super::peripheral_clock as pc;
use self::TimerPeripheral::*;
... | TimerPeripheral | identifier_name |
timer.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// 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/lice... |
}
mod reg {
use util::volatile_cell::VolatileCell;
use core::ops::Drop;
ioregs!(TIMER = {
0x00 => reg16 cr1 { // control 1
0 => counter_enable : rw,
1 => update_disable : rw,
2 => update_request_source : rw,
3 => one_pulse_mode : rw,
4 => direction : r... | {
self.reg.cnt.counter() as u32
} | identifier_body |
timer.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Dzmitry "kvark" Malyshau <kvarkus@gmail.com>
//
// 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/lice... | // distributed under the License is distributed on an "AS IS" BASIS,
// 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.
//! Timer configuration for ST STM32L1.
//!
//! This code supports on... | //
// Unless required by applicable law or agreed to in writing, software | random_line_split |
response.rs | //! # HTTP Response generation
//!
//! The HTTP Response code converts response objects into octets and
//! writes them to a stream.
// ****************************************************************************
//
// Imports
//
// ****************************************************************************
use std:... | // Private Types
//
// ****************************************************************************
// None
// ****************************************************************************
//
// Public Functions
//
// ****************************************************************************
impl<'a> HttpResponse<'... | pub body: Cow<'a, str>,
}
// ****************************************************************************
// | random_line_split |
response.rs | //! # HTTP Response generation
//!
//! The HTTP Response code converts response objects into octets and
//! writes them to a stream.
// ****************************************************************************
//
// Imports
//
// ****************************************************************************
use std:... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
// Write strictly the first element into the supplied output
// stream: `f`. Returns `fmt::Result` which indicates whether the
// operation succeeded or failed. Note that `write!` uses syntax which
// is very similar to `println!`.
... | fmt | identifier_name |
response.rs | //! # HTTP Response generation
//!
//! The HTTP Response code converts response objects into octets and
//! writes them to a stream.
// ****************************************************************************
//
// Imports
//
// ****************************************************************************
use std:... | HttpResponseStatus::UseProxy => "Use Proxy",
HttpResponseStatus::SwitchProxy => "Switch Proxy",
HttpResponseStatus::TemporaryRedirect => "Temporary Redirect",
HttpResponseStatus::PermanentRedirect => "Permanent Redirect",
HttpResponseStatus::BadRequest => "Bad... | {
match *self {
HttpResponseStatus::Continue => "Continue",
HttpResponseStatus::SwitchingProtocols => "Switching Protocols",
HttpResponseStatus::Processing => "Processing",
HttpResponseStatus::OK => "OK",
HttpResponseStatus::Created => "Created",
... | identifier_body |
loads.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 ... |
// CHECK-LABEL: small_struct_alignment
// The struct is loaded as i32, but its alignment is lower, go with 1 byte to avoid target
// dependent alignment
#[no_mangle]
pub fn small_struct_alignment(x: Bytes) -> Bytes {
// CHECK: [[VAR:%[0-9]+]] = load i32* %{{.*}}, align 1
// CHECK: ret i32 [[VAR]]
x
}
| {
// CHECK: [[VAR:%[0-9]+]] = load i32* %{{.*}}, align 1
// CHECK: ret i32 [[VAR]]
x
} | identifier_body |
loads.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 ... | (x: &i32) -> &i32 {
// CHECK: load i32** %x{{.*}},!nonnull
x
}
// CHECK-LABEL: @_box
#[no_mangle]
pub fn _box(x: Box<i32>) -> i32 {
// CHECK: load i32** %x{{.*}},!nonnull
*x
}
// CHECK-LABEL: small_array_alignment
// The array is loaded as i32, but its alignment is lower, go with 1 byte to avoid target
// dep... | borrow | identifier_name |
loads.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 ... | #[no_mangle]
pub fn borrow(x: &i32) -> &i32 {
// CHECK: load i32** %x{{.*}},!nonnull
x
}
// CHECK-LABEL: @_box
#[no_mangle]
pub fn _box(x: Box<i32>) -> i32 {
// CHECK: load i32** %x{{.*}},!nonnull
*x
}
// CHECK-LABEL: small_array_alignment
// The array is loaded as i32, but its alignment is lower, go with 1 b... | }
// CHECK-LABEL: @borrow | random_line_split |
mod.rs | use alloc::boxed::Box;
use core::str;
use fs::{KScheme, Resource};
use system::error::{Error, Result, ENOENT};
use system::syscall::O_CREAT;
pub use self::dsdt::DSDT;
pub use self::fadt::FADT;
pub use self::madt::MADT;
pub use self::rsdt::RSDT;
pub use self::sdt::SDTHeader;
pub use self::ssdt::SSDT;
pub mod aml;
pub... | (&self) -> &'static str {
"acpi"
}
fn open(&mut self, url: &str, flags: usize) -> Result<Box<Resource>> {
if url.splitn(2, ":").nth(1).unwrap_or("") == "off" && flags & O_CREAT == O_CREAT {
match self.fadt {
Some(fadt) => {
debugln!("Powering Off"... | scheme | identifier_name |
mod.rs | use alloc::boxed::Box;
use core::str;
use fs::{KScheme, Resource};
use system::error::{Error, Result, ENOENT};
use system::syscall::O_CREAT;
pub use self::dsdt::DSDT;
pub use self::fadt::FADT;
pub use self::madt::MADT;
pub use self::rsdt::RSDT;
pub use self::sdt::SDTHeader;
pub use self::ssdt::SSDT;
pub mod aml;
pub... |
}
}
}
impl KScheme for Acpi {
fn scheme(&self) -> &'static str {
"acpi"
}
fn open(&mut self, url: &str, flags: usize) -> Result<Box<Resource>> {
if url.splitn(2, ":").nth(1).unwrap_or("") == "off" && flags & O_CREAT == O_CREAT {
match self.fadt {
So... | {
debugln!("{}", e);
None
} | conditional_block |
mod.rs | use alloc::boxed::Box;
use core::str;
use fs::{KScheme, Resource};
use system::error::{Error, Result, ENOENT};
use system::syscall::O_CREAT;
pub use self::dsdt::DSDT;
pub use self::fadt::FADT;
pub use self::madt::MADT;
pub use self::rsdt::RSDT;
pub use self::sdt::SDTHeader;
pub use self::ssdt::SSDT;
pub mod aml;
pub... | acpi.dsdt = Some(dsdt);
}
acpi.fadt = Some(fadt);
} else if let Some(ssdt) = SSDT::new(header) {
syslog_debug!("SSDT:");
aml::parse(ssdt.data);
acpi.ssd... | {
match RSDT::new() {
Ok(rsdt) => {
// debugln!("{:#?}", rsdt);
let mut acpi = box Acpi {
rsdt: rsdt,
fadt: None,
dsdt: None,
ssdt: None,
madt: None,
}... | identifier_body |
mod.rs | use alloc::boxed::Box;
use core::str;
use fs::{KScheme, Resource};
use system::error::{Error, Result, ENOENT};
use system::syscall::O_CREAT;
pub use self::dsdt::DSDT;
pub use self::fadt::FADT;
pub use self::madt::MADT;
pub use self::rsdt::RSDT;
pub use self::sdt::SDTHeader;
pub use self::ssdt::SSDT;
pub mod aml;
pub... | aml::parse(ssdt.data);
acpi.ssdt = Some(ssdt);
} else if let Some(madt) = MADT::new(header) {
syslog_debug!("{:#?}", madt);
acpi.madt = Some(madt);
} else {
sys... | syslog_debug!("SSDT:"); | random_line_split |
showbayer.rs | //! ShowBayer.
extern crate bayer;
extern crate sdl2;
use std::cmp::min;
use std::env;
use std::fs::File;
use std::path::Path;
use std::slice;
use bayer::*;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::PixelFormatEnum;
#[derive(Copy,Clone,Debug,Eq,PartialEq)]
enum ImgDepth {
Depth8,
... | {
canvas.clear();
let _ = canvas.copy(&texture, None, None);
canvas.present();
} | identifier_body | |
showbayer.rs | //! ShowBayer.
extern crate bayer;
extern crate sdl2;
use std::cmp::min;
use std::env;
use std::fs::File;
use std::path::Path;
use std::slice;
use bayer::*;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::PixelFormatEnum;
#[derive(Copy,Clone,Debug,Eq,PartialEq)]
enum ImgDepth {
Depth8,
... | (alg: Demosaic) {
let s = match alg {
Demosaic::None => "none",
Demosaic::NearestNeighbour => "nearest neighbour",
Demosaic::Linear => "linear",
Demosaic::Cubic => "cubic",
};
println!("Demosaic: {}", s);
}
fn read_file(
path: &Path, bayer_w: usize, bayer_h: usize,
... | print_alg | identifier_name |
showbayer.rs | //! ShowBayer.
extern crate bayer;
extern crate sdl2;
use std::cmp::min;
use std::env;
use std::fs::File;
use std::path::Path;
use std::slice;
use bayer::*;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::PixelFormatEnum;
#[derive(Copy,Clone,Debug,Eq,PartialEq)]
enum ImgDepth {
Depth8,
... | }
Event::KeyDown { keycode: Some(Keycode::Left),.. } => {
if idx == 0 {
idx = files.len() - 1;
} else {
idx = idx - 1;
}
}
_ => (),
}
... | {
match e {
Event::Quit {..}
| Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
break 'mainloop;
},
Event::KeyDown { keycode: Some(Keycode::F1), .. } => { cfa = CFA::BGGR; },
Event::KeyDown { keyco... | conditional_block |
showbayer.rs | //! ShowBayer.
extern crate bayer;
extern crate sdl2;
use std::cmp::min;
use std::env;
use std::fs::File;
use std::path::Path;
use std::slice;
use bayer::*;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::PixelFormatEnum;
#[derive(Copy,Clone,Debug,Eq,PartialEq)]
enum ImgDepth {
Depth8,
... | },
Event::KeyDown { keycode: Some(Keycode::F1),.. } => { cfa = CFA::BGGR; },
Event::KeyDown { keycode: Some(Keycode::F2),.. } => { cfa = CFA::GBRG; },
Event::KeyDown { keycode: Some(Keycode::F3),.. } => { cfa = CFA::GRBG; },
Event::KeyDown... | break 'mainloop; | random_line_split |
cssnamespacerule.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::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceR... |
}
impl CSSNamespaceRuleMethods for CSSNamespaceRule {
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-prefix
fn Prefix(&self) -> DOMString {
let guard = self.cssrule.shared_lock().read();
self.namespacerule.read_with(&guard).prefix
.as_ref().map(|s| s.to_string().into())
... | {
reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule),
window,
CSSNamespaceRuleBinding::Wrap)
} | identifier_body |
cssnamespacerule.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::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceR... | (&self) -> u16 {
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;
CSSRuleConstants::NAMESPACE_RULE
}
fn get_css(&self) -> DOMString {
let guard = self.cssrule.shared_lock().read();
self.namespacerule.read_with(&guard).to_css_string(&guard).into()
}
}
| ty | identifier_name |
cssnamespacerule.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::CSSNamespaceRuleBinding;
use dom::bindings::codegen::Bindings::CSSNamespaceR... | use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylearc::Arc;
use style::stylesheets::NamespaceRule;
#[dom_struct]
pub struct CSSNamespaceRule {
cssrule: CSSRule,
#[ignore_heap_size_of = "Arc"]
namespacerule: Arc<Locked<NamespaceRule>>,
}
impl CSSNamespaceRule {
fn new_inherited(parent_s... | use dom::bindings::str::DOMString;
use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct; | random_line_split |
exec.rs | // Copyright 2017 Google Inc.
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
use std::error::Error;
use std::ffi::OsString;
use std::io::{stderr, Write};
use std::path::Path;
use std::process::Command;
use walkdir:... | (
executable: &str,
args: &[&str],
exec_in_parent_dir: bool,
) -> Result<Self, Box<dyn Error>> {
let transformed_args = args
.iter()
.map(|&a| match a {
"{}" => Arg::Filename,
_ => Arg::LiteralArg(OsString::from(a)),
}... | new | identifier_name |
exec.rs | // Copyright 2017 Google Inc.
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
use std::error::Error;
use std::ffi::OsString;
use std::io::{stderr, Write};
use std::path::Path;
use std::process::Command;
use walkdir:... | else {
file_info.path().to_path_buf()
};
for arg in &self.args {
command.arg(match *arg {
Arg::LiteralArg(ref a) => a.as_os_str(),
Arg::Filename => path_to_file.as_os_str(),
});
}
if self.exec_in_parent_dir {
... | {
if let Some(f) = file_info.path().file_name() {
Path::new(".").join(f)
} else {
Path::new(".").join(file_info.path())
}
} | conditional_block |
exec.rs | // Copyright 2017 Google Inc.
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
use std::error::Error;
use std::ffi::OsString;
use std::io::{stderr, Write};
use std::path::Path;
use std::process::Command;
use walkdir:... | Arg::Filename => path_to_file.as_os_str(),
});
}
if self.exec_in_parent_dir {
match file_info.path().parent() {
None => {
// Root paths like "/" have no parent. Run them from the root to match GNU find.
comm... | random_line_split | |
v10Data.rs | pub fn v10Data() -> [f64; 81] | v10List[16] = -0.0655694;
v10List[17] = -0.0556668;
v10List[18] = 0.0269233;
v10List[19] = 0.0368759;
v10List[20] = 0.0886982;
v10List[21] = 0.0965984;
v10List[22] = 0.0990651;
v10List[23] = 0.0818134;
v10List[24] = 0.0693681;
v10List[25] = 0.00481364;
v10List[26] = 0.0061198... | {
let mut v10List: [f64; 81] = [0.0; 81];
// index is wavelengths of light, stepped by 5, from 380 to 780
v10List[0] = -0.296898;
v10List[1] = -0.230842;
v10List[2] = -0.160906;
v10List[3] = -0.0696234;
v10List[4] = 0.0198897;
v10List[5] = 0.0648208;
v10List[6] = 0.0979055;
v10L... | identifier_body |
v10Data.rs | pub fn | () -> [f64; 81] {
let mut v10List: [f64; 81] = [0.0; 81];
// index is wavelengths of light, stepped by 5, from 380 to 780
v10List[0] = -0.296898;
v10List[1] = -0.230842;
v10List[2] = -0.160906;
v10List[3] = -0.0696234;
v10List[4] = 0.0198897;
v10List[5] = 0.0648208;
v10List[6] = 0.0... | v10Data | identifier_name |
v10Data.rs | pub fn v10Data() -> [f64; 81] {
let mut v10List: [f64; 81] = [0.0; 81];
// index is wavelengths of light, stepped by 5, from 380 to 780
v10List[0] = -0.296898;
v10List[1] = -0.230842;
v10List[2] = -0.160906;
v10List[3] = -0.0696234;
v10List[4] = 0.0198897;
v10List[5] = 0.0648208;
v1... | v10List[24] = 0.0693681;
v10List[25] = 0.00481364;
v10List[26] = 0.00611984;
v10List[27] = 0.0390983;
v10List[28] = -0.011949;
v10List[29] = -0.114423;
v10List[30] = -0.0860141;
v10List[31] = -0.237726;
v10List[32] = -0.0579294;
v10List[33] = -0.0644042;
v10List[34] = -0.0387... | v10List[22] = 0.0990651;
v10List[23] = 0.0818134; | random_line_split |
evaluation.rs | use std::cmp;
use rayon;
use {Expression, Length};
use reduce::{Reduce, ReduceScalar};
const MIN_THRESHOLD: usize = 4096;
const MAX_COUNT: usize = 32;
fn get_len(l1: Length, l2: Length) -> usize {
match cmp::min(l1, l2) {
Length::Finite(x) => x,
Length::Infinite => panic!("trying to reduce an inf... | <E, R>(e: E, reduce: R) -> R::Output
where E: Expression, R: Reduce<E::Element>
{
let len = get_len(e.length(), reduce.expected_length());
eval_inner(e, cmp::max(len / MAX_COUNT, MIN_THRESHOLD), reduce)
}
fn eval_inner<E, R>(e: E, threshold: usize, reduce: R) -> R::Output
where E: Expression, R: Reduc... | evaluate | identifier_name |
evaluation.rs | use std::cmp;
use rayon;
use {Expression, Length};
use reduce::{Reduce, ReduceScalar};
const MIN_THRESHOLD: usize = 4096;
const MAX_COUNT: usize = 32;
fn get_len(l1: Length, l2: Length) -> usize {
match cmp::min(l1, l2) {
Length::Finite(x) => x,
Length::Infinite => panic!("trying to reduce an inf... | {
let len = get_len(e.length(), reduce.expected_length());
assert!(e.length().compatible(reduce.expected_length()));
if len > threshold {
let (low, high, scalar) = reduce.split();
let (e_low, e_high) = e.split(false);
let (a, b) = rayon::join(|| eval_inner(e_low, threshold, low),
... | eval_inner(e, cmp::max(len / MAX_COUNT, MIN_THRESHOLD), reduce)
}
fn eval_inner<E, R>(e: E, threshold: usize, reduce: R) -> R::Output
where E: Expression, R: Reduce<E::Element> | random_line_split |
evaluation.rs | use std::cmp;
use rayon;
use {Expression, Length};
use reduce::{Reduce, ReduceScalar};
const MIN_THRESHOLD: usize = 4096;
const MAX_COUNT: usize = 32;
fn get_len(l1: Length, l2: Length) -> usize |
pub fn evaluate<E, R>(e: E, reduce: R) -> R::Output
where E: Expression, R: Reduce<E::Element>
{
let len = get_len(e.length(), reduce.expected_length());
eval_inner(e, cmp::max(len / MAX_COUNT, MIN_THRESHOLD), reduce)
}
fn eval_inner<E, R>(e: E, threshold: usize, reduce: R) -> R::Output
where E: Exp... | {
match cmp::min(l1, l2) {
Length::Finite(x) => x,
Length::Infinite => panic!("trying to reduce an infinite expression into an infinite reducer")
}
} | identifier_body |
noparse.rs | macro_rules! noparse(
($name:ident, $re:expr) => (
#[test]
fn $name() {
let re = $re;
match regex_new!(re) {
Err(_) => {},
Ok(_) => panic!("Regex '{}' should cause a parse error.", re),
}
}
);
);
noparse!(fail_double_re... | noparse!(fail_class_incomplete, "[A-");
noparse!(fail_class_not_closed, "[A");
noparse!(fail_class_no_begin, r"[\A]");
noparse!(fail_class_no_end, r"[\z]");
noparse!(fail_class_no_boundary, r"[\b]");
noparse!(fail_open_paren, "(");
noparse!(fail_close_paren, ")");
noparse!(fail_invalid_range, "[a-Z]");
noparse!(fail_em... | noparse!(fail_incomplete_escape, "\\"); | random_line_split |
mod.rs | //! Job scheduling.
use Result;
use system::Job;
mod impartial;
mod queue;
pub use self::impartial::Impartial;
pub use self::queue::{Interval, Queue};
/// A scheduling policy.
pub trait Schedule {
/// The data consumed by the policy.
type Data; | fn push(&mut self, f64, Self::Data) -> Result<()>;
}
/// A scheduling decision.
#[derive(Clone, Debug)]
pub enum Decision {
Accept {
/// The start of the execution interval.
start: f64,
/// The end of the execution interval.
finish: f64,
/// The mapping of the job to the... |
/// Take a decision with respect to a job.
fn next(&mut self, &Job) -> Result<Decision>;
/// Advance time and consume the data accumulated since the previous call. | random_line_split |
mod.rs | //! Job scheduling.
use Result;
use system::Job;
mod impartial;
mod queue;
pub use self::impartial::Impartial;
pub use self::queue::{Interval, Queue};
/// A scheduling policy.
pub trait Schedule {
/// The data consumed by the policy.
type Data;
/// Take a decision with respect to a job.
fn next(&mu... | {
Accept {
/// The start of the execution interval.
start: f64,
/// The end of the execution interval.
finish: f64,
/// The mapping of the job to the platform.
mapping: Mapping,
},
Reject,
}
/// A mapping of a job’s processing elements to the platform‘s proc... | Decision | identifier_name |
mod.rs | //! Job scheduling.
use Result;
use system::Job;
mod impartial;
mod queue;
pub use self::impartial::Impartial;
pub use self::queue::{Interval, Queue};
/// A scheduling policy.
pub trait Schedule {
/// The data consumed by the policy.
type Data;
/// Take a decision with respect to a job.
fn next(&mu... | NoData
}
}
| identifier_body | |
identity.rs | use std::ops::Mul;
use num::One;
use structs::mat;
use traits::operations::{Inv, Transpose};
use traits::geometry::{Translate, Rotate, Transform, AbsoluteRotate};
impl One for mat::Identity {
#[inline]
fn one() -> mat::Identity {
mat::Identity::new()
}
}
impl Inv for mat::Identity {
fn inv(&se... | v.clone()
}
#[inline]
fn inv_translate(&self, v: &V) -> V {
v.clone()
}
}
impl<V: Clone> Rotate<V> for mat::Identity {
#[inline]
fn rotate(&self, v: &V) -> V {
v.clone()
}
#[inline]
fn inv_rotate(&self, v: &V) -> V {
v.clone()
}
}
impl<V: Clone... |
impl<V: Clone> Translate<V> for mat::Identity {
#[inline]
fn translate(&self, v: &V) -> V { | random_line_split |
identity.rs | use std::ops::Mul;
use num::One;
use structs::mat;
use traits::operations::{Inv, Transpose};
use traits::geometry::{Translate, Rotate, Transform, AbsoluteRotate};
impl One for mat::Identity {
#[inline]
fn one() -> mat::Identity {
mat::Identity::new()
}
}
impl Inv for mat::Identity {
fn inv(&se... |
}
impl Transpose for mat::Identity {
#[inline]
fn transpose(&self) -> mat::Identity {
mat::Identity::new()
}
#[inline]
fn transpose_mut(&mut self) {
}
}
impl<V: Clone> Translate<V> for mat::Identity {
#[inline]
fn translate(&self, v: &V) -> V {
v.clone()
}
#[... | {
other
} | identifier_body |
identity.rs | use std::ops::Mul;
use num::One;
use structs::mat;
use traits::operations::{Inv, Transpose};
use traits::geometry::{Translate, Rotate, Transform, AbsoluteRotate};
impl One for mat::Identity {
#[inline]
fn one() -> mat::Identity {
mat::Identity::new()
}
}
impl Inv for mat::Identity {
fn inv(&se... | (&self, v: &V) -> V {
v.clone()
}
}
impl<V: Clone> AbsoluteRotate<V> for mat::Identity {
#[inline]
fn absolute_rotate(&self, v: &V) -> V {
v.clone()
}
}
impl<V: Clone> Transform<V> for mat::Identity {
#[inline]
fn transform(&self, v: &V) -> V {
v.clone()
}
#[in... | inv_rotate | 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/. */
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#[macro_use]
extern crate log;
extern crate a... | pub use compositor_task::{CompositorEventListener, CompositorProxy, CompositorTask};
pub use constellation::Constellation;
pub mod compositor_task;
mod compositor_layer;
mod compositor;
mod headless;
mod scrolling;
pub mod pipeline;
pub mod constellation;
pub mod windowing; | random_line_split | |
error.rs | use std::error::Error as StdError;
use std::fmt::{self, Debug, Display, Formatter};
use std::io;
use hyper::Error as HyperError;
use rustc_serialize::json::DecoderError;
use telegram_bot;
pub enum Error {
General(String),
}
impl From<HyperError> for Error {
fn from(e: HyperError) -> Error {
Error::Gen... | impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::General(ref msg) => msg,
}
}
} | Ok(())
}
}
| random_line_split |
error.rs | use std::error::Error as StdError;
use std::fmt::{self, Debug, Display, Formatter};
use std::io;
use hyper::Error as HyperError;
use rustc_serialize::json::DecoderError;
use telegram_bot;
pub enum | {
General(String),
}
impl From<HyperError> for Error {
fn from(e: HyperError) -> Error {
Error::General(e.description().to_owned())
}
}
impl From<DecoderError> for Error {
fn from(e: DecoderError) -> Error {
Error::General(e.description().to_owned())
}
}
impl From<io::Error> for ... | Error | identifier_name |
bcm.rs | use libc::{
c_int, c_short, c_uint, c_void, close, connect, fcntl, read, sockaddr, socket, timeval, write,
F_SETFL, O_NONBLOCK,
};
use futures;
// use mio::{Evented, PollOpt, Ready, Token};
use nix::net::if_::if_nametoindex;
use std::collections::VecDeque;
use std::fmt;
use std::io::{Error, ErrorKind};
use std... |
Poll::Ready(Some(Ok(frame)))
} else {
// This happens e.g. when a timed out msg is received
self.io.clear_read_ready(lw)?;
Poll::Pending
}
}
Err(e) => {
if e.kind() ==... | {
for frame in n.frames() {
self.frame_buffer.push_back(*frame)
}
} | conditional_block |
bcm.rs | use libc::{
c_int, c_short, c_uint, c_void, close, connect, fcntl, read, sockaddr, socket, timeval, write,
F_SETFL, O_NONBLOCK,
};
use futures;
// use mio::{Evented, PollOpt, Ready, Token};
use nix::net::if_::if_nametoindex;
use std::collections::VecDeque;
use std::fmt;
use std::io::{Error, ErrorKind};
use std... |
}
impl Stream for BcmStream {
type Item = io::Result<BcmMsgHead>;
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>> {
ready!(self.io.poll_read_ready(lw)?);
match self.io.get_ref().read_msg() {
Ok(n) => Poll::Ready(Some(Ok(n))),
Err(e) =>... | {
let io = PollEvented::new(bcm_socket);
BcmStream { io: io }
} | identifier_body |
bcm.rs | use libc::{
c_int, c_short, c_uint, c_void, close, connect, fcntl, read, sockaddr, socket, timeval, write,
F_SETFL, O_NONBLOCK,
};
use futures;
// use mio::{Evented, PollOpt, Ready, Token};
use nix::net::if_::if_nametoindex;
use std::collections::VecDeque;
use std::fmt;
use std::io::{Error, ErrorKind};
use std... | return unsafe { slice::from_raw_parts(self._frames.as_ptr(), self._nframes as usize) };
}
}
/// A socket for a CAN device, specifically for broadcast manager operations.
#[derive(Debug)]
pub struct CanBCMSocket {
pub fd: c_int,
}
pub struct BcmFrameStream {
io: PollEvented<CanBCMSocket>,
frame... | #[inline]
pub fn frames(&self) -> &[CanFrame] { | random_line_split |
bcm.rs | use libc::{
c_int, c_short, c_uint, c_void, close, connect, fcntl, read, sockaddr, socket, timeval, write,
F_SETFL, O_NONBLOCK,
};
use futures;
// use mio::{Evented, PollOpt, Ready, Token};
use nix::net::if_::if_nametoindex;
use std::collections::VecDeque;
use std::fmt;
use std::io::{Error, ErrorKind};
use std... | (&self, can_id: CanMessageId) -> io::Result<()> {
let frames = [CanFrame::new(CanMessageId::EFF(0x0), &[], false, false).unwrap(); MAX_NFRAMES as usize];
let msg = &BcmMsgHead {
_opcode: RX_DELETE,
_flags: 0,
_count: 0,
_ival1: c_timeval_new(time::Duratio... | filter_delete | identifier_name |
f02-thread-id.rs | /// Figure 11.2 Printing thread IDs
///
/// $ f02-thread-id | sed's/[0-9]//g; s/x[a-f]*//g'
/// main thread: pid tid ()
/// new thread: pid tid ()
extern crate libc;
extern crate apue;
use libc::{c_void, pthread_t};
use libc::{pthread_create, getpid, pthread_self, usleep};
use std::ptr::null_mut;
use apue::LibcRe... |
extern "C" fn thr_fn(_: *mut c_void) -> *mut c_void {
printids("new thread:");
0 as _
}
fn main() {
unsafe {
let mut ntid: pthread_t = std::mem::zeroed();
pthread_create(&mut ntid, null_mut(), thr_fn as _, null_mut()).check_zero()
.expect("can't create thread");
printid... | {
unsafe {
let pid = getpid();
let tid = pthread_self();
println!("{} pid {} tid {} (0x{:x})", s, pid, tid, tid);
}
} | identifier_body |
f02-thread-id.rs | /// Figure 11.2 Printing thread IDs
///
/// $ f02-thread-id | sed's/[0-9]//g; s/x[a-f]*//g'
/// main thread: pid tid ()
/// new thread: pid tid ()
extern crate libc;
extern crate apue;
use libc::{c_void, pthread_t};
use libc::{pthread_create, getpid, pthread_self, usleep};
use std::ptr::null_mut;
use apue::LibcRe... | (_: *mut c_void) -> *mut c_void {
printids("new thread:");
0 as _
}
fn main() {
unsafe {
let mut ntid: pthread_t = std::mem::zeroed();
pthread_create(&mut ntid, null_mut(), thr_fn as _, null_mut()).check_zero()
.expect("can't create thread");
printids("main thread:");
... | thr_fn | identifier_name |
f02-thread-id.rs | /// Figure 11.2 Printing thread IDs
///
/// $ f02-thread-id | sed's/[0-9]//g; s/x[a-f]*//g'
/// main thread: pid tid ()
/// new thread: pid tid ()
| use std::ptr::null_mut;
use apue::LibcResult;
fn printids(s: &str) {
unsafe {
let pid = getpid();
let tid = pthread_self();
println!("{} pid {} tid {} (0x{:x})", s, pid, tid, tid);
}
}
extern "C" fn thr_fn(_: *mut c_void) -> *mut c_void {
printids("new thread:");
0 as _
}
fn m... | extern crate libc;
extern crate apue;
use libc::{c_void, pthread_t};
use libc::{pthread_create, getpid, pthread_self, usleep}; | random_line_split |
type-sizes.rs | // 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.
use std::mem::size... | // 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.
// | random_line_split | |
type-sizes.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 ... | {a: isize, b: ()}
struct x {a: isize, b: (), c: ()}
struct y {x: isize}
enum e1 {
a(u8, u32), b(u32), c
}
enum e2 {
a(u32), b
}
enum e3 {
a([u16; 0], u8), b
}
pub fn main() {
assert_eq!(size_of::<u8>(), 1 as usize);
assert_eq!(size_of::<u32>(), 4 as usize);
assert_eq!(size_of::<char>(), 4 as... | w | identifier_name |
test_fcntl.rs | use nix::fcntl::{openat, open, OFlag, O_RDONLY, readlink, readlinkat};
use nix::sys::stat::Mode;
use nix::unistd::{close, read};
use tempdir::TempDir;
use tempfile::NamedTempFile;
use std::io::prelude::*;
use std::os::unix::fs;
#[test]
fn test_openat() |
#[test]
fn test_readlink() {
let tempdir = TempDir::new("nix-test_readdir")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let src = tempdir.path().join("a");
let dst = tempdir.path().join("b");
println!("a: {:?}, b: {:?}", &src, &dst);
fs::symlink(&src.as_path(), &dst.as_path()).unw... | {
const CONTENTS: &'static [u8] = b"abcd";
let mut tmp = NamedTempFile::new().unwrap();
tmp.write(CONTENTS).unwrap();
let dirfd = open(tmp.path().parent().unwrap(),
OFlag::empty(),
Mode::empty()).unwrap();
let fd = openat(dirfd,
tmp.path... | identifier_body |
test_fcntl.rs | use nix::fcntl::{openat, open, OFlag, O_RDONLY, readlink, readlinkat};
use nix::sys::stat::Mode;
use nix::unistd::{close, read};
use tempdir::TempDir;
use tempfile::NamedTempFile;
use std::io::prelude::*;
use std::os::unix::fs;
#[test]
fn test_openat() {
const CONTENTS: &'static [u8] = b"abcd";
let mut tmp = N... | () {
let (rd, wr) = pipe().unwrap();
let buf1 = b"abcdef";
let buf2 = b"defghi";
let mut iovecs = Vec::with_capacity(2);
iovecs.push(IoVec::from_slice(&buf1[0..3]));
iovecs.push(IoVec::from_slice(&buf2[0..3]));
let res = vmsplice(wr, &iovecs[..], SpliceFFlags::e... | test_vmsplice | identifier_name |
test_fcntl.rs | use nix::fcntl::{openat, open, OFlag, O_RDONLY, readlink, readlinkat};
use nix::sys::stat::Mode;
use nix::unistd::{close, read};
use tempdir::TempDir;
use tempfile::NamedTempFile;
use std::io::prelude::*;
use std::os::unix::fs;
#[test]
fn test_openat() {
const CONTENTS: &'static [u8] = b"abcd";
let mut tmp = N... | let mut iovecs = Vec::with_capacity(2);
iovecs.push(IoVec::from_slice(&buf1[0..3]));
iovecs.push(IoVec::from_slice(&buf2[0..3]));
let res = vmsplice(wr, &iovecs[..], SpliceFFlags::empty()).unwrap();
assert_eq!(6, res);
// Check the bytes can be read at rd.
let ... | let (rd, wr) = pipe().unwrap();
let buf1 = b"abcdef";
let buf2 = b"defghi"; | random_line_split |
cleanup-arm-conditional.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
fn do_something(t: &Test) -> isize {
// The cleanup scope for the result of `t.get_x()` should be the
// arm itself and not the match, otherwise we'll (potentially) get
// a crash trying to free an uninitialized stack slot.
match t {
&Test { x: 2 } if t.get_x().is_some() => {
t... | {
Some(box self.x)
} | identifier_body |
cleanup-arm-conditional.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 | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that cleanup scope for temporaries created in a match
// arm is confined to the match arm itself.
// pretty-expanded FIXME #23616
#![allow(unknown_features)]
#![feature(box_syntax, os)]
use std::os;
struct ... | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
cleanup-arm-conditional.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 t = Test { x: 1 };
do_something(&t);
}
| main | identifier_name |
mod.rs | //! Utilities for handling shell surfaces with the `wl_shell` protocol
//!
//! This module provides automatic handling of shell surfaces objects, by being registered
//! as a global handler for `wl_shell`. This protocol is deprecated in favor of `xdg_shell`,
//! thus this module is provided as a compatibility layer wit... | },
/// A pong event
///
/// The surface responded to its pending ping. If you receive this
/// event, smithay has already checked that the responded serial was valid.
Pong {
/// The surface that sent the pong
surface: ShellSurface,
},
/// Start of an interactive move
... | surface: ShellSurface, | random_line_split |
mod.rs | //! Utilities for handling shell surfaces with the `wl_shell` protocol
//!
//! This module provides automatic handling of shell surfaces objects, by being registered
//! as a global handler for `wl_shell`. This protocol is deprecated in favor of `xdg_shell`,
//! thus this module is provided as a compatibility layer wit... |
}
/// Create a new `wl_shell` global
pub fn wl_shell_init<L, Impl>(
display: &mut Display,
implementation: Impl,
logger: L,
) -> (Arc<Mutex<ShellState>>, Global<wl_shell::WlShell>)
where
L: Into<Option<::slog::Logger>>,
Impl: FnMut(ShellRequest, DispatchData<'_>) +'static,
{
let _log = crate::... | {
&self.known_surfaces[..]
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.