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 |
|---|---|---|---|---|
loop-break-value-no-repeat.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
for _ in &[1,2,3] {
break 22 //~ ERROR `break` with value from a `for` loop
}
} | identifier_body | |
loop-break-value-no-repeat.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | // except according to those terms.
#![allow(unused_variables)]
use std::ptr;
// Test that we only report **one** error here and that is that
// `break` with an expression is illegal in this context. In
// particular, we don't report any mismatched types error, which is
// besides the point.
fn main() {
for _ i... | random_line_split | |
loop-break-value-no-repeat.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
for _ in &[1,2,3] {
break 22 //~ ERROR `break` with value from a `for` loop
}
}
| main | identifier_name |
issue-26802.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 ... | (foobar: FooBar) -> Box<Foo<'static>> {
Box::new(foobar)
}
fn main() {
assert_eq!(test(FooBar).bar(&4), 11);
}
| test | identifier_name |
issue-26802.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 ... | }
fn main() {
assert_eq!(test(FooBar).bar(&4), 11);
} | random_line_split | |
svnrev.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 crate::BonsaiChangeset;
use abomonation_derive::Abomonation;
use anyhow::{bail, Error, Result};
use sql::mysql;
use std::fmt::{self, Di... |
None => bail!("Bonsai cs {:?} without svnrev", bcs),
}
}
}
impl Display for Svnrev {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(&self.0, fmt)
}
}
impl FromStr for Svnrev {
type Err = <u64 as FromStr>::Err;
fn from_str(s: &str) -> Result<Self... | {
let svnrev = Svnrev::parse_svnrev(str::from_utf8(&svnrev.to_vec())?)?;
Ok(Self::new(svnrev))
} | conditional_block |
svnrev.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 crate::BonsaiChangeset;
use abomonation_derive::Abomonation;
use anyhow::{bail, Error, Result};
use sql::mysql;
use std::fmt::{self, Di... |
impl Svnrev {
#[inline]
pub const fn new(rev: u64) -> Self {
Self(rev)
}
#[inline]
pub fn id(&self) -> u64 {
self.0
}
// ex. svn:uuid/path@1234
pub fn parse_svnrev(svnrev: &str) -> Result<u64> {
let at_pos = svnrev
.rfind('@')
.ok_or_else(... |
// Changeset svnrev. Present only in some repos which were imported from SVN.
#[derive(Abomonation, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(mysql::OptTryFromRowField)]
pub struct Svnrev(u64); | random_line_split |
svnrev.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 crate::BonsaiChangeset;
use abomonation_derive::Abomonation;
use anyhow::{bail, Error, Result};
use sql::mysql;
use std::fmt::{self, Di... | (bcs: &BonsaiChangeset) -> Result<Self> {
match bcs.extra().find(|(key, _)| key == &"convert_revision") {
Some((_, svnrev)) => {
let svnrev = Svnrev::parse_svnrev(str::from_utf8(&svnrev.to_vec())?)?;
Ok(Self::new(svnrev))
}
None => bail!("Bonsa... | from_bcs | identifier_name |
contact_signal.rs | /// A signal handler for contact detection.
pub trait ContactSignalHandler<B> {
/// Activate an action for when two objects start or stop to be close to each other.
fn handle_contact(&mut self, b1: &B, b2: &B, started: bool);
}
/// Signal for contact start/stop.
pub struct ContactSignal<B> {
contact_signal... |
}
| {
for &mut (_, ref mut f) in self.contact_signal_handlers.iter_mut() {
f.handle_contact(b1, b2, started)
}
} | identifier_body |
contact_signal.rs | /// A signal handler for contact detection.
pub trait ContactSignalHandler<B> {
/// Activate an action for when two objects start or stop to be close to each other.
fn handle_contact(&mut self, b1: &B, b2: &B, started: bool);
}
/// Signal for contact start/stop.
pub struct ContactSignal<B> {
contact_signal... |
}
// FIXME: do we really want to use &mut here?
/// Activates the contact signal, executing all the event handlers.
pub fn trigger_contact_signal(&mut self, b1: &B, b2: &B, started: bool) {
for &mut (_, ref mut f) in self.contact_signal_handlers.iter_mut() {
f.handle_contact(b1, b2... | {
let _ = self.contact_signal_handlers.remove(to_remove);
} | conditional_block |
contact_signal.rs | /// A signal handler for contact detection.
pub trait ContactSignalHandler<B> {
/// Activate an action for when two objects start or stop to be close to each other.
fn handle_contact(&mut self, b1: &B, b2: &B, started: bool);
}
/// Signal for contact start/stop.
pub struct ContactSignal<B> {
contact_signal... | if name == &n[..] {
to_remove = i;
}
}
if to_remove!= self.contact_signal_handlers.len() {
let _ = self.contact_signal_handlers.remove(to_remove);
}
}
// FIXME: do we really want to use &mut here?
/// Activates the contact signal,... | pub fn unregister_contact_signal_handler(&mut self, name: &str) {
let mut to_remove = self.contact_signal_handlers.len();
for (i, &mut (ref n, _)) in self.contact_signal_handlers.iter_mut().enumerate() { | random_line_split |
contact_signal.rs | /// A signal handler for contact detection.
pub trait ContactSignalHandler<B> {
/// Activate an action for when two objects start or stop to be close to each other.
fn handle_contact(&mut self, b1: &B, b2: &B, started: bool);
}
/// Signal for contact start/stop.
pub struct ContactSignal<B> {
contact_signal... | () -> ContactSignal<B> {
ContactSignal {
contact_signal_handlers: Vec::new(),
}
}
/// Registers an event handler.
pub fn register_contact_signal_handler(&mut self,
name: &str,
callback:... | new | identifier_name |
olr_ext.rs | /// Overlap Region extension functions.
use cand_rgn::CandRgn;
use chr::{ Chr, MasterChrList, };
use generics::*;
use met_st::OlrMetSt;
use met_st::OlrMetSt::*;
use ol_rgn::{ OlRgn, MasterOlRgnList, };
use spl_indv::SplIndv;
use std::vec::Vec;
use std::ops::Deref;
use std::process; // For debugging.
// Discover and c... | (
m_chr_list: &MasterChrList,
m_olr_list: &mut MasterOlRgnList,
num_indv: u32,
) {
println!("Start olr compilation.");
comp_all_olr(m_chr_list, m_olr_list, num_indv);
println!("Olr compilation complete.");
println!("Start olr extension.");
extend_olr_rec(m_olr_list);
filter_olr_size... | comp_all_olr_ext | identifier_name |
olr_ext.rs | /// Overlap Region extension functions.
use cand_rgn::CandRgn;
use chr::{ Chr, MasterChrList, };
use generics::*;
use met_st::OlrMetSt;
use met_st::OlrMetSt::*;
use ol_rgn::{ OlRgn, MasterOlRgnList, };
use spl_indv::SplIndv;
use std::vec::Vec;
use std::ops::Deref;
use std::process; // For debugging.
// Discover and c... | {
println!("Start olr compilation.");
comp_all_olr(m_chr_list, m_olr_list, num_indv);
println!("Olr compilation complete.");
println!("Start olr extension.");
extend_olr_rec(m_olr_list);
filter_olr_size(m_olr_list);
filter_olr(m_olr_list);
println!("Olr extension complete.");
} | identifier_body | |
olr_ext.rs | /// Overlap Region extension functions.
use cand_rgn::CandRgn;
use chr::{ Chr, MasterChrList, };
use generics::*;
use met_st::OlrMetSt;
use met_st::OlrMetSt::*;
use ol_rgn::{ OlRgn, MasterOlRgnList, };
use spl_indv::SplIndv;
use std::vec::Vec;
use std::ops::Deref;
use std::process; // For debugging.
// Discover and c... | num_indv: u32,
) {
println!("Start olr compilation.");
comp_all_olr(m_chr_list, m_olr_list, num_indv);
println!("Olr compilation complete.");
println!("Start olr extension.");
extend_olr_rec(m_olr_list);
filter_olr_size(m_olr_list);
filter_olr(m_olr_list);
println!("Olr extension co... | // Main function to be used in main.rs.
pub fn comp_all_olr_ext(
m_chr_list: &MasterChrList,
m_olr_list: &mut MasterOlRgnList, | random_line_split |
olr_ext.rs | /// Overlap Region extension functions.
use cand_rgn::CandRgn;
use chr::{ Chr, MasterChrList, };
use generics::*;
use met_st::OlrMetSt;
use met_st::OlrMetSt::*;
use ol_rgn::{ OlRgn, MasterOlRgnList, };
use spl_indv::SplIndv;
use std::vec::Vec;
use std::ops::Deref;
use std::process; // For debugging.
// Discover and c... |
}
}
// Main function to be used in main.rs.
pub fn comp_all_olr_ext(
m_chr_list: &MasterChrList,
m_olr_list: &mut MasterOlRgnList,
num_indv: u32,
) {
println!("Start olr compilation.");
comp_all_olr(m_chr_list, m_olr_list, num_indv);
println!("Olr compilation complete.");
println!("St... | {
m_olr_list.rm_olr(olr);
} | conditional_block |
expr-block-generic.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... | test_generic::<Pair>(Pair {a: 1, b: 2}, compare_rec);
}
pub fn main() { test_bool(); test_rec(); } | fn compare_rec(t1: Pair, t2: Pair) -> bool {
t1.a == t2.a && t1.b == t2.b
} | random_line_split |
expr-block-generic.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... |
#[deriving(Clone)]
struct Pair {
a: int,
b: int,
}
fn test_rec() {
fn compare_rec(t1: Pair, t2: Pair) -> bool {
t1.a == t2.a && t1.b == t2.b
}
test_generic::<Pair>(Pair {a: 1, b: 2}, compare_rec);
}
pub fn main() { test_bool(); test_rec(); }
| {
fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
test_generic::<bool>(true, compare_bool);
} | identifier_body |
expr-block-generic.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
test_generic::<bool>(true, compare_bool);
}
#[deriving(Clone)]
struct Pair {
a: int,
b: int,
}
fn test_rec() {
fn compare_rec(t1: Pair, t2: Pair) -> bool {
t1.a == t2.a && t1.b == t2.b
}
test_generic::<Pair>(Pair... | test_bool | identifier_name |
structs.rs | use std::os::raw::{c_int, c_double, c_void, c_char};
use ffi::enums::*;
/// Represents a `ffi::enums::SioChannelLayoutId`. Contains
/// the number of channels in the layout, the channel id for each
/// channel and the name of the layout.
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SoundIoChannelLayout {
pub name... | /// Base address of buffer.
pub ptr: *mut c_char,
/// How many bytes it takes to get from the beginning of one sample to
/// the beginning of the next sample.
pub step: c_int,
}
/// Base struct.
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SoundIo {
/// Optional. Put whatever you want here. Def... | #[repr(C)]
#[derive(Copy, Clone)]
pub struct SoundIoChannelArea { | random_line_split |
structs.rs | use std::os::raw::{c_int, c_double, c_void, c_char};
use ffi::enums::*;
/// Represents a `ffi::enums::SioChannelLayoutId`. Contains
/// the number of channels in the layout, the channel id for each
/// channel and the name of the layout.
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SoundIoChannelLayout {
pub name... | {
/// Optional. Put whatever you want here. Defaults to NULL.
pub userdata: *mut c_void,
/// Optional callback. Called when the list of devices
/// change. Only called during a call to
/// If you do not supply a callback, the default will
/// crash your program with an error message. This callb... | SoundIo | identifier_name |
pie.rs | use std::f32::consts;
use graph::{Graph, Tools, Coord, Padding, HTML, Size};
use entry::Entry;
pub struct PieBuilder {
width: f32,
height: f32,
entries: Option<Vec<Entry>>,
}
impl PieBuilder {
pub fn new() -> PieBuilder |
pub fn width(mut self, width: f32) -> PieBuilder {
self.width = width;
self
}
pub fn height(mut self, height: f32) -> PieBuilder {
self.height = height;
self
}
pub fn entries(mut self, entries: Vec<Entry>) -> PieBuilder {
self.entries = Some(entries);
... | {
PieBuilder {
width: 500.0,
height: 500.0,
entries: None,
}
} | identifier_body |
pie.rs | use std::f32::consts;
use graph::{Graph, Tools, Coord, Padding, HTML, Size};
use entry::Entry;
pub struct PieBuilder {
width: f32,
height: f32,
entries: Option<Vec<Entry>>,
}
impl PieBuilder {
pub fn new() -> PieBuilder {
PieBuilder {
width: 500.0,
height: 500.0,
... | (i: usize) -> String {
let colors = vec![
//"rgba(0,0,0,0.5)",
//"rgba(0,94,255,0.5)",
//"rgba(255,165,0,0.5)",
//"rgba(10,199,0,0.5)",
//"rgba(220,232,0,0.5)",
//"rgba(232,0,162,0.5)"
//
"rgb(237,10,63)",
... | color | identifier_name |
pie.rs | use std::f32::consts;
use graph::{Graph, Tools, Coord, Padding, HTML, Size};
use entry::Entry;
pub struct PieBuilder {
width: f32,
height: f32,
entries: Option<Vec<Entry>>,
}
impl PieBuilder {
pub fn new() -> PieBuilder {
PieBuilder {
width: 500.0,
height: 500.0,
... | .collect()
}
fn labels(&self) -> Vec<Label> {
self.entries
.iter()
.enumerate()
.map(|(i, e)| {
Label {
fill: Pie::color(i),
text: e.label.clone(),
x: 0.0,
y: (i a... | text: text,
text_x: text_x,
text_y: text_y,
}
}) | random_line_split |
mod.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... | <'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a> {
cx: &'cx Context<'cx_a>,
values: &'a [S],
}
impl<'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a> ComputedVecIter<'a, 'cx, 'cx_a, S> {
/// Construct an iterator from a slice of specified values and a context
pub fn new(cx: &'cx Context<'cx_a>, values: &'a [... | ComputedVecIter | identifier_name |
mod.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... | else {
size
}
}
/// (Servo doesn't do text-zoom)
#[cfg(feature = "servo")]
pub fn maybe_zoom_text(&self, size: NonNegativeLength) -> NonNegativeLength {
size
}
}
/// An iterator over a slice of computed values
#[derive(Clone)]
pub struct ComputedVecIter<'a, 'cx, 'cx_a:... | {
self.device().zoom_text(Au::from(size)).into()
} | conditional_block |
mod.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... |
/// The default computed style we're getting our reset style from.
pub fn default_style(&self) -> &ComputedValues {
self.builder.default_style()
}
/// The current style.
pub fn style(&self) -> &StyleBuilder {
&self.builder
}
/// Apply text-zoom if enabled.
#[cfg(featu... | {
self.builder.device.au_viewport_size_for_viewport_unit_resolution()
} | identifier_body |
mod.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... |
/// Whether this computation is being done for a SMIL animation.
///
/// This is used to allow certain properties to generate out-of-range
/// values, which SMIL allows.
pub for_smil_animation: bool,
/// The property we are computing a value for, if it is a non-inherited
/// property. Non... |
/// The quirks mode of this context.
pub quirks_mode: QuirksMode, | random_line_split |
mod.rs | // Copyright 2015 Brendan Zabarauskas and the gl-rs developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required b... |
/// Generates all the type aliases for a namespace.
///
/// Aliases are either `pub type =...` or `#[repr(C)] pub struct... {... }` and contain all the
/// things that we can't obtain from the XML files.
pub fn gen_types<W>(api: Api, dest: &mut W) -> io::Result<()> where W: io::Write {
try!(writeln!(dest, "{}", i... | {
writeln!(dest,
"#[allow(dead_code, non_upper_case_globals)] pub const {ident}: {types_prefix}{ty} = {value}{cast_suffix};",
ident = enm.ident,
types_prefix = if enm.ty == "&'static str" { "" } else { types_prefix },
ty = enm.ty,
value = enm.value,
cast_suffix = matc... | identifier_body |
mod.rs | // Copyright 2015 Brendan Zabarauskas and the gl-rs developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required b... | (api: Api) -> &'static str {
match api {
Api::Gl => "Gl",
Api::Glx => "Glx",
Api::Wgl => "Wgl",
Api::Egl => "Egl",
Api::GlCore => "GlCore",
Api::Gles1 => "Gles1",
Api::Gles2 => "Gles2",
}
}
/// This function generates a `const name: type = value;` item.
... | gen_struct_name | identifier_name |
mod.rs | // Copyright 2015 Brendan Zabarauskas and the gl-rs developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required b... | pub fn gen_enum_item<W>(enm: &Enum, types_prefix: &str, dest: &mut W) -> io::Result<()> where W: io::Write {
writeln!(dest,
"#[allow(dead_code, non_upper_case_globals)] pub const {ident}: {types_prefix}{ty} = {value}{cast_suffix};",
ident = enm.ident,
types_prefix = if enm.ty == "&'static st... | }
/// This function generates a `const name: type = value;` item. | random_line_split |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | () -> Result<()> {
let out_dir = std::env::var("OUT_DIR").unwrap();
let tvm_mk_add = concat!(env!("CARGO_MANIFEST_DIR"), "/src/tvm_add.py");
let output = std::process::Command::new(tvm_mk_add)
.args(&[
if cfg!(feature = "cpu") {
"llvm"
} else {
... | main | identifier_name |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | fn main() -> Result<()> {
let out_dir = std::env::var("OUT_DIR").unwrap();
let tvm_mk_add = concat!(env!("CARGO_MANIFEST_DIR"), "/src/tvm_add.py");
let output = std::process::Command::new(tvm_mk_add)
.args(&[
if cfg!(feature = "cpu") {
"llvm"
} else {
... | use anyhow::{Context, Result};
| random_line_split |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | .context("utf-8 conversion failed")?
.trim()
.split("\n")
.last()
.unwrap_or("")
);
println!("cargo:rustc-link-search=native={}", out_dir);
Ok(())
}
| {
let out_dir = std::env::var("OUT_DIR").unwrap();
let tvm_mk_add = concat!(env!("CARGO_MANIFEST_DIR"), "/src/tvm_add.py");
let output = std::process::Command::new(tvm_mk_add)
.args(&[
if cfg!(feature = "cpu") {
"llvm"
} else {
"cuda"
... | identifier_body |
build.rs | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | ,
&std::env::var("OUT_DIR").unwrap(),
])
.output()
.with_context(|| anyhow::anyhow!(tvm_mk_add))?;
assert!(
std::path::Path::new(&format!("{}/test_add.so", out_dir)).exists(),
"Could not build tvm lib: {}",
String::from_utf8(output.stderr)
.conte... | {
"cuda"
} | conditional_block |
main.rs | extern crate tinyrsh;
use std::collections::HashMap;
use std::net::{TcpListener, TcpStream};
use std::io::{Write};
use std::io;
use std::process;
use std::os::unix::io::{RawFd};
use tinyrsh::child::PersistentChild;
use tinyrsh::fdstore::{FdStore, OnceAccept, OnceRead};
fn greet_client(fdstore: &FdStore, mut stream: ... |
fn main() {
println!("Hello, world!");
let child = PersistentChild::new("../../py-ptysh/ptysh.py");
// TODO linebuffered? how is child output buffered at all?
let listener = TcpListener::bind("127.0.0.1:6699").unwrap();
let mut fdstore = FdStore::new(listener, child);
println!("sel... | {
assert_eq!(stream.write(b"hello\n").expect("greet client failed"), 6);
stream.write_all(b"Your fellow peers:").expect("client write");
let mut v = vec![];
for other in fdstore.clients.keys() {
v.push(format!("fd {}", other));
}
stream.write_all(v.join(", ").as_bytes()).expect("client write");... | identifier_body |
main.rs | extern crate tinyrsh;
use std::collections::HashMap;
use std::net::{TcpListener, TcpStream};
use std::io::{Write};
use std::io;
use std::process;
use std::os::unix::io::{RawFd};
use tinyrsh::child::PersistentChild;
use tinyrsh::fdstore::{FdStore, OnceAccept, OnceRead};
fn | (fdstore: &FdStore, mut stream: &TcpStream) {
assert_eq!(stream.write(b"hello\n").expect("greet client failed"), 6);
stream.write_all(b"Your fellow peers:").expect("client write");
let mut v = vec![];
for other in fdstore.clients.keys() {
v.push(format!("fd {}", other));
}
stream.write_all(v.jo... | greet_client | identifier_name |
main.rs | extern crate tinyrsh;
use std::collections::HashMap;
use std::net::{TcpListener, TcpStream};
use std::io::{Write};
use std::io;
use std::process;
use std::os::unix::io::{RawFd};
use tinyrsh::child::PersistentChild;
use tinyrsh::fdstore::{FdStore, OnceAccept, OnceRead};
fn greet_client(fdstore: &FdStore, mut stream: ... |
assert!(!child_eof, "child exited, unhandled!");
};
let childstderrfun = | stderr: OnceRead<process::ChildStderr>, clients: &HashMap<RawFd, TcpStream> | -> () {
println!("child (stderr) got active");
let mut buf = [0; 10];
let n = stderr.do_read(&mut bu... | {
println!("!!!!!!! child exited. pipe will break now");
//println!("exit code: {}", child.wait().expect("child unexpected state"));
//ahh, ownership!
} | conditional_block |
main.rs | extern crate tinyrsh;
use std::collections::HashMap;
use std::net::{TcpListener, TcpStream};
use std::io::{Write};
use std::io;
use std::process;
use std::os::unix::io::{RawFd};
use tinyrsh::child::PersistentChild;
use tinyrsh::fdstore::{FdStore, OnceAccept, OnceRead};
fn greet_client(fdstore: &FdStore, mut stream: ... | } | //do all the stuff
fdstore.select(&srvacceptfun, &clientfun, &childstdoutfun, &childstderrfun);
} //loop | random_line_split |
no_0021_merge_two_sorted_lists.rs | // Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
struct Solution;
impl Solution {
// from https://leet... | val: 2,
next: Some(Box::new(ListNode { val: 4, next: None })),
})),
}));
let l2 = Some(Box::new(ListNode {
val: 1,
next: Some(Box::new(ListNode {
val: 3,
next: Some(Box::new(ListNode { val: 4, next: None })),
... | Node {
| identifier_name |
no_0021_merge_two_sorted_lists.rs | // Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
struct Solution;
impl Solution {
// from https://leet... | ptr.next = if l1.is_some() { l1 } else { l2 };
res.next
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_merge_two_lists1() {
let l1 = Some(Box::new(ListNode {
val: 1,
next: Some(Box::new(ListNode {
val: 2,
next... | l2 = ptr.next.take();
}
}
// 剩余的 | random_line_split |
no_0021_merge_two_sorted_lists.rs | // Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
struct Solution;
impl Solution {
// from https://leet... | let l1 = Some(Box::new(ListNode {
val: 1,
next: Some(Box::new(ListNode {
val: 2,
next: Some(Box::new(ListNode { val: 4, next: None })),
})),
}));
let l2 = Some(Box::new(ListNode {
val: 1,
next: Some(Box::new(Li... | conditional_block | |
lwlock.rs | #![macro_escape]
use self::LWLockMode::*;
use s_lock::{
SpinLock
};
use process;
use std::thread_local::Key;
use std::fmt;
pub struct | {
/// T if ok to release waiters
release_ok: bool,
/// has an exclusive holder?
exclusive: bool,
/// # of shared holders (0..MaxBackends)
shared: u32,
//tranche: u32, /// tranche ID
/// head of list of waiting Procs
head: Option<&'static Key<process::Proc>>,
/// tail of list of ... | LWLockHeader | identifier_name |
lwlock.rs | #![macro_escape]
use self::LWLockMode::*;
use s_lock::{
SpinLock
};
use process;
use std::thread_local::Key;
use std::fmt;
pub struct LWLockHeader {
/// T if ok to release waiters
release_ok: bool,
/// has an exclusive holder?
exclusive: bool,
/// # of shared holders (0..MaxBackends)
sha... | // We are done updating shared state of the lock itself.
drop(guard);
// Add lock to list of locks held by this backend
// held_lwlocks[num_held_lwlocks++] = lock;
// Fix the process wait semaphore's count for any absorbed wakeups.
while extra_wa... | // TODO: add this
| random_line_split |
lwlock.rs | #![macro_escape]
use self::LWLockMode::*;
use s_lock::{
SpinLock
};
use process;
use std::thread_local::Key;
use std::fmt;
pub struct LWLockHeader {
/// T if ok to release waiters
release_ok: bool,
/// has an exclusive holder?
exclusive: bool,
/// # of shared holders (0..MaxBackends)
sha... |
pub fn acquire(&self, mode: LWLockMode) -> bool {
self.acquire_common(mode)
}
fn acquire_common(&self, mode: LWLockMode) -> bool {
process::MY_PROC.with( |thread| {
let mut retry = false;
let mut result = true;
let mut extra_waits = 0u32;
/... | {
lwlock_init!(data)
} | identifier_body |
point.rs | use color::Color;
use intersection::Intersection;
use material::Material;
use math::{Point3, EPSILON};
use ray::Ray;
| intensity: f32,
falloff: Falloff,
diffuse: bool,
specular: bool,
}
impl Point {
pub fn new(
origin: Point3,
color: Color,
intensity: f32,
falloff: Falloff,
diffuse: bool,
specular: bool,
) -> Self {
Self {
origin,
c... | use super::{Falloff, Light};
pub struct Point {
pub origin: Point3,
pub color: Color, | random_line_split |
point.rs | use color::Color;
use intersection::Intersection;
use material::Material;
use math::{Point3, EPSILON};
use ray::Ray;
use super::{Falloff, Light};
pub struct Point {
pub origin: Point3,
pub color: Color,
intensity: f32,
falloff: Falloff,
diffuse: bool,
specular: bool,
}
impl Point {
pub fn... | (&self, intersection: &Intersection) -> f32 {
(intersection.point - self.origin).length()
}
fn diffuse_color(
&self,
intersection: &Intersection,
material: &Material,
distance_to_light: f32,
) -> Option<Color> {
if!self.diffuse {
return None;
... | distance_to_light | identifier_name |
point.rs | use color::Color;
use intersection::Intersection;
use material::Material;
use math::{Point3, EPSILON};
use ray::Ray;
use super::{Falloff, Light};
pub struct Point {
pub origin: Point3,
pub color: Color,
intensity: f32,
falloff: Falloff,
diffuse: bool,
specular: bool,
}
impl Point {
pub fn... |
}
impl Light for Point {
fn create_shadow_ray(
&self,
intersection: &Intersection,
medium_refraction: Option<f32>,
) -> Ray {
let light_direction = (self.origin - intersection.point).normalize();
Ray::new(
(intersection.point + light_direction * 1e-3).as_poi... | {
match self.falloff {
Falloff::InverseSquare => {
1.0 / (distance_to_light * distance_to_light) * self.intensity
}
Falloff::InverseLinear => 1.0 / distance_to_light * self.intensity,
}
} | identifier_body |
util.rs | //! Helper functions corresponding to lifetime errors due to
//! anonymous regions.
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, DefIdTree, Region, Ty};
use rustc_span::Span;
/// Information about the anony... |
None
}
// Here we check for the case where anonymous region
// corresponds to self and if yes, we display E0312.
// FIXME(#42700) - Need to format self properly to
// enable E0621 for it.
pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: LocalDefId) -> bool {
is_f... | {
let sig = ret_ty.fn_sig(self.tcx());
let late_bound_regions =
self.tcx().collect_referenced_late_bound_regions(&sig.output());
if late_bound_regions.iter().any(|r| *r == br) {
return Some(decl.output.span());
}
} | conditional_block |
util.rs | //! Helper functions corresponding to lifetime errors due to
//! anonymous regions.
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, DefIdTree, Region, Ty};
use rustc_span::Span;
/// Information about the anony... | Some(hir::Node::Item(hir::Item {
kind:
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
bounds,
origin: hir::OpaqueTyOrigin::AsyncFn,
..
... | {
match self.tcx().hir().get_if_local(*def_id) { | random_line_split |
util.rs | //! Helper functions corresponding to lifetime errors due to
//! anonymous regions.
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, DefIdTree, Region, Ty};
use rustc_span::Span;
/// Information about the anony... | .take(if fn_sig.c_variadic {
fn_sig.inputs().len()
} else {
assert_eq!(fn_sig.inputs().len(), body.params.len());
body.params.len()
})
.enumerate()
.find_map(|(index, param)| {
// May return None; so... | {
let (id, bound_region) = match *anon_region {
ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region),
ty::ReEarlyBound(ebr) => (
self.tcx().parent(ebr.def_id).unwrap(),
ty::BoundRegionKind::BrNamed(ebr.def_id, ebr.name),
... | identifier_body |
util.rs | //! Helper functions corresponding to lifetime errors due to
//! anonymous regions.
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, DefIdTree, Region, Ty};
use rustc_span::Span;
/// Information about the anony... | <'tcx> {
/// The parameter corresponding to the anonymous region.
pub param: &'tcx hir::Param<'tcx>,
/// The type corresponding to the anonymous region parameter.
pub param_ty: Ty<'tcx>,
/// The ty::BoundRegionKind corresponding to the anonymous region.
pub bound_region: ty::BoundRegionKind,
... | AnonymousParamInfo | identifier_name |
generics_functions.rs | struct A; // Concrete type `A`.
struct S(A); // Concrete type `S`.
struct SGen<T>(T); // Generic type `SGen`.
// The following functions all take ownership of the variable passed into
// them and immediately go out of scope, freeing the variable.
// Define a function `reg_fn` that takes an argument `_s... | // Define a function `gen_spec_t` that takes an argument `_s` of type `SGen<T>`.
// It has been explicitly given the type parameter `A`, but because `A` has not
// been specified as a generic type parameter for `gen_spec_t`, it is not generic.
fn gen_spec_t(_s: SGen<A>) {}
// Define a function `gen_spec_i32` that take... | // This has no `<T>` so this is not a generic function.
fn reg_fn(_s: S) {}
| random_line_split |
generics_functions.rs | struct A; // Concrete type `A`.
struct S(A); // Concrete type `S`.
struct | <T>(T); // Generic type `SGen`.
// The following functions all take ownership of the variable passed into
// them and immediately go out of scope, freeing the variable.
// Define a function `reg_fn` that takes an argument `_s` of type `S`.
// This has no `<T>` so this is not a generic function.
fn reg_fn(_s: S) {}
/... | SGen | identifier_name |
generics_functions.rs | struct A; // Concrete type `A`.
struct S(A); // Concrete type `S`.
struct SGen<T>(T); // Generic type `SGen`.
// The following functions all take ownership of the variable passed into
// them and immediately go out of scope, freeing the variable.
// Define a function `reg_fn` that takes an argument `_s... |
// Define a function `gen_spec_t` that takes an argument `_s` of type `SGen<T>`.
// It has been explicitly given the type parameter `A`, but because `A` has not
// been specified as a generic type parameter for `gen_spec_t`, it is not generic.
fn gen_spec_t(_s: SGen<A>) {}
// Define a function `gen_spec_i32` that ta... | {} | identifier_body |
unit_quat_test.rs | use PI;
use maths::{Quat, UnitQuat, Vec3D};
#[test]
fn it_can_be_instantiated_using_the_axis_angle_formulation() {
let radians = 2.5;
let hr = radians / 2.0;
let q = UnitQuat::from_axis_angle(Vec3D::new(2.0, 3.0, 6.0).normalize(), radians);
let chr = hr.cos();
let shr = hr.sin(); | }
#[test]
fn it_can_rotate_a_vector() {
let v = Vec3D::new(1.0, 0.0, 0.0);
let q = UnitQuat::from_axis_angle(Vec3D::new(1.0, 0.5, 0.5).normalize(), PI/3.0);
let res = q.rotate(v);
assert_approx_eq!(res, Vec3D::new(0.8333333333333335, 0.5202200572599405, -0.18688672392660716));
} | assert_approx_eq!(Quat::from(q), Quat::new(chr, 2.0*shr/7.0, 3.0*shr/7.0, 6.0*shr/7.0)); | random_line_split |
unit_quat_test.rs | use PI;
use maths::{Quat, UnitQuat, Vec3D};
#[test]
fn | () {
let radians = 2.5;
let hr = radians / 2.0;
let q = UnitQuat::from_axis_angle(Vec3D::new(2.0, 3.0, 6.0).normalize(), radians);
let chr = hr.cos();
let shr = hr.sin();
assert_approx_eq!(Quat::from(q), Quat::new(chr, 2.0*shr/7.0, 3.0*shr/7.0, 6.0*shr/7.0));
}
#[test]
fn it_can_rotate_a_vect... | it_can_be_instantiated_using_the_axis_angle_formulation | identifier_name |
unit_quat_test.rs | use PI;
use maths::{Quat, UnitQuat, Vec3D};
#[test]
fn it_can_be_instantiated_using_the_axis_angle_formulation() |
#[test]
fn it_can_rotate_a_vector() {
let v = Vec3D::new(1.0, 0.0, 0.0);
let q = UnitQuat::from_axis_angle(Vec3D::new(1.0, 0.5, 0.5).normalize(), PI/3.0);
let res = q.rotate(v);
assert_approx_eq!(res, Vec3D::new(0.8333333333333335, 0.5202200572599405, -0.18688672392660716));
}
| {
let radians = 2.5;
let hr = radians / 2.0;
let q = UnitQuat::from_axis_angle(Vec3D::new(2.0, 3.0, 6.0).normalize(), radians);
let chr = hr.cos();
let shr = hr.sin();
assert_approx_eq!(Quat::from(q), Quat::new(chr, 2.0*shr/7.0, 3.0*shr/7.0, 6.0*shr/7.0));
} | identifier_body |
mod.rs | use std::fmt;
use std::error;
use std::marker;
#[derive(Debug)]
pub enum BencodeError
{
ParseError(&'static str)
}
impl fmt::Display for BencodeError
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BencodeError::ParseError(err) => write!(f, "oxidation_bencode parse e... | (&self) -> &str {
match *self {
BencodeError::ParseError(err) => &err
}
}
fn cause(&self) -> Option<&error::Error> {
match *self {
BencodeError::ParseError(_) => None
}
}
}
pub trait Bencodable<T> {
fn to_bencode_string(&self) -> String;
fn ... | description | identifier_name |
mod.rs | use std::fmt;
use std::error;
use std::marker;
#[derive(Debug)]
pub enum BencodeError
{
ParseError(&'static str)
}
impl fmt::Display for BencodeError
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BencodeError::ParseError(err) => write!(f, "oxidation_bencode parse e... |
}
pub trait Bencodable<T> {
fn to_bencode_string(&self) -> String;
fn from_bencode_string(str: &'static str) -> Result<Self,BencodeError>
where Self: marker::Sized;
fn extract_content(&self) -> T;
} | {
match *self {
BencodeError::ParseError(_) => None
}
} | identifier_body |
mod.rs | use std::fmt;
use std::error;
use std::marker;
#[derive(Debug)]
pub enum BencodeError
{
ParseError(&'static str)
}
impl fmt::Display for BencodeError
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BencodeError::ParseError(err) => write!(f, "oxidation_bencode parse e... | pub trait Bencodable<T> {
fn to_bencode_string(&self) -> String;
fn from_bencode_string(str: &'static str) -> Result<Self,BencodeError>
where Self: marker::Sized;
fn extract_content(&self) -> T;
} | random_line_split | |
biosnoop.rs | beam_utils::CachePadded;
/// Biosnoop leverages BCC to make use of eBPF to get disk IO of TiKV requests.
/// The BCC code is in `biosnoop.c` which is compiled and attached kernel on
/// TiKV bootstrap. The code hooks on the start and completion of blk_account_io
/// in kernel, so it's easily to get the latency and byt... |
}
fn is_all_free(&self) -> bool {
self.count.load(Ordering::SeqCst) == 0
}
}
pub fn set_io_type(new_io_type: IOType) {
unsafe {
IDX.with(|idx| {
// if MAX_THREAD_IDX, keep IOType::Other always
if idx.0!= MAX_THREAD_IDX {
*IO_TYPE_ARRAY[idx.0] = ... | {
self.free_list.lock().unwrap().push_back(idx);
} | conditional_block |
biosnoop.rs | beam_utils::CachePadded;
/// Biosnoop leverages BCC to make use of eBPF to get disk IO of TiKV requests.
/// The BCC code is in `biosnoop.c` which is compiled and attached kernel on
/// TiKV bootstrap. The code hooks on the start and completion of blk_account_io
/// in kernel, so it's easily to get the latency and byt... |
fn is_all_free(&self) -> bool {
self.count.load(Ordering::SeqCst) == 0
}
}
pub fn set_io_type(new_io_type: IOType) {
unsafe {
IDX.with(|idx| {
// if MAX_THREAD_IDX, keep IOType::Other always
if idx.0!= MAX_THREAD_IDX {
*IO_TYPE_ARRAY[idx.0] = new_io... | {
self.count.fetch_sub(1, Ordering::SeqCst);
if idx != MAX_THREAD_IDX {
self.free_list.lock().unwrap().push_back(idx);
}
} | identifier_body |
biosnoop.rs | beam_utils::CachePadded;
/// Biosnoop leverages BCC to make use of eBPF to get disk IO of TiKV requests.
/// The BCC code is in `biosnoop.c` which is compiled and attached kernel on
/// TiKV bootstrap. The code hooks on the start and completion of blk_account_io
/// in kernel, so it's easily to get the latency and byt... | (&self) -> bool {
self.count.load(Ordering::SeqCst) == 0
}
}
pub fn set_io_type(new_io_type: IOType) {
unsafe {
IDX.with(|idx| {
// if MAX_THREAD_IDX, keep IOType::Other always
if idx.0!= MAX_THREAD_IDX {
*IO_TYPE_ARRAY[idx.0] = new_io_type;
}... | is_all_free | identifier_name |
biosnoop.rs | crossbeam_utils::CachePadded;
/// Biosnoop leverages BCC to make use of eBPF to get disk IO of TiKV requests.
/// The BCC code is in `biosnoop.c` which is compiled and attached kernel on
/// TiKV bootstrap. The code hooks on the start and completion of blk_account_io
/// in kernel, so it's easily to get the latency a... | assert_ne!(IO_BYTES_VEC.compaction.write.get(), 0);
assert_ne!(IO_BYTES_VEC.other.read.get(), 0);
}
fn test_thread_idx_allocation() {
// the thread indexes should be recycled.
for _ in 1..=MAX_THREAD_IDX * 2 {
std::thread::spawn(|| {
set_io_type(IOTyp... | assert_ne!(IO_LATENCY_MICROS_VEC.compaction.write.get_sample_count(), 0);
assert_ne!(IO_LATENCY_MICROS_VEC.other.read.get_sample_count(), 0); | random_line_split |
member.rs | // Evelyn: Your personal assistant, project manager and calendar
// Copyright (C) 2017 Gregory Jensen
//
// 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
//... | pub struct AddMemberResponseModel {
pub error: Option<ErrorModel>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct AddMemberModel {
pub user_group_id: String,
pub user_group_member_model: UserGroupMemberModel,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rena... | }
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "PascalCase")] | random_line_split |
member.rs | // Evelyn: Your personal assistant, project manager and calendar
// Copyright (C) 2017 Gregory Jensen
//
// 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
//... | {
pub token: String,
pub user_group_id: String,
pub member: UserGroupAddMemberExternalModel,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct AddMemberResponseModel {
pub error: Option<ErrorModel>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all ... | AddMemberRequestModel | identifier_name |
arm_unknown_linux_gnueabi.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () -> Target {
let base = super::linux_base::opts();
Target {
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "linux".to_string(),
target_env: "g... | target | identifier_name |
arm_unknown_linux_gnueabi.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 base = super::linux_base::opts();
Target {
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "linux".to_string(),
target_env: "gnueabi".to_stri... | random_line_split | |
arm_unknown_linux_gnueabi.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 base = super::linux_base::opts();
Target {
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
arch: "arm".to_string(),
target_os: "linux".to_string(),
target_env: "gnueabi".to_st... | identifier_body | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | pub private: bool,
pub arguments: Vec<String>,
}
#[derive(Debug, Deserialize, Serialize)]
pub enum CachedConsoleMessage {
PageError(PageError),
ConsoleAPI(ConsoleAPI),
}
#[derive(Debug, PartialEq)]
pub struct HttpRequest {
pub url: ServoUrl,
pub method: Method,
pub headers: Headers,
pu... | pub level: String,
pub filename: String,
pub lineNumber: u32,
pub functionName: String,
pub timeStamp: u64, | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | {
Log,
Debug,
Info,
Warn,
Error,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConsoleMessage {
pub message: String,
pub logLevel: LogLevel,
pub filename: String,
pub lineNumber: usize,
pub columnNumber: usize,
}
bitflags! {
#[derive(Deserialize, Serialize)]... | LogLevel | identifier_name |
snappy.rs | extern crate libc;
use self::libc::{c_int, size_t};
use std::io::Read;
use codecs::FromByte;
use error::{Result, Error};
#[link(name = "snappy")]
extern {
fn snappy_uncompress(compressed: *const u8,
compressed_length: size_t,
uncompressed: *mut u8,
... | else {
Err(Error::InvalidInputSnappy) // SNAPPY_INVALID_INPUT
}
}
}
#[test]
fn test_uncompress() {
// The vector should uncompress to "This is test"
let msg: Vec<u8> = vec!(12, 44, 84, 104, 105, 115, 32, 105, 115, 32, 116, 101, 115, 116);
let uncomp_msg = String::from_utf8(uncompre... | {
dst.set_len(dstlen as usize);
Ok(dst)
} | conditional_block |
snappy.rs | extern crate libc;
use self::libc::{c_int, size_t};
use std::io::Read;
use codecs::FromByte;
use error::{Result, Error};
#[link(name = "snappy")]
extern {
fn snappy_uncompress(compressed: *const u8,
compressed_length: size_t,
uncompressed: *mut u8,
... |
#[test]
#[should_panic]
fn test_uncompress_panic() {
let msg: Vec<u8> = vec!(12, 42, 84, 104, 105, 115, 32, 105, 115, 32, 116, 101, 115, 116);
let uncomp_msg = String::from_utf8(uncompress(msg).unwrap()).unwrap();
assert_eq!(&uncomp_msg[..], "This is test");
}
| {
// The vector should uncompress to "This is test"
let msg: Vec<u8> = vec!(12, 44, 84, 104, 105, 115, 32, 105, 115, 32, 116, 101, 115, 116);
let uncomp_msg = String::from_utf8(uncompress(msg).unwrap()).unwrap();
assert_eq!(&uncomp_msg[..], "This is test");
} | identifier_body |
snappy.rs | extern crate libc;
use self::libc::{c_int, size_t};
use std::io::Read;
use codecs::FromByte;
use error::{Result, Error};
#[link(name = "snappy")]
extern {
fn snappy_uncompress(compressed: *const u8,
compressed_length: size_t,
uncompressed: *mut u8,
... | pub version: i32,
pub compat: i32
}
#[derive(Default, Debug, Clone)]
pub struct SnappyMessage {
pub message: Vec<u8>
}
impl FromByte for SnappyHeader {
type R = SnappyHeader;
#[allow(unused_must_use)]
fn decode<T: Read>(&mut self, buffer: &mut T) -> Result<()> {
self.marker.decode(buf... | random_line_split | |
snappy.rs | extern crate libc;
use self::libc::{c_int, size_t};
use std::io::Read;
use codecs::FromByte;
use error::{Result, Error};
#[link(name = "snappy")]
extern {
fn snappy_uncompress(compressed: *const u8,
compressed_length: size_t,
uncompressed: *mut u8,
... | {
pub marker: i8,
// TODO - Its a c-string of 6 bytes not 6 independent chars
pub c1: i8,
pub c2: i8,
pub c3: i8,
pub c4: i8,
pub c5: i8,
pub c6: i8,
pub pad: i8,
pub version: i32,
pub compat: i32
}
#[derive(Default, Debug, Clone)]
pub struct SnappyMessage {
pub message... | SnappyHeader | identifier_name |
mod.rs | // (c) 2015-2017 Productize SPRL <joost@productize.be>
// extension:.kicad_mod
// format: new-style
use std::fmt;
use std::result;
// get from parent
use symbolic_expressions;
use symbolic_expressions::IntoSexp;
use formatter::KicadFormatter;
use KicadError;
// pub use footprint;
pub use footprint::data::*;
/// co... | LayerType::Adhes => write!(f, "Adhes"),
LayerType::Cuts => write!(f, "Cuts"),
LayerType::CrtYd => write!(f, "CrtYd"),
LayerType::Fab => write!(f, "Fab"),
LayerType::Margin => write!(f, "Margin"),
LayerType::Other(ref x) => write!(f, "{}", x),
... | {
match self.side {
LayerSide::Front => write!(f, "F."),
LayerSide::Back => write!(f, "B."),
LayerSide::Dwgs => write!(f, "Dwgs."),
LayerSide::Cmts => write!(f, "Cmts."),
LayerSide::Eco1 => write!(f, "Eco1."),
LayerSide::Eco2 => write!(f, "... | identifier_body |
mod.rs | // (c) 2015-2017 Productize SPRL <joost@productize.be>
// extension:.kicad_mod
// format: new-style
use std::fmt;
use std::result;
// get from parent
use symbolic_expressions;
use symbolic_expressions::IntoSexp;
use formatter::KicadFormatter;
use KicadError;
// pub use footprint;
pub use footprint::data::*;
/// co... | (s: &str) -> Result<Module, KicadError> {
let t = symbolic_expressions::parser::parse_str(s)?;
let s = symbolic_expressions::from_sexp(&t)?;
Ok(s)
}
mod data;
mod ser;
mod de;
| parse | identifier_name |
mod.rs | // (c) 2015-2017 Productize SPRL <joost@productize.be>
// extension:.kicad_mod
// format: new-style
use std::fmt;
use std::result;
// get from parent
use symbolic_expressions;
use symbolic_expressions::IntoSexp;
use formatter::KicadFormatter;
use KicadError;
// pub use footprint;
pub use footprint::data::*;
/// co... | symbolic_expressions::ser::to_string_with_formatter(&module.into_sexp(), formatter)
.map_err(From::from)
}
impl fmt::Display for Layer {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
match self.side {
LayerSide::Front => write!(f, "F."),
LayerS... | random_line_split | |
mod.rs | use std::collections::{HashMap, VecDeque};
pub struct Graph {
orbits: HashMap<String, String>,
}
impl Graph {
pub fn new(orbits: HashMap<String, String>) -> Self |
pub fn traverse(&self) -> HashMap<String, usize> {
let mut map = HashMap::new();
// The center of mass orbits nothing.
map.insert("COM".to_string(), 0);
for k in self.orbits.keys() {
self.count(&mut map, &k);
}
map
}
fn count(&self, m: &mut Has... | {
Graph { orbits }
} | identifier_body |
mod.rs | use std::collections::{HashMap, VecDeque};
pub struct Graph {
orbits: HashMap<String, String>,
}
impl Graph {
pub fn new(orbits: HashMap<String, String>) -> Self { | pub fn traverse(&self) -> HashMap<String, usize> {
let mut map = HashMap::new();
// The center of mass orbits nothing.
map.insert("COM".to_string(), 0);
for k in self.orbits.keys() {
self.count(&mut map, &k);
}
map
}
fn count(&self, m: &mut HashM... | Graph { orbits }
}
| random_line_split |
mod.rs | use std::collections::{HashMap, VecDeque};
pub struct Graph {
orbits: HashMap<String, String>,
}
impl Graph {
pub fn new(orbits: HashMap<String, String>) -> Self {
Graph { orbits }
}
pub fn traverse(&self) -> HashMap<String, usize> {
let mut map = HashMap::new();
// The center... | () {
let g = graph(data_p2());
assert_eq!(g.common_ancestor("YOU", "SAN"), "D");
assert_eq!(g.common_ancestor("K", "I"), "D");
assert_eq!(g.common_ancestor("YOU", "L"), "K");
assert_eq!(g.common_ancestor("G", "D"), "B");
}
#[test]
fn transfers_between() {
let... | common_ancestor | identifier_name |
mod.rs | use std::collections::{HashMap, VecDeque};
pub struct Graph {
orbits: HashMap<String, String>,
}
impl Graph {
pub fn new(orbits: HashMap<String, String>) -> Self {
Graph { orbits }
}
pub fn traverse(&self) -> HashMap<String, usize> {
let mut map = HashMap::new();
// The center... |
let n = self.count(m, &self.orbits[s]);
m.insert(s.to_string(), n + 1);
m[s]
}
pub fn common_ancestor(&self, a: &str, b: &str) -> String {
let a_path = self.path(a);
let b_path = self.path(b);
let mut last = "COM";
for (ai, bi) in a_path.iter().zip(b_pat... | {
return *x;
} | conditional_block |
read_manifest.rs | use cargo::core::{Package, Source};
use cargo::util::{CliResult, CliError, Config};
use cargo::sources::{PathSource};
#[derive(RustcDecodable)]
struct | {
flag_manifest_path: String,
}
pub const USAGE: &'static str = "
Usage:
cargo read-manifest [options] --manifest-path=PATH
cargo read-manifest -h | --help
Options:
-h, --help Print this message
-v, --verbose Use verbose output
";
pub fn execute(options: Options, config: &... | Options | identifier_name |
read_manifest.rs | use cargo::core::{Package, Source};
use cargo::util::{CliResult, CliError, Config};
use cargo::sources::{PathSource};
#[derive(RustcDecodable)]
struct Options {
flag_manifest_path: String,
}
pub const USAGE: &'static str = "
Usage:
cargo read-manifest [options] --manifest-path=PATH
cargo read-manifest -h ... | .map_err(|err| CliError::from_boxed(err, 1))
} | .map(|pkg| Some(pkg)) | random_line_split |
dma.rs | use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use libd7::{syscall, PhysAddr, VirtAddr};
static MAPPED: AtomicBool = AtomicBool::new(false);
static VIRTUAL_ADDR: VirtAddr = unsafe { VirtAddr::new_unsafe(0x10_0000_0000) }; // Should be free
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DMARegion... | (size_bytes: usize) -> Self {
let phys = syscall::dma_allocate(size_bytes as u64).unwrap();
// Assumes that DMA block is on the first page.
// Keep in sync with plan.md
if!MAPPED.compare_and_swap(false, true, Ordering::SeqCst) {
unsafe {
syscall::mmap_physica... | allocate | identifier_name |
dma.rs | use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use libd7::{syscall, PhysAddr, VirtAddr};
static MAPPED: AtomicBool = AtomicBool::new(false);
static VIRTUAL_ADDR: VirtAddr = unsafe { VirtAddr::new_unsafe(0x10_0000_0000) }; // Should be free
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DMARegion... |
Self {
phys,
virt: VIRTUAL_ADDR + phys.as_u64(),
}
}
}
| {
unsafe {
syscall::mmap_physical(
PhysAddr::new(0),
VIRTUAL_ADDR,
size_bytes as u64,
syscall::MemoryProtectionFlags::READ | syscall::MemoryProtectionFlags::WRITE,
)
.unwrap();
... | conditional_block |
dma.rs | use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use libd7::{syscall, PhysAddr, VirtAddr};
static MAPPED: AtomicBool = AtomicBool::new(false);
static VIRTUAL_ADDR: VirtAddr = unsafe { VirtAddr::new_unsafe(0x10_0000_0000) }; // Should be free
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DMARegion... | unsafe {
syscall::mmap_physical(
PhysAddr::new(0),
VIRTUAL_ADDR,
size_bytes as u64,
syscall::MemoryProtectionFlags::READ | syscall::MemoryProtectionFlags::WRITE,
)
.unwrap();
... | if !MAPPED.compare_and_swap(false, true, Ordering::SeqCst) { | random_line_split |
dma.rs | use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use libd7::{syscall, PhysAddr, VirtAddr};
static MAPPED: AtomicBool = AtomicBool::new(false);
static VIRTUAL_ADDR: VirtAddr = unsafe { VirtAddr::new_unsafe(0x10_0000_0000) }; // Should be free
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DMARegion... | }
}
}
| {
let phys = syscall::dma_allocate(size_bytes as u64).unwrap();
// Assumes that DMA block is on the first page.
// Keep in sync with plan.md
if !MAPPED.compare_and_swap(false, true, Ordering::SeqCst) {
unsafe {
syscall::mmap_physical(
Phys... | identifier_body |
log.rs | //!
//! Global, mutable log.
//!
//! You may think, "Global and mutable?" and wonder how the borrow checker doesn't completely have a meltdown.
//!
//! Well I do too.
//!
// What can I say, I think `GlobalLog` is prettier than GLOBALLLOG
#![allow(non_upper_case_globals)]
///
/// How to use it
///
/// Import log and u... | () -> Self {
Log { data: vec![] }
}
///
/// Get a range of the last n items added to the log
///
/// The intention of this is that the range is the interated over, and then used as indices
/// to read the log data
///
pub fn get_last_n_messages(&self, n: usize) -> &[(&'static str, RGB, u32)] {
... | new | identifier_name |
log.rs | //!
//! Global, mutable log.
//!
//! You may think, "Global and mutable?" and wonder how the borrow checker doesn't completely have a meltdown.
//!
//! Well I do too.
//!
// What can I say, I think `GlobalLog` is prettier than GLOBALLLOG
#![allow(non_upper_case_globals)]
///
/// How to use it
///
/// Import log and u... |
///
/// How it actually works
///
/// So here's the thought process of this whole thing. I realized that I need some way for various detached objects to have some
/// way to communicate what they are doing directly to the player without creating a mess of spaghetti. The best idea I came up with
/// was to take some so... | random_line_split | |
log.rs | //!
//! Global, mutable log.
//!
//! You may think, "Global and mutable?" and wonder how the borrow checker doesn't completely have a meltdown.
//!
//! Well I do too.
//!
// What can I say, I think `GlobalLog` is prettier than GLOBALLLOG
#![allow(non_upper_case_globals)]
///
/// How to use it
///
/// Import log and u... |
// Push message
self.data.push(message);
}
}
// Make a mutex available
lazy_static! {
pub static ref GlobalLog: Mutex<Log> = Mutex::new(Log::new());
}
/// This macro automates the log mutex process. This whole thing is pretty crazy
/// Obviously if any panics occur here then the mutex becomes pois... | {
// If the last message string is the same, update the counter instead of pushing.
let last_pos = self.data.len() - 1;
if &self.data[last_pos].0 == &message.0 {
self.data[last_pos].2 += 1;
return;
}
} | conditional_block |
main.rs | fn main() {
println!("{:?}", mul_inv(42, 2017));
}
fn mul_inv(a: i32, b: i32) -> Option<i32> {
let (gcd, mut x, _) = egcd(a, b);
if gcd!= 1 {
// No multiplicative inverse exists
return None;
}
if x < 0 {
x += b;
}
Some(x % b)
}
#[allow(clippy::many_single_char_names... | (g, x - (b / a) * y, y)
}
#[test]
fn test() {
assert_eq!(mul_inv(42, 2017), Some(1969));
} | let (g, y, x) = egcd(b % a, a); | random_line_split |
main.rs | fn main() {
println!("{:?}", mul_inv(42, 2017));
}
fn mul_inv(a: i32, b: i32) -> Option<i32> {
let (gcd, mut x, _) = egcd(a, b);
if gcd!= 1 {
// No multiplicative inverse exists
return None;
}
if x < 0 {
x += b;
}
Some(x % b)
}
#[allow(clippy::many_single_char_names... | {
assert_eq!(mul_inv(42, 2017), Some(1969));
} | identifier_body | |
main.rs | fn main() {
println!("{:?}", mul_inv(42, 2017));
}
fn mul_inv(a: i32, b: i32) -> Option<i32> {
let (gcd, mut x, _) = egcd(a, b);
if gcd!= 1 {
// No multiplicative inverse exists
return None;
}
if x < 0 {
x += b;
}
Some(x % b)
}
#[allow(clippy::many_single_char_names... |
let (g, y, x) = egcd(b % a, a);
(g, x - (b / a) * y, y)
}
#[test]
fn test() {
assert_eq!(mul_inv(42, 2017), Some(1969));
}
| {
return (b, 0, 1);
} | conditional_block |
main.rs | fn main() {
println!("{:?}", mul_inv(42, 2017));
}
fn mul_inv(a: i32, b: i32) -> Option<i32> {
let (gcd, mut x, _) = egcd(a, b);
if gcd!= 1 {
// No multiplicative inverse exists
return None;
}
if x < 0 {
x += b;
}
Some(x % b)
}
#[allow(clippy::many_single_char_names... | (a: i32, b: i32) -> (i32, i32, i32) {
if a == 0 {
return (b, 0, 1);
}
let (g, y, x) = egcd(b % a, a);
(g, x - (b / a) * y, y)
}
#[test]
fn test() {
assert_eq!(mul_inv(42, 2017), Some(1969));
}
| egcd | identifier_name |
latencies.rs | #![feature(test)]
| use shamirsecretsharing as sss;
#[bench]
fn create_shares_54(b: &mut Bencher) {
let data = vec![42; sss::DATA_SIZE];
let count = 5;
let threshold = 4;
b.iter(|| {
sss::create_shares(&data, count, threshold).unwrap();
});
}
#[bench]
fn combine_shares_4(b: &mut Bencher) {
let data = vec!... | extern crate shamirsecretsharing;
extern crate test;
use test::Bencher;
| random_line_split |
latencies.rs | #![feature(test)]
extern crate shamirsecretsharing;
extern crate test;
use test::Bencher;
use shamirsecretsharing as sss;
#[bench]
fn create_shares_54(b: &mut Bencher) {
let data = vec![42; sss::DATA_SIZE];
let count = 5;
let threshold = 4;
b.iter(|| {
sss::create_shares(&data, count, thresh... | (b: &mut Bencher) {
let key = vec![42; sss::hazmat::KEY_SIZE];
let threshold = 4;
let shares = sss::hazmat::create_keyshares(&key, threshold, threshold).unwrap();
b.iter(|| {
sss::hazmat::combine_keyshares(&shares).unwrap();
});
}
| combine_keyshares_4 | identifier_name |
latencies.rs | #![feature(test)]
extern crate shamirsecretsharing;
extern crate test;
use test::Bencher;
use shamirsecretsharing as sss;
#[bench]
fn create_shares_54(b: &mut Bencher) {
let data = vec![42; sss::DATA_SIZE];
let count = 5;
let threshold = 4;
b.iter(|| {
sss::create_shares(&data, count, thresh... | {
let key = vec![42; sss::hazmat::KEY_SIZE];
let threshold = 4;
let shares = sss::hazmat::create_keyshares(&key, threshold, threshold).unwrap();
b.iter(|| {
sss::hazmat::combine_keyshares(&shares).unwrap();
});
} | identifier_body | |
mod.rs | pub use self::dependency::Dependency;
pub use self::features::{
enable_nightly_features, maybe_allow_nightly_features, nightly_features_allowed,
};
pub use self::features::{CliUnstable, Edition, Feature, Features};
pub use self::interning::InternedString;
pub use self::manifest::{EitherManifest, VirtualManifest};
p... | pub mod dependency;
pub mod features;
mod interning;
pub mod manifest;
pub mod package;
pub mod package_id;
mod package_id_spec;
pub mod profiles;
pub mod registry;
pub mod resolver;
pub mod shell;
pub mod source;
pub mod summary;
mod workspace; | pub use self::workspace::{Members, Workspace, WorkspaceConfig, WorkspaceRootConfig};
pub mod compiler; | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.