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 |
|---|---|---|---|---|
input_state.rs | use std::vec::Vec;
use operation::{ Operation, Direction, };
pub struct InputState {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
pub enter: bool,
pub cancel: bool,
}
impl InputState {
pub fn new() -> InputState {
InputState {
left: false, right: fals... |
if self.cancel { states.push(Operation::Cancel); }
states
}
}
| { states.push(Operation::Enter); } | conditional_block |
input_state.rs | use std::vec::Vec;
use operation::{ Operation, Direction, };
pub struct InputState {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
pub enter: bool,
pub cancel: bool,
}
impl InputState {
pub fn new() -> InputState {
InputState {
left: false, right: fals... | (&mut self, op: Operation) -> &mut Self {
self.update(op, false)
}
fn update(&mut self, op: Operation, value: bool) -> &mut Self {
match op {
Operation::Move(dir) => match dir {
Direction::Left => self.left = value,
Direction::Right => self.right = va... | release | identifier_name |
input_state.rs | use std::vec::Vec; | use operation::{ Operation, Direction, };
pub struct InputState {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
pub enter: bool,
pub cancel: bool,
}
impl InputState {
pub fn new() -> InputState {
InputState {
left: false, right: false, up: false, down: ... | random_line_split | |
spatial_reference.rs | extern crate gdal; |
fn run() -> Result<(), gdal::errors::Error> {
let spatial_ref1 = SpatialRef::from_proj4(
"+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs",
)?;
println!(
"Spatial ref from proj4 to wkt:\n{:?}\n",
spatial_ref1.to_wkt()?
);
let spatial_r... |
use gdal::spatial_ref::{CoordTransform, SpatialRef};
use gdal::vector::Geometry; | random_line_split |
spatial_reference.rs | extern crate gdal;
use gdal::spatial_ref::{CoordTransform, SpatialRef};
use gdal::vector::Geometry;
fn | () -> Result<(), gdal::errors::Error> {
let spatial_ref1 = SpatialRef::from_proj4(
"+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs",
)?;
println!(
"Spatial ref from proj4 to wkt:\n{:?}\n",
spatial_ref1.to_wkt()?
);
let spatial_ref2 = S... | run | identifier_name |
spatial_reference.rs | extern crate gdal;
use gdal::spatial_ref::{CoordTransform, SpatialRef};
use gdal::vector::Geometry;
fn run() -> Result<(), gdal::errors::Error> | "Spatial ref from epsg code to wkt:\n{:?}\n",
spatial_ref4.to_wkt()?
);
println!(
"Spatial ref from epsg code to pretty wkt:\n{:?}\n",
spatial_ref4.to_pretty_wkt()?
);
println!(
"Comparison between identical SRS : {:?}\n",
spatial_ref2 == spatial_ref4
... | {
let spatial_ref1 = SpatialRef::from_proj4(
"+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs",
)?;
println!(
"Spatial ref from proj4 to wkt:\n{:?}\n",
spatial_ref1.to_wkt()?
);
let spatial_ref2 = SpatialRef::from_wkt("GEOGCS[\"WGS 84\"... | identifier_body |
vga.rs | use core::prelude::*;
use io;
const BACKSPACE: u8 = 0x08;
const TAB: u8 = 0x09;
const NEWLINE: u8 = 0x0A;
const CR: u8 = 0x0D;
const WHITESPACE: u8 = 0x20;
const VGA_ADDRESS: int = 0xB8000;
const VGA_HEIGHT: u16 = 25;
const VGA_WIDTH: u16 = 80;
enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3... | VGA.putc(character);
}
}
pub fn puts(string: &str) {
unsafe {
VGA.puts(string);
}
} | pub fn putc(character: u8) {
unsafe { | random_line_split |
vga.rs | use core::prelude::*;
use io;
const BACKSPACE: u8 = 0x08;
const TAB: u8 = 0x09;
const NEWLINE: u8 = 0x0A;
const CR: u8 = 0x0D;
const WHITESPACE: u8 = 0x20;
const VGA_ADDRESS: int = 0xB8000;
const VGA_HEIGHT: u16 = 25;
const VGA_WIDTH: u16 = 80;
enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3... | self.put(offset, Black as u16, White as u16, character);
self.forward();
}
self.mov();
}
fn puti(&mut self, integer: uint) {
if integer == 0 {
self.puts("0");
}
else {
let mut integer = integer;
let mut revers... | {
if character == BACKSPACE {
self.back();
}
else if character == TAB {
self.tab();
}
else if character == NEWLINE {
self.newline();
}
else if character == CR {
self.cr();
}
else if character >= ... | identifier_body |
vga.rs | use core::prelude::*;
use io;
const BACKSPACE: u8 = 0x08;
const TAB: u8 = 0x09;
const NEWLINE: u8 = 0x0A;
const CR: u8 = 0x0D;
const WHITESPACE: u8 = 0x20;
const VGA_ADDRESS: int = 0xB8000;
const VGA_HEIGHT: u16 = 25;
const VGA_WIDTH: u16 = 80;
enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3... | (&mut self, integer: uint) {
self.puts("0x");
let mut nibbles = 1;
while (integer >> nibbles * 4) > 0 {
nibbles += 1
}
for i in range(0, nibbles) {
let nibble = ((integer >> (nibbles - i - 1) * 4) & 0xF) as u8;
let character = if nibble ... | puth | identifier_name |
vga.rs | use core::prelude::*;
use io;
const BACKSPACE: u8 = 0x08;
const TAB: u8 = 0x09;
const NEWLINE: u8 = 0x0A;
const CR: u8 = 0x0D;
const WHITESPACE: u8 = 0x20;
const VGA_ADDRESS: int = 0xB8000;
const VGA_HEIGHT: u16 = 25;
const VGA_WIDTH: u16 = 80;
enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3... |
else if character >= WHITESPACE {
let offset = self.offset();
self.put(offset, Black as u16, White as u16, character);
self.forward();
}
self.mov();
}
fn puti(&mut self, integer: uint) {
if integer == 0 {
self.puts("0");
... | {
self.cr();
} | conditional_block |
gid_filter.rs | use filter;
use filter::Filter;
use walkdir::DirEntry;
use std::os::unix::fs::MetadataExt;
use std::process;
pub struct GidFilter {
gid: u32,
comp_op: filter::CompOp,
}
impl GidFilter {
pub fn new(comp_op: filter::CompOp, gid: u32) -> GidFilter {
GidFilter{comp_op: comp_op, gid: gid}
}
}
impl... | ,
}
}
}
| {
eprintln!("Operator {:?} not covered for attribute gid!", self.comp_op);
process::exit(1);
} | conditional_block |
gid_filter.rs | use filter;
use filter::Filter;
use walkdir::DirEntry;
use std::os::unix::fs::MetadataExt;
use std::process;
pub struct GidFilter {
gid: u32,
comp_op: filter::CompOp,
}
impl GidFilter {
pub fn new(comp_op: filter::CompOp, gid: u32) -> GidFilter {
GidFilter{comp_op: comp_op, gid: gid}
}
}
impl... |
}
| {
match self.comp_op {
filter::CompOp::Equal => self.gid == dir_entry.metadata().unwrap().gid(),
filter::CompOp::Unequal => self.gid != dir_entry.metadata().unwrap().gid(),
_ => {
eprintln!("Operator {:?} not covered for attribute gid!", ... | identifier_body |
gid_filter.rs | use filter;
use filter::Filter;
use walkdir::DirEntry;
use std::os::unix::fs::MetadataExt;
use std::process;
pub struct | {
gid: u32,
comp_op: filter::CompOp,
}
impl GidFilter {
pub fn new(comp_op: filter::CompOp, gid: u32) -> GidFilter {
GidFilter{comp_op: comp_op, gid: gid}
}
}
impl Filter for GidFilter {
fn test(&self, dir_entry: &DirEntry) -> bool {
match self.comp_op {
filter::CompOp... | GidFilter | identifier_name |
gid_filter.rs | use filter;
use filter::Filter;
use walkdir::DirEntry;
use std::os::unix::fs::MetadataExt;
use std::process;
pub struct GidFilter {
gid: u32,
comp_op: filter::CompOp,
}
impl GidFilter {
pub fn new(comp_op: filter::CompOp, gid: u32) -> GidFilter {
GidFilter{comp_op: comp_op, gid: gid}
}
}
impl... | eprintln!("Operator {:?} not covered for attribute gid!", self.comp_op);
process::exit(1);
},
}
}
} | fn test(&self, dir_entry: &DirEntry) -> bool {
match self.comp_op {
filter::CompOp::Equal => self.gid == dir_entry.metadata().unwrap().gid(),
filter::CompOp::Unequal => self.gid != dir_entry.metadata().unwrap().gid(),
_ => { | random_line_split |
config.rs | #![allow(dead_code)]
use log::LevelFilter;
use once_cell::sync::Lazy;
use std::str::FromStr;
static CONF: Lazy<Config> = Lazy::new(|| {
let log_level = std::env::var("SIMAG_LOG_LEVEL")
.or_else::<std::env::VarError, _>(|_| Ok("info".to_owned()))
.ok()
.map(|l| LevelFilter::from_str(&l).unwrap... | ;
impl Logger {
pub fn get_logger() -> &'static Logger {
Lazy::force(&LOGGER)
}
}
#[allow(unused_must_use)]
static LOGGER: Lazy<Logger> = Lazy::new(|| {
env_logger::builder()
.format_module_path(true)
.format_timestamp_nanos()
.targe... | Logger | identifier_name |
config.rs | #![allow(dead_code)]
use log::LevelFilter;
use once_cell::sync::Lazy;
use std::str::FromStr;
static CONF: Lazy<Config> = Lazy::new(|| {
let log_level = std::env::var("SIMAG_LOG_LEVEL")
.or_else::<std::env::VarError, _>(|_| Ok("info".to_owned()))
.ok()
.map(|l| LevelFilter::from_str(&l).unwrap... | pub struct Logger;
impl Logger {
pub fn get_logger() -> &'static Logger {
Lazy::force(&LOGGER)
}
}
#[allow(unused_must_use)]
static LOGGER: Lazy<Logger> = Lazy::new(|| {
env_logger::builder()
.format_module_path(true)
.format_timestamp_nano... | #[cfg(any(test, debug_assertions))]
pub(super) mod tracing {
use super::*;
#[derive(Clone, Copy)] | random_line_split |
builder.rs | use crate::enums::{CapStyle, DashStyle, LineJoin};
use crate::factory::IFactory;
use crate::stroke_style::StrokeStyle;
use com_wrapper::ComWrapper;
use dcommon::Error;
use winapi::shared::winerror::SUCCEEDED;
use winapi::um::d2d1::D2D1_STROKE_STYLE_PROPERTIES;
pub struct StrokeStyleBuilder<'a> {
factory: &'a dyn ... | else {
Err(hr.into())
}
}
}
pub fn with_start_cap(mut self, start_cap: CapStyle) -> Self {
self.start_cap = start_cap;
self
}
pub fn with_end_cap(mut self, end_cap: CapStyle) -> Self {
self.end_cap = end_cap;
self
}
pub fn w... | {
Ok(StrokeStyle::from_raw(ptr))
} | conditional_block |
builder.rs | use crate::enums::{CapStyle, DashStyle, LineJoin};
use crate::factory::IFactory;
use crate::stroke_style::StrokeStyle;
use com_wrapper::ComWrapper;
use dcommon::Error;
use winapi::shared::winerror::SUCCEEDED;
use winapi::um::d2d1::D2D1_STROKE_STYLE_PROPERTIES;
pub struct StrokeStyleBuilder<'a> {
factory: &'a dyn ... | }
pub fn with_dash_cap(mut self, dash_cap: CapStyle) -> Self {
self.dash_cap = dash_cap;
self
}
pub fn with_line_join(mut self, line_join: LineJoin) -> Self {
self.line_join = line_join;
self
}
pub fn with_miter_limit(mut self, miter_limit: f32) -> Self {
... |
pub fn with_end_cap(mut self, end_cap: CapStyle) -> Self {
self.end_cap = end_cap;
self | random_line_split |
builder.rs | use crate::enums::{CapStyle, DashStyle, LineJoin};
use crate::factory::IFactory;
use crate::stroke_style::StrokeStyle;
use com_wrapper::ComWrapper;
use dcommon::Error;
use winapi::shared::winerror::SUCCEEDED;
use winapi::um::d2d1::D2D1_STROKE_STYLE_PROPERTIES;
pub struct StrokeStyleBuilder<'a> {
factory: &'a dyn ... |
pub fn with_end_cap(mut self, end_cap: CapStyle) -> Self {
self.end_cap = end_cap;
self
}
pub fn with_dash_cap(mut self, dash_cap: CapStyle) -> Self {
self.dash_cap = dash_cap;
self
}
pub fn with_line_join(mut self, line_join: LineJoin) -> Self {
self.line... | {
self.start_cap = start_cap;
self
} | identifier_body |
builder.rs | use crate::enums::{CapStyle, DashStyle, LineJoin};
use crate::factory::IFactory;
use crate::stroke_style::StrokeStyle;
use com_wrapper::ComWrapper;
use dcommon::Error;
use winapi::shared::winerror::SUCCEEDED;
use winapi::um::d2d1::D2D1_STROKE_STYLE_PROPERTIES;
pub struct StrokeStyleBuilder<'a> {
factory: &'a dyn ... | (mut self, dashes: &'a [f32]) -> Self {
self.dash_style = DashStyle::Custom;
self.dashes = Some(dashes);
self
}
fn to_d2d1(&self) -> D2D1_STROKE_STYLE_PROPERTIES {
D2D1_STROKE_STYLE_PROPERTIES {
startCap: self.start_cap as u32,
endCap: self.end_cap as u32... | with_dashes | identifier_name |
defs.rs | /*
* Copyright (C) 2017 AltOS-Rust Team
*
* 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 | * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
pub const GROUPA_ADDR: *const u32 = 0x4800_0000 as *const _;
pub const GROUPB_ADDR: *const u32 = 0x4800_0400 as *const _;
pub co... | * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | random_line_split |
logger.rs | /* Copyright (C) 2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... | (tx: &RFBTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
js.open_object("rfb")?;
// Protocol version
if let Some(tx_spv) = &tx.tc_server_protocol_version {
js.open_object("server_protocol_version")?;
js.set_string("major", &tx_spv.major)?;
js.set_string("minor", &tx_sp... | log_rfb | identifier_name |
logger.rs | /* Copyright (C) 2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... | match tx.chosen_security_type {
Some(2) => {
js.open_object("vnc")?;
if let Some(ref sc) = tx.tc_vnc_challenge {
let mut s = String::new();
for &byte in &sc.secret[..] {
write!(&mut s, "{:02x}", byte).expect("Unable to write");
... | if let Some(chosen_security_type) = tx.chosen_security_type {
js.set_uint("security_type", chosen_security_type as u64)?;
} | random_line_split |
logger.rs | /* Copyright (C) 2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... | js.set_uint("security_type", chosen_security_type as u64)?;
}
match tx.chosen_security_type {
Some(2) => {
js.open_object("vnc")?;
if let Some(ref sc) = tx.tc_vnc_challenge {
let mut s = String::new();
for &byte in &sc.secret[..] {
... | {
js.open_object("rfb")?;
// Protocol version
if let Some(tx_spv) = &tx.tc_server_protocol_version {
js.open_object("server_protocol_version")?;
js.set_string("major", &tx_spv.major)?;
js.set_string("minor", &tx_spv.minor)?;
js.close()?;
}
if let Some(tx_cpv) = &tx.t... | identifier_body |
util.rs | use hyper::header::{Accept, Connection, ContentType, Headers, Quality,
QualityItem, qitem};
use hyper::mime::{Mime, SubLevel, TopLevel};
use protobuf::{self, Message};
use proto::mesos::*;
pub fn protobuf_headers() -> Headers {
let mut headers = Headers::new();
headers.set(Accept(vec![
... | {
offers.iter()
.flat_map(|o| o.get_resources())
.filter(|r| r.get_name() == "mem")
.map(|c| c.get_scalar())
.fold(0f64, |acc, mem_res| acc + mem_res.get_value())
} | identifier_body | |
util.rs | use hyper::header::{Accept, Connection, ContentType, Headers, Quality,
QualityItem, qitem};
use hyper::mime::{Mime, SubLevel, TopLevel};
use protobuf::{self, Message};
use proto::mesos::*;
pub fn protobuf_headers() -> Headers {
let mut headers = Headers::new();
headers.set(Accept(vec![
... | res.set_role(role.to_string());
res.set_field_type(Value_Type::SCALAR);
res.set_scalar(scalar);
res
}
pub fn get_scalar_resource_sum<'a>(name: &'a str, offers: Vec<&Offer>) -> f64 {
offers.iter()
.flat_map(|o| o.get_resources())
.filter(|r| r.get_name() == "mem")
.map(|c|... | let mut res = Resource::new();
res.set_name(name.to_string()); | random_line_split |
util.rs | use hyper::header::{Accept, Connection, ContentType, Headers, Quality,
QualityItem, qitem};
use hyper::mime::{Mime, SubLevel, TopLevel};
use protobuf::{self, Message};
use proto::mesos::*;
pub fn protobuf_headers() -> Headers {
let mut headers = Headers::new();
headers.set(Accept(vec![
... | (task_infos: Vec<TaskInfo>) -> Operation {
let mut launch = Operation_Launch::new();
launch.set_task_infos(protobuf::RepeatedField::from_vec(task_infos));
let mut operation = Operation::new();
operation.set_field_type(Operation_Type::LAUNCH);
operation.set_launch(launch);
operation
}
pub fn sc... | launch_operation | identifier_name |
object-safety-issue-22040.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() {
let a: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
let b: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
// assert_eq!(a, b);
}
| {
println!("element count: {}", self.elements.len());
} | identifier_body |
object-safety-issue-22040.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 ... | (&self, other:&SExpr<'x>) -> bool {
println!("L1: {} L2: {}", self.elements.len(), other.elements.len());
//~^ ERROR E0038
let result = self.elements.len() == other.elements.len();
println!("Got compare {}", result);
return result;
}
}
impl <'x> SExpr<'x> {
fn new() -> ... | eq | identifier_name |
object-safety-issue-22040.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 ... |
impl <'x> SExpr<'x> {
fn new() -> SExpr<'x> { return SExpr{elements: Vec::new(),}; }
}
impl <'x> Expr for SExpr<'x> {
fn print_element_count(&self) {
println!("element count: {}", self.elements.len());
}
}
fn main() {
let a: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
let b: Box<E... | println!("Got compare {}", result);
return result;
}
} | random_line_split |
cell-does-not-clone.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let x = Cell::new(Foo { x: 22 });
let _y = x.get();
let _z = x.clone();
} | identifier_body | |
cell-does-not-clone.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 ... | (&self) -> Foo {
// Using Cell in any way should never cause clone() to be
// invoked -- after all, that would permit evil user code to
// abuse `Cell` and trigger crashes.
panic!();
}
}
impl Copy for Foo {}
pub fn main() {
let x = Cell::new(Foo { x: 22 });
let _y = x.get(... | clone | identifier_name |
cell-does-not-clone.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 ... | panic!();
}
}
impl Copy for Foo {}
pub fn main() {
let x = Cell::new(Foo { x: 22 });
let _y = x.get();
let _z = x.clone();
} | fn clone(&self) -> Foo {
// Using Cell in any way should never cause clone() to be
// invoked -- after all, that would permit evil user code to
// abuse `Cell` and trigger crashes.
| random_line_split |
arguments.rs | use std;
pub enum | {
Invalid,
Help,
Create(String, Vec<String>),
Extract(String),
List(String),
}
impl Arguments {
pub fn parseargs() -> Arguments {
enum Action { Create, Extract, List }
let mut action = None;
let mut archive: Option<String> = None;
let mut files: Vec<String> = Ve... | Arguments | identifier_name |
arguments.rs | use std;
pub enum Arguments {
Invalid,
Help,
Create(String, Vec<String>),
Extract(String),
List(String),
}
impl Arguments {
pub fn parseargs() -> Arguments {
enum Action { Create, Extract, List }
let mut action = None;
let mut archive: Option<String> = None;
let... | let archive = match archive {
None => return Arguments::Invalid,
Some(fname) => fname,
};
return match action {
None => Arguments::Invalid,
Some(Action::Create) => Arguments::Create(archive, files),
Some(Action::Extract) => Arguments::... | random_line_split | |
insert.rs | use database::Database;
use database::Errors;
use database::errors::log_n_wrap;
use database::Errors::{NotFound, Conflict};
use std::vec::Vec;
use serde_json::Value;
use serde_json;
use rand;
impl Database {
/// Inserts the record to the given path.
pub fn insert(&mut self, keys: &mut Vec<String>, value: Value... | record at index: {:?}",
&value_with_id,
idx)))
} else {
array.push(value_with_id.clone());
info!(&self.logger, "Inse... | {
let data = &mut self.data;
if let Ok(obj) = Self::get_object(keys, data) {
// Path Found. It should be an array to accomplish an operation. Otherwise it must be an update not insert.
if let Some(ref mut array) = obj.as_array_mut() {
let mut id = rand::random();
... | identifier_body |
insert.rs | use database::Database;
use database::Errors;
use database::errors::log_n_wrap;
use database::Errors::{NotFound, Conflict};
use std::vec::Vec;
use serde_json::Value;
use serde_json;
use rand;
impl Database {
/// Inserts the record to the given path.
pub fn | (&mut self, keys: &mut Vec<String>, value: Value) -> Result<Value, Errors> {
let data = &mut self.data;
if let Ok(obj) = Self::get_object(keys, data) {
// Path Found. It should be an array to accomplish an operation. Otherwise it must be an update not insert.
if let Some(ref mut ... | insert | identifier_name |
insert.rs | use database::Database;
use database::Errors;
use database::errors::log_n_wrap;
use database::Errors::{NotFound, Conflict};
use std::vec::Vec;
use serde_json::Value;
use serde_json;
use rand;
impl Database {
/// Inserts the record to the given path.
pub fn insert(&mut self, keys: &mut Vec<String>, value: Value... | }
} | log_n_wrap(&self.logger,
NotFound(format!("Insert - Error {:?}. No record with the given path:",
keys)))
} | random_line_split |
insert.rs | use database::Database;
use database::Errors;
use database::errors::log_n_wrap;
use database::Errors::{NotFound, Conflict};
use std::vec::Vec;
use serde_json::Value;
use serde_json;
use rand;
impl Database {
/// Inserts the record to the given path.
pub fn insert(&mut self, keys: &mut Vec<String>, value: Value... |
let value_with_id = &mut value.clone();
if let Some(obj_id) = value_with_id.as_object_mut() {
obj_id.insert("id".to_string(), serde_json::to_value(id).unwrap());
}
// TODO: random id conflict must be resolved.
if let So... | {
if let Some(parsed) = id_value.as_i64() {
id = parsed;
}
} | conditional_block |
lib.rs | ();
let add_insts = self.add_insts();
let regex = &*self.original;
quote_expr!(self.cx, {
// When `regex!` is bound to a name that is not used, we have to make sure
// that dead_code warnings don't bubble up to the user from the generated
// code. Therefore, we suppress them by allowing dead_co... | {
arms.push(self.wild_arm_expr(self.empty_block()));
self.cx.expr_match(self.sp, quote_expr!(self.cx, pc), arms)
} | identifier_body | |
lib.rs | = match Compiler::new().size_limit(usize::MAX).compile(&[expr]) {
Ok(re) => re,
Err(err) => {
cx.span_err(sp, &err.to_string());
return DummyResult::any(sp)
}
};
let names = prog.captures.iter().cloned().collect();
let mut gen = NfaGen {
cx: &*cx,
... | (&self, ranges: &[(char, char)]) -> P<ast:: | match_class | identifier_name |
lib.rs | prog = match Compiler::new().size_limit(usize::MAX).compile(&[expr]) {
Ok(re) => re,
Err(err) => {
cx.span_err(sp, &err.to_string());
return DummyResult::any(sp)
}
};
let names = prog.captures.iter().cloned().collect();
let mut gen = NfaGen {
cx: &*cx... | }
return false;
})
}
// EmptyLook, Save, Jump, Split
_ => quote_expr!(self.cx, { return false; }),
};
self.arm_inst(pc, body)
}).collect::<Vec<ast::Arm>>();
self.m... | self.add(nlist, thread_caps, $nextpc, at_next);
} | random_line_split |
query19.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
// use differential_dataflow::difference::DiffPair;
use ::Collectio... | println!("TODO: query 19 could use some _u attention");
let lineitems =
collections
.lineitems()
.inner
.flat_map(|(x,t,d)|
if (starts_with(&x.ship_mode, b"AIR") || starts_with(&x.ship_mode, b"AIR REG")) && starts_with(&x.ship_instruct, b"DELIVER IN PERSON") {
... |
pub fn query<G: Scope>(collections: &mut Collections<G>) -> ProbeHandle<G::Timestamp>
where G::Timestamp: Lattice+Ord {
| random_line_split |
query19.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
// use differential_dataflow::difference::DiffPair;
use ::Collectio... |
else { None }
)
.as_collection();
let lines1 = lineitems.filter(|&(_, quant)| quant >= 1 && quant <= 11).map(|x| (x.0, ()));
let lines2 = lineitems.filter(|&(_, quant)| quant >= 10 && quant <= 20).map(|x| (x.0, ()));
let lines3 = lineitems.filter(|&(_, quant)| quant >= 20 && qua... | {
Some(((x.part_key, x.quantity), t, d * (x.extended_price * (100 - x.discount) / 100) as isize))
} | conditional_block |
query19.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
// use differential_dataflow::difference::DiffPair;
use ::Collectio... |
pub fn query<G: Scope>(collections: &mut Collections<G>) -> ProbeHandle<G::Timestamp>
where G::Timestamp: Lattice+Ord {
println!("TODO: query 19 could use some _u attention");
let lineitems =
collections
.lineitems()
.inner
.flat_map(|(x,t,d)|
if (starts_with(&x.ship_m... | {
source.len() >= query.len() && &source[..query.len()] == query
} | identifier_body |
query19.rs | use timely::dataflow::*;
use timely::dataflow::operators::*;
use timely::dataflow::operators::probe::Handle as ProbeHandle;
use differential_dataflow::AsCollection;
use differential_dataflow::operators::*;
use differential_dataflow::lattice::Lattice;
// use differential_dataflow::difference::DiffPair;
use ::Collectio... | <G: Scope>(collections: &mut Collections<G>) -> ProbeHandle<G::Timestamp>
where G::Timestamp: Lattice+Ord {
println!("TODO: query 19 could use some _u attention");
let lineitems =
collections
.lineitems()
.inner
.flat_map(|(x,t,d)|
if (starts_with(&x.ship_mode, b"AIR") |... | query | identifier_name |
any_unique_aliases_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub cons... |
}
impl<'a> flatbuffers::Verifiable for AnyUniqueAliases {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
u8::run_verifier(v, pos)
}
}
impl flatbuffers::SimpleToVerifyInSlice for AnyUniqueAli... | {
let b = u8::from_le(self.0);
Self(b)
} | identifier_body |
any_unique_aliases_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub cons... | (buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe {
flatbuffers::read_scalar_at::<u8>(buf, loc)
};
Self(b)
}
}
impl flatbuffers::Push for AnyUniqueAliases {
type Output = AnyUniqueAliases;
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
unsafe { flatbuffers::e... | follow | identifier_name |
any_unique_aliases_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub cons... | ];
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
Self::NONE => Some("NONE"),
Self::M => Some("M"),
Self::TS => Some("TS"),
Self::M2 => Some("M2"),
_ => None,
}
}
}
impl std::fmt::Debug for AnyUniqueAliases ... | Self::M2, | random_line_split |
client.rs | //! The modules which contains CDRS Cassandra client.
use std::net;
use std::io;
use std::collections::HashMap;
use query::{Query, QueryParams, QueryBatch};
use frame::{Frame, Opcode, Flag};
use frame::frame_response::ResponseBody;
use IntoBytes;
use frame::parser::parse_frame;
use types::*;
use frame::events::SimpleSe... | pub struct Session<T: Authenticator, X: CDRSTransport> {
started: bool,
cdrs: CDRS<T, X>,
compressor: Compression,
}
impl<T: Authenticator, X: CDRSTransport> Session<T, X> {
/// Creates new session basing on CDRS instance.
pub fn start(cdrs: CDRS<T, X>) -> Session<T, X> {
let compressor = c... | /// The object that provides functionality for communication with Cassandra server. | random_line_split |
client.rs | //! The modules which contains CDRS Cassandra client.
use std::net;
use std::io;
use std::collections::HashMap;
use query::{Query, QueryParams, QueryBatch};
use frame::{Frame, Opcode, Flag};
use frame::frame_response::ResponseBody;
use IntoBytes;
use frame::parser::parse_frame;
use types::*;
use frame::events::SimpleSe... | io::ErrorKind::NotFound,
format!(
"Unsupported type of authenticator. {:?} got,
but {} is supported.",
authenticator,
authenticator
... | {
let body = start_response.get_body()?;
let authenticator = body.get_authenticator().expect(
"Cassandra Server did communicate that it needed password
authentication but the auth schema was missing in the body response",
);
// This creat... | conditional_block |
client.rs | //! The modules which contains CDRS Cassandra client.
use std::net;
use std::io;
use std::collections::HashMap;
use query::{Query, QueryParams, QueryBatch};
use frame::{Frame, Opcode, Flag};
use frame::frame_response::ResponseBody;
use IntoBytes;
use frame::parser::parse_frame;
use types::*;
use frame::events::SimpleSe... | <'a>(mut self,
events: Vec<SimpleServerEvent>)
-> error::Result<(Listener<X>, EventStream)> {
let query_frame = Frame::new_req_register(events).into_cbytes();
try!(self.cdrs.transport.write(query_frame.as_slice()));
try!(parse_frame(&mut self.c... | listen_for | identifier_name |
manual_non_exhaustive.rs | use clippy_utils::attrs::is_doc_hidden;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::source::snippet_opt;
use clippy_utils::{meets_msrv, msrvs};
use if_chain::if_chain;
use rustc_ast::ast::{FieldDef, Item, ItemKind, Variant, VariantData, VisibilityKind};
use rustc_errors::Applicability;
use rust... | (field: &FieldDef) -> bool {
matches!(field.vis.kind, VisibilityKind::Inherited)
}
fn is_non_exhaustive_marker(field: &FieldDef) -> bool {
is_private(field) && field.ty.kind.is_unit() && field.ident.map_or(true, |n| n.as_str().starts_with('_'))
}
fn find_header_span(cx: &EarlyContext<'... | is_private | identifier_name |
manual_non_exhaustive.rs | use clippy_utils::attrs::is_doc_hidden;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::source::snippet_opt;
use clippy_utils::{meets_msrv, msrvs};
use if_chain::if_chain;
use rustc_ast::ast::{FieldDef, Item, ItemKind, Variant, VariantData, VisibilityKind};
use rustc_errors::Applicability;
use rust... | }
}
fn check_manual_non_exhaustive_struct(cx: &EarlyContext<'_>, item: &Item, data: &VariantData) {
fn is_private(field: &FieldDef) -> bool {
matches!(field.vis.kind, VisibilityKind::Inherited)
}
fn is_non_exhaustive_marker(field: &FieldDef) -> bool {
is_private(field) && field.ty.kind... | random_line_split | |
manual_non_exhaustive.rs | use clippy_utils::attrs::is_doc_hidden;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::source::snippet_opt;
use clippy_utils::{meets_msrv, msrvs};
use if_chain::if_chain;
use rustc_ast::ast::{FieldDef, Item, ItemKind, Variant, VariantData, VisibilityKind};
use rustc_errors::Applicability;
use rust... | ,
_ => {},
}
}
extract_msrv_attr!(EarlyContext);
}
fn check_manual_non_exhaustive_enum(cx: &EarlyContext<'_>, item: &Item, variants: &[Variant]) {
fn is_non_exhaustive_marker(variant: &Variant) -> bool {
matches!(variant.data, VariantData::Unit(_))
&& variant.ident.... | {
if let VariantData::Unit(..) = variant_data {
return;
}
check_manual_non_exhaustive_struct(cx, item, variant_data);
} | conditional_block |
manual_non_exhaustive.rs | use clippy_utils::attrs::is_doc_hidden;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::source::snippet_opt;
use clippy_utils::{meets_msrv, msrvs};
use if_chain::if_chain;
use rustc_ast::ast::{FieldDef, Item, ItemKind, Variant, VariantData, VisibilityKind};
use rustc_errors::Applicability;
use rust... |
fn find_header_span(cx: &EarlyContext<'_>, item: &Item, data: &VariantData) -> Span {
let delimiter = match data {
VariantData::Struct(..) => '{',
VariantData::Tuple(..) => '(',
VariantData::Unit(_) => unreachable!("`VariantData::Unit` is already handled above"),
... | {
is_private(field) && field.ty.kind.is_unit() && field.ident.map_or(true, |n| n.as_str().starts_with('_'))
} | identifier_body |
test_sync.rs | use std::sync::Arc;
use std::thread;
// use protobuf::CodedInputStream;
// use protobuf::Message;
use quick_protobuf::*;
use super::basic::*;
// test messages are sync
#[test]
fn test_sync() | })
.collect();
let results = threads
.into_iter()
.map(|t| t.join().unwrap())
.collect::<Vec<_>>();
assert_eq!(&[Some(23), Some(23), Some(23), Some(23)], &results[..]);
}
| {
let m = Arc::new({
let mut r = TestTypesSingular::default();
r.int32_field = Some(23);
r
});
let threads: Vec<_> = (0..4)
.map(|_| {
let m_copy = m.clone();
thread::spawn(move || {
let mut bytes = Vec::new();
{
... | identifier_body |
test_sync.rs | use std::sync::Arc;
use std::thread;
// use protobuf::CodedInputStream;
// use protobuf::Message;
use quick_protobuf::*;
use super::basic::*;
// test messages are sync
#[test]
fn | () {
let m = Arc::new({
let mut r = TestTypesSingular::default();
r.int32_field = Some(23);
r
});
let threads: Vec<_> = (0..4)
.map(|_| {
let m_copy = m.clone();
thread::spawn(move || {
let mut bytes = Vec::new();
{
... | test_sync | identifier_name |
test_sync.rs | use std::sync::Arc;
use std::thread;
// use protobuf::CodedInputStream;
// use protobuf::Message;
use quick_protobuf::*;
use super::basic::*;
// test messages are sync
#[test]
fn test_sync() {
let m = Arc::new({
let mut r = TestTypesSingular::default();
r.int32_field = Some(23);
r
});... | let mut reader = BytesReader::from_bytes(&bytes);
let read = TestTypesSingular::from_reader(&mut reader, &bytes).unwrap();
read.int32_field
})
})
.collect();
let results = threads
.into_iter()
.map(|t| t.join().unwrap())
... | {
let mut writer = Writer::new(&mut bytes);
m_copy.write_message(&mut writer).unwrap();
} | random_line_split |
boost_query.rs | use crate::fastfield::AliveBitSet;
use crate::query::explanation::does_not_match;
use crate::query::{Explanation, Query, Scorer, Weight};
use crate::{DocId, DocSet, Score, Searcher, SegmentReader, Term};
use std::collections::BTreeMap;
use std::fmt;
/// `BoostQuery` is a wrapper over a query used to boost its score.
/... | }
fn query_terms(&self, terms: &mut BTreeMap<Term, bool>) {
self.query.query_terms(terms)
}
}
pub(crate) struct BoostWeight {
weight: Box<dyn Weight>,
boost: Score,
}
impl BoostWeight {
pub fn new(weight: Box<dyn Weight>, boost: Score) -> Self {
BoostWeight { weight, boost }
... | } else {
weight_without_boost
};
Ok(boosted_weight) | random_line_split |
boost_query.rs | use crate::fastfield::AliveBitSet;
use crate::query::explanation::does_not_match;
use crate::query::{Explanation, Query, Scorer, Weight};
use crate::{DocId, DocSet, Score, Searcher, SegmentReader, Term};
use std::collections::BTreeMap;
use std::fmt;
/// `BoostQuery` is a wrapper over a query used to boost its score.
/... |
let mut explanation =
Explanation::new(format!("Boost x{} of...", self.boost), scorer.score());
let underlying_explanation = self.weight.explain(reader, doc)?;
explanation.add_detail(underlying_explanation);
Ok(explanation)
}
fn count(&self, reader: &SegmentReader) ... | {
return Err(does_not_match(doc));
} | conditional_block |
boost_query.rs | use crate::fastfield::AliveBitSet;
use crate::query::explanation::does_not_match;
use crate::query::{Explanation, Query, Scorer, Weight};
use crate::{DocId, DocSet, Score, Searcher, SegmentReader, Term};
use std::collections::BTreeMap;
use std::fmt;
/// `BoostQuery` is a wrapper over a query used to boost its score.
/... |
fn size_hint(&self) -> u32 {
self.underlying.size_hint()
}
fn count(&mut self, alive_bitset: &AliveBitSet) -> u32 {
self.underlying.count(alive_bitset)
}
fn count_including_deleted(&mut self) -> u32 {
self.underlying.count_including_deleted()
}
}
impl<S: Scorer> Scor... | {
self.underlying.doc()
} | identifier_body |
boost_query.rs | use crate::fastfield::AliveBitSet;
use crate::query::explanation::does_not_match;
use crate::query::{Explanation, Query, Scorer, Weight};
use crate::{DocId, DocSet, Score, Searcher, SegmentReader, Term};
use std::collections::BTreeMap;
use std::fmt;
/// `BoostQuery` is a wrapper over a query used to boost its score.
/... | (&mut self) -> DocId {
self.underlying.advance()
}
fn seek(&mut self, target: DocId) -> DocId {
self.underlying.seek(target)
}
fn fill_buffer(&mut self, buffer: &mut [DocId]) -> usize {
self.underlying.fill_buffer(buffer)
}
fn doc(&self) -> u32 {
self.underlyin... | advance | identifier_name |
comparator.rs | #[cfg(test)]
mod comparator {
use libc::c_char;
use utils::{tmpdir, db_put_simple};
use leveldb::database::{Database};
use leveldb::iterator::Iterable;
use leveldb::options::{Options,ReadOptions};
use leveldb::comparator::{Comparator,OrdComparator};
use std::cmp::Ordering;
struct ReverseComparator {}... | }
fn compare(&self, a: &[u8], b: &[u8]) -> Ordering {
b.cmp(a)
}
}
#[test]
fn test_comparator() {
let comparator: ReverseComparator = ReverseComparator {};
let mut opts = Options::new();
opts.create_if_missing = true;
let tmp = tmpdir("reverse_comparator");
let database =... |
fn name(&self) -> *const c_char {
"reverse".as_ptr() as *const c_char | random_line_split |
comparator.rs | #[cfg(test)]
mod comparator {
use libc::c_char;
use utils::{tmpdir, db_put_simple};
use leveldb::database::{Database};
use leveldb::iterator::Iterable;
use leveldb::options::{Options,ReadOptions};
use leveldb::comparator::{Comparator,OrdComparator};
use std::cmp::Ordering;
struct ReverseComparator {}... | () {
let comparator: ReverseComparator = ReverseComparator {};
let mut opts = Options::new();
opts.create_if_missing = true;
let tmp = tmpdir("reverse_comparator");
let database = &mut Database::open_with_comparator(tmp.path(), opts, comparator).unwrap();
db_put_simple(database, b"1", &[1]);
... | test_comparator | identifier_name |
manticore_protocol_spdm_GetVersion__req_to_wire.rs | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | //!! DO NOT EDIT!!
// To regenerate this file, run `fuzz/generate_proto_tests.py`.
#![no_main]
#![allow(non_snake_case)]
use libfuzzer_sys::fuzz_target;
use manticore::protocol::Command;
use manticore::protocol::wire::ToWire;
use manticore::protocol::borrowed::AsStatic;
use manticore::protocol::borrowed::Borrowed;
... | // SPDX-License-Identifier: Apache-2.0
| random_line_split |
loader.rs |
use collections::{HashMap, HashSet};
use flate;
use time;
pub static MACOS_DLL_PREFIX: &'static str = "lib";
pub static MACOS_DLL_SUFFIX: &'static str = ".dylib";
pub static WIN32_DLL_PREFIX: &'static str = "";
pub static WIN32_DLL_SUFFIX: &'static str = ".dll";
pub static LINUX_DLL_PREFIX: &'static str = "lib";
pu... | random_line_split | ||
loader.rs | (&None, &None) => vec!(),
(&Some(ref p), &None) |
(&None, &Some(ref p)) => vec!(p.clone()),
(&Some(ref p1), &Some(ref p2)) => vec!(p1.clone(), p2.clone()),
}
}
}
impl<'a> Context<'a> {
pub fn maybe_load_library_crate(&mut self) -> Opt... |
}
let data = lib.metadata.as_slice();
let crate_id = decoder::get_crate_id(data);
note_crateid_attr(self.sess.diagnostic(), &crate_id);
}
None
}
}
}
// Attempts to match the requ... | {} | conditional_block |
loader.rs | {
pub ident: ~str,
pub dylib: Option<Path>,
pub rlib: Option<Path>
}
impl CratePaths {
fn paths(&self) -> Vec<Path> {
match (&self.dylib, &self.rlib) {
(&None, &None) => vec!(),
(&Some(ref p), &None) |
(&None, &Some(ref p)) => vec!(p... | CratePaths | identifier_name | |
loader.rs |
}
impl<'a> Context<'a> {
pub fn maybe_load_library_crate(&mut self) -> Option<Library> {
self.find_library_crate()
}
pub fn load_library_crate(&mut self) -> Library {
match self.find_library_crate() {
Some(t) => t,
None => {
self.report_load_errs();... | {
match (&self.dylib, &self.rlib) {
(&None, &None) => vec!(),
(&Some(ref p), &None) |
(&None, &Some(ref p)) => vec!(p.clone()),
(&Some(ref p1), &Some(ref p2)) => vec!(p1.clone(), p2.clone()),
}
} | identifier_body | |
generic_type_does_not_live_long_enough.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | } | random_line_split | |
generic_type_does_not_live_long_enough.rs | // Copyright 2018 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 ... |
existential type WrongGeneric<T>:'static;
//~^ ERROR the parameter type `T` may not live long enough
fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
t
}
| {
let y = 42;
let x = wrong_generic(&y);
let z: i32 = x; //~ ERROR mismatched types
} | identifier_body |
generic_type_does_not_live_long_enough.rs | // Copyright 2018 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 y = 42;
let x = wrong_generic(&y);
let z: i32 = x; //~ ERROR mismatched types
}
existential type WrongGeneric<T>:'static;
//~^ ERROR the parameter type `T` may not live long enough
fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
t
}
| main | identifier_name |
sectionalize_pass.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn should_not_create_sections_from_indented_headers() {
let doc = mk_doc(
~"#[doc = \"\n\
Text\n # Header\n\
Body\"]\
mod a {
}");
assert!(doc.cratemod().mods()[0].item.sections.is_empty());
}
#[test]
fn should_remove_sec... | }");
assert!(doc.cratemod().mods()[0].item.sections[0].body.contains("Body"));
}
#[test] | random_line_split |
sectionalize_pass.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn fold_trait(fold: &fold::Fold<()>, doc: doc::TraitDoc) -> doc::TraitDoc {
let doc = fold::default_seq_fold_trait(fold, doc);
doc::TraitDoc {
methods: do doc.methods.map |method| {
let (desc, sections) = sectionalize(copy method.desc);
doc::MethodDoc {
desc: ... | {
let doc = fold::default_seq_fold_item(fold, doc);
let (desc, sections) = sectionalize(copy doc.desc);
doc::ItemDoc {
desc: desc,
sections: sections,
.. doc
}
} | identifier_body |
sectionalize_pass.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 ... | (desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
/*!
* Take a description of the form
*
* General text
*
* # Section header
*
* Section text
*
* # Section header
*
* Section text
*
* and remove each header and accompanyin... | sectionalize | identifier_name |
sectionalize_pass.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 ... |
(new_desc, sections)
}
fn parse_header<'a>(line: &'a str) -> Option<&'a str> {
if line.starts_with("# ") {
Some(line.slice_from(2))
} else {
None
}
}
#[cfg(test)]
mod test {
use astsrv;
use attr_pass;
use doc;
use extract;
use prune_hidden_pass;
use section... | {
sections.push(current_section.unwrap());
} | conditional_block |
sepcomp-unwind.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 ... | () -> usize { 0 }
mod a {
pub fn f() {
panic!();
}
}
mod b {
pub fn g() {
::a::f();
}
}
fn main() {
thread::spawn(move|| { ::b::g() }).join().err().unwrap();
}
| pad | identifier_name |
sepcomp-unwind.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn main() {
thread::spawn(move|| { ::b::g() }).join().err().unwrap();
} | random_line_split | |
sepcomp-unwind.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 ... | {
thread::spawn(move|| { ::b::g() }).join().err().unwrap();
} | identifier_body | |
storageevent.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::StorageEventBinding;
use dom::bindings::codegen::Bindings::StorageEventBindi... | use util::str::DOMString;
#[dom_struct]
pub struct StorageEvent {
event: Event,
key: Option<DOMString>,
oldValue: Option<DOMString>,
newValue: Option<DOMString>,
url: DOMString,
storageArea: MutNullableHeap<JS<Storage>>
}
impl StorageEvent {
pub fn new_inherited(key: Option<DOMString>,
... | random_line_split | |
storageevent.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::StorageEventBinding;
use dom::bindings::codegen::Bindings::StorageEventBindi... | (&self) -> Option<DOMString> {
self.newValue.clone()
}
// https://html.spec.whatwg.org/multipage/#dom-storageevent-url
fn Url(&self) -> DOMString {
self.url.clone()
}
// https://html.spec.whatwg.org/multipage/#dom-storageevent-storagearea
fn GetStorageArea(&self) -> Option<Root... | GetNewValue | identifier_name |
storageevent.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::StorageEventBinding;
use dom::bindings::codegen::Bindings::StorageEventBindi... | ;
let cancelable = if init.parent.cancelable {
EventCancelable::Cancelable
} else {
EventCancelable::NotCancelable
};
let event = StorageEvent::new(global, Atom::from(&*type_),
bubbles, cancelable,
... | { EventBubbles::DoesNotBubble } | conditional_block |
storageevent.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::StorageEventBinding;
use dom::bindings::codegen::Bindings::StorageEventBindi... |
// https://html.spec.whatwg.org/multipage/#dom-storageevent-storagearea
fn GetStorageArea(&self) -> Option<Root<Storage>> {
self.storageArea.get()
}
}
| {
self.url.clone()
} | identifier_body |
task-perf-spawnalot.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () { }
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"400"]
} else if args.len() <= 1u {
~[~"", ~"10"]
} else {
args
};
let n = uint::from_str(args[1]).get();
let mut i = 0u;
while i < n { task::spawn(|| f(n) ); i ... | g | identifier_name |
task-perf-spawnalot.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | else if args.len() <= 1u {
~[~"", ~"10"]
} else {
args
};
let n = uint::from_str(args[1]).get();
let mut i = 0u;
while i < n { task::spawn(|| f(n) ); i += 1u; }
}
| {
~[~"", ~"400"]
} | conditional_block |
task-perf-spawnalot.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os;
use std::task;
use std::uint;
fn f(n: uint) {
let mut i = 0u;
while i < n {
task::try(|| g() );
i += 1u;
}
}
fn g() { }
fn main() {
let args = os::args();
let args = ... | // http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
task-perf-spawnalot.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"400"]
} else if args.len() <= 1u {
~[~"", ~"10"]
} else {
args
};
let n = uint::from_str(args[1]).get();
let mut i = 0u;
while i < n { task::spawn(|| f(n) ); i += 1u;... | { } | identifier_body |
archive.rs | use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
use std::io::{Seek, SeekFrom};
use std::mem;
use std::path::Path;
use std::path::PathBuf;
use std::slice;
use std::vec::Vec;
use std::result::Result as StdResult;
use common::ReadExt;
use meta::WadMetadata;
use types::{WadLu... |
}
// Read metadata.
let meta = try!(WadMetadata::from_file(meta_path));
Ok(Archive {
meta: meta,
file: RefCell::new(file),
lumps: lumps,
index_map: index_map,
levels: levels,
path: wad_path,
})
}
... | {
assert!(i_lump > 0);
levels.push((i_lump - 1) as usize);
} | conditional_block |
archive.rs | use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
use std::io::{Seek, SeekFrom};
use std::mem;
use std::path::Path;
use std::path::PathBuf;
use std::slice;
use std::vec::Vec;
use std::result::Result as StdResult;
use common::ReadExt;
use meta::WadMetadata;
use types::{WadLu... |
pub fn read_named_lump<T: Copy>(&self, name: &WadName) -> Option<Result<Vec<T>>> {
self.named_lump_index(name).map(|index| self.read_lump(index))
}
pub fn read_lump<T: Copy>(&self, index: usize) -> Result<Vec<T>> {
let mut file = self.file.borrow_mut();
let info = self.lumps[index... | {
self.read_named_lump(name)
.unwrap_or_else(|| Err(MissingRequiredLump(*name).in_archive(self)))
} | identifier_body |
archive.rs | use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
use std::io::{Seek, SeekFrom};
use std::mem;
use std::path::Path;
use std::path::PathBuf;
use std::slice;
use std::vec::Vec;
use std::result::Result as StdResult;
use common::ReadExt;
use meta::WadMetadata;
use types::{WadLu... | levels: levels,
path: wad_path,
})
}
pub fn num_levels(&self) -> usize { self.levels.len() }
pub fn level_lump_index(&self, level_index: usize) -> usize {
self.levels[level_index]
}
pub fn level_name(&self, level_index: usize) -> &WadName {
self.lum... | meta: meta,
file: RefCell::new(file),
lumps: lumps,
index_map: index_map, | random_line_split |
archive.rs | use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
use std::io::{Seek, SeekFrom};
use std::mem;
use std::path::Path;
use std::path::PathBuf;
use std::slice;
use std::vec::Vec;
use std::result::Result as StdResult;
use common::ReadExt;
use meta::WadMetadata;
use types::{WadLu... | (&self, level_index: usize) -> usize {
self.levels[level_index]
}
pub fn level_name(&self, level_index: usize) -> &WadName {
self.lump_name(self.levels[level_index])
}
pub fn num_lumps(&self) -> usize { self.lumps.len() }
pub fn named_lump_index(&self, name: &WadName) -> Option<us... | level_lump_index | identifier_name |
issue-19340-1.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 ... | // pretty-expanded FIXME #23616
extern crate issue_19340_1 as lib;
use lib::Homura;
fn main() {
let homura = Homura::Madoka { name: "Kaname".to_string() };
match homura {
Homura::Madoka { name } => (),
};
} | // aux-build:issue-19340-1.rs
| random_line_split |
issue-19340-1.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 homura = Homura::Madoka { name: "Kaname".to_string() };
match homura {
Homura::Madoka { name } => (),
};
} | identifier_body | |
issue-19340-1.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 homura = Homura::Madoka { name: "Kaname".to_string() };
match homura {
Homura::Madoka { name } => (),
};
}
| main | identifier_name |
element_wrapper.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/. */
//! A wrapper over an element and a snapshot, that allows us to selector-match
//! against a past state of the ele... |
fn next_sibling_element(&self) -> Option<Self> {
self.element.next_sibling_element()
.map(|e| ElementWrapper::new(e, self.snapshot_map))
}
#[inline]
fn is_html_element_in_html_document(&self) -> bool {
self.element.is_html_element_in_html_document()
}
#[inline]
... | {
self.element.prev_sibling_element()
.map(|e| ElementWrapper::new(e, self.snapshot_map))
} | identifier_body |
element_wrapper.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/. */
//! A wrapper over an element and a snapshot, that allows us to selector-match
//! against a past state of the ele... | (&self) -> Option<Self> {
self.element.last_child_element()
.map(|e| ElementWrapper::new(e, self.snapshot_map))
}
fn prev_sibling_element(&self) -> Option<Self> {
self.element.prev_sibling_element()
.map(|e| ElementWrapper::new(e, self.snapshot_map))
}
fn next_sib... | last_child_element | identifier_name |
element_wrapper.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/. */
//! A wrapper over an element and a snapshot, that allows us to selector-match
//! against a past state of the ele... | return Some(s);
}
let snapshot = self.snapshot_map.get(&self.element);
debug_assert!(snapshot.is_some(), "has_snapshot lied!");
self.cached_snapshot.set(snapshot);
snapshot
}
/// Returns the states that have changed since the element was snapshotted.
p... | if let Some(s) = self.cached_snapshot.get() { | random_line_split |
lib.rs | #![deny(missing_debug_implementations)]
use janus_plugin_sys as ffi;
use bitflags::bitflags;
pub use debug::LogLevel;
pub use debug::log;
pub use jansson::{JanssonDecodingFlags, JanssonEncodingFlags, JanssonValue, RawJanssonValue};
pub use session::SessionWrapper;
pub use ffi::events::janus_eventhandler as EventHandle... | (val: i32) -> JanusResult {
match val {
0 => Ok(()),
e => Err(JanusError { code: e })
}
}
}
impl Error for JanusError {}
impl fmt::Display for JanusError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} (code: {})", self.to_cstr().to_str().... | from | identifier_name |
lib.rs | #![deny(missing_debug_implementations)]
use janus_plugin_sys as ffi;
use bitflags::bitflags;
pub use debug::LogLevel;
pub use debug::log;
pub use jansson::{JanssonDecodingFlags, JanssonEncodingFlags, JanssonValue, RawJanssonValue};
pub use session::SessionWrapper;
pub use ffi::events::janus_eventhandler as EventHandle... |
}
impl Deref for PluginResult {
type Target = RawPluginResult;
fn deref(&self) -> &RawPluginResult {
unsafe { &*self.ptr }
}
}
impl Drop for PluginResult {
fn drop(&mut self) {
unsafe { ffi::plugin::janus_plugin_result_destroy(self.ptr) }
}
}
unsafe impl Send for PluginResult {}... | {
let ptr = self.ptr;
mem::forget(self);
ptr
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.