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 |
|---|---|---|---|---|
requested_path.rs | use iron::Request;
use std::path::{PathBuf, Path};
use std::fs::{self, Metadata};
use std::convert::AsRef;
pub struct | {
pub path: PathBuf,
}
impl RequestedPath {
pub fn new<P: AsRef<Path>>(root_path: P, request: &Request) -> RequestedPath {
let mut path = root_path.as_ref().to_path_buf();
path.extend(&request.url.path);
RequestedPath { path: path }
}
pub fn should_redirect(&self, metadata: ... | RequestedPath | identifier_name |
requested_path.rs | use iron::Request;
use std::path::{PathBuf, Path};
use std::fs::{self, Metadata};
use std::convert::AsRef;
pub struct RequestedPath {
pub path: PathBuf,
}
impl RequestedPath {
pub fn new<P: AsRef<Path>>(root_path: P, request: &Request) -> RequestedPath {
let mut path = root_path.as_ref().to_path_buf()... |
let index_path = self.path.join("index.html");
match fs::metadata(&index_path) {
Ok(m) =>
if m.is_file() {
Some(index_path)
} else {
None
},
Err(_) => None,
}
}
}
| {
return Some(self.path);
} | conditional_block |
requested_path.rs | use iron::Request;
use std::path::{PathBuf, Path};
use std::fs::{self, Metadata};
use std::convert::AsRef;
pub struct RequestedPath {
pub path: PathBuf,
}
impl RequestedPath {
pub fn new<P: AsRef<Path>>(root_path: P, request: &Request) -> RequestedPath {
let mut path = root_path.as_ref().to_path_buf()... |
pub fn get_file(self, metadata: &Metadata) -> Option<PathBuf> {
if metadata.is_file() {
return Some(self.path);
}
let index_path = self.path.join("index.html");
match fs::metadata(&index_path) {
Ok(m) =>
if m.is_file() {
... | {
let last_url_element = request.url.path
.last()
.map(|s| s.as_ref());
// As per servo/rust-url/serialize_path, URLs ending in a slash have an
// empty string stored as the last component of their path. Rust-url
// even ensures that url.path is non-empty by appe... | identifier_body |
borrowck-borrow-overloaded-deref.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 ... | {} | identifier_body | |
borrowck-borrow-overloaded-deref.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 ... | <'a>(x: &'a Rc<isize>) -> &'a mut isize {
&mut **x //~ ERROR cannot borrow
}
fn deref_extend_mut2<'a>(x: &'a mut Rc<isize>) -> &'a mut isize {
&mut **x //~ ERROR cannot borrow
}
fn assign1<'a>(x: Rc<isize>) {
*x = 3; //~ ERROR cannot assign
}
fn assign2<'a>(x: &'a Rc<isize>) {
**x = 3; //~ ERROR cann... | deref_extend_mut1 | identifier_name |
borrowck-borrow-overloaded-deref.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn deref_imm(x: Rc<isize>) {
let __isize = &*x;
}
fn deref_mut1(x: Rc<isize>) {
let __isize = &mut *x; //~ ERROR cannot borrow
}
fn deref_mut2(mut x: Rc<isize>) {
let __isize = &mut *x; //~ ERROR cannot borrow
}
fn deref_extend<'a>(x: &'a Rc<isize>) -> &'a isize {
&**x
}
fn deref_extend_mut1<'a>(x:... | unsafe { &*self.value }
}
} | random_line_split |
http.rs | /* Copyright 2015 Virgil Dupras
*
* This software is licensed under the "LGPLv3" License as described in the "LICENSE" file,
* which should be included with this package. The terms are also available at
* http://www.gnu.org/licenses/lgpl-3.0.html
*/
use rustc_serialize::{json, base64};
use rustc_serialize::base64... | result.access_token
}
| {
let auth_pair = format!("{}:{}", appid, appsecret);
let http_auth_hash = auth_pair.into_bytes()[..].to_base64(base64::Config {
char_set: base64::CharacterSet::Standard,
newline: base64::Newline::LF,
pad: false,
line_length: None,
});
#[derive(RustcDecodable)]
struct... | identifier_body |
http.rs | /* Copyright 2015 Virgil Dupras
*
* This software is licensed under the "LGPLv3" License as described in the "LICENSE" file,
* which should be included with this package. The terms are also available at
* http://www.gnu.org/licenses/lgpl-3.0.html
*/
use rustc_serialize::{json, base64};
use rustc_serialize::base64... | let result: Response = json::decode(&body).unwrap();
result.access_token
} | random_line_split | |
http.rs | /* Copyright 2015 Virgil Dupras
*
* This software is licensed under the "LGPLv3" License as described in the "LICENSE" file,
* which should be included with this package. The terms are also available at
* http://www.gnu.org/licenses/lgpl-3.0.html
*/
use rustc_serialize::{json, base64};
use rustc_serialize::base64... | {
access_token: String,
}
let postdata = format!("grant_type=password&username={}&password={}", username, password);
let resp = curl::http::handle().
post("https://www.reddit.com/api/v1/access_token", &postdata[..]).
header("Content-Type", "application/x-www-form-urlencoded").
... | Response | identifier_name |
bytestring.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::ffi::OsString;
use std::fmt::Write;
use std::path::PathBuf;
| /// The purpose of this encoding is to represent bytestrings with an arbitrary
/// encoding.
///
/// In practice, as used by watchman, bytestrings have the filesystem encoding
/// on posix systems (which is usually utf8 on linux, guaranteed utf8 on macos)
/// and when they appear as file names in file results are guara... | /// The ByteString type represents values encoded using BSER_BYTESTRING. | random_line_split |
bytestring.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::ffi::OsString;
use std::fmt::Write;
use std::path::PathBuf;
/// The ByteString type represents values encoded using BSE... |
}
}
}
output
}
}
/// Guaranteed conversion from an owned byte vector to a ByteString
impl From<Vec<u8>> for ByteString {
fn from(vec: Vec<u8>) -> Self {
Self(vec)
}
}
/// Guaranteed conversion from a UTF-8 string to a ByteString
impl From<String> for B... | {
break;
} | conditional_block |
bytestring.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::ffi::OsString;
use std::fmt::Write;
use std::path::PathBuf;
/// The ByteString type represents values encoded using BSE... |
}
/// Guaranteed conversion from a UTF-8 string to a ByteString
impl From<String> for ByteString {
fn from(s: String) -> Self {
Self(s.into_bytes())
}
}
impl From<&str> for ByteString {
fn from(s: &str) -> Self {
Self(s.as_bytes().to_vec())
}
}
/// Attempt to convert a ByteString int... | {
Self(vec)
} | identifier_body |
bytestring.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::ffi::OsString;
use std::fmt::Write;
use std::path::PathBuf;
/// The ByteString type represents values encoded using BSE... | (&self) -> &[u8] {
&self.0
}
}
impl std::ops::DerefMut for ByteString {
fn deref_mut(&mut self) -> &mut [u8] {
&mut self.0
}
}
impl ByteString {
/// Returns the raw bytes as a slice
pub fn as_bytes(&self) -> &[u8] {
self.0.as_slice()
}
/// Returns a version of the ... | deref | identifier_name |
ptr.rs | //! The AST pointer.
//!
//! Provides `P<T>`, a frozen owned smart pointer.
//!
//! # Motivations and benefits
//!
//! * **Identity**: sharing AST nodes is problematic for the various analysis
//! passes (e.g., one may be able to bypass the borrow checker with a shared
//! `ExprKind::AddrOf` node taking a mutable b... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Debug::fmt(&self.ptr, f)
}
}
impl<T: Display> Display for P<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt(&**self, f)
}
}
impl<T> fmt::Pointer for P<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt... | fmt | identifier_name |
ptr.rs | //! The AST pointer.
//!
//! Provides `P<T>`, a frozen owned smart pointer.
//!
//! # Motivations and benefits
//!
//! * **Identity**: sharing AST nodes is problematic for the various analysis
//! passes (e.g., one may be able to bypass the borrow checker with a shared
//! `ExprKind::AddrOf` node taking a mutable b... | }
impl<T:?Sized> DerefMut for P<T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.ptr
}
}
impl<T:'static + Clone> Clone for P<T> {
fn clone(&self) -> P<T> {
P((**self).clone())
}
}
impl<T:?Sized + Debug> Debug for P<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
... | &self.ptr
} | random_line_split |
ptr.rs | //! The AST pointer.
//!
//! Provides `P<T>`, a frozen owned smart pointer.
//!
//! # Motivations and benefits
//!
//! * **Identity**: sharing AST nodes is problematic for the various analysis
//! passes (e.g., one may be able to bypass the borrow checker with a shared
//! `ExprKind::AddrOf` node taking a mutable b... |
}
impl<T:?Sized> Deref for P<T> {
type Target = T;
fn deref(&self) -> &T {
&self.ptr
}
}
impl<T:?Sized> DerefMut for P<T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.ptr
}
}
impl<T:'static + Clone> Clone for P<T> {
fn clone(&self) -> P<T> {
P((**self).clone())
... | {
*self.ptr = f(*self.ptr)?;
Some(self)
} | identifier_body |
number.rs | use core::*;
use lexer::*;
use util::*;
#[derive(Debug)]
pub struct ZeroScanner;
impl Scanner for ZeroScanner {
fn scan(&self, state: State, c: u8) -> ScanResult |
fn return_token(&self, _state: State, token_string: String) -> Option<Tokn> {
Some(Tokn::Nmbr(token_string))
}
}
#[derive(Debug)]
pub struct IntegerScanner;
impl Scanner for IntegerScanner {
fn scan(&self, state: State, c: u8) -> ScanResult {
match state {
State::Normal => {
... | {
if state == State::Normal && c == b'0' {
push_into_mode!(ZeroNumber)
} else if state == State::ZeroNumber {
match c {
0 => finish!(),
_ if is_whitespace(c) => finish!(),
_ if is_token_end_delimiter(c) => delimite!(),
... | identifier_body |
number.rs | use core::*;
use lexer::*;
use util::*;
#[derive(Debug)]
pub struct ZeroScanner;
impl Scanner for ZeroScanner {
fn scan(&self, state: State, c: u8) -> ScanResult {
if state == State::Normal && c == b'0' {
push_into_mode!(ZeroNumber)
} else if state == State::ZeroNumber {
ma... | pub struct IntegerScanner;
impl Scanner for IntegerScanner {
fn scan(&self, state: State, c: u8) -> ScanResult {
match state {
State::Normal => {
if c == b'-' || (c >= b'1' && c <= b'9') {
push_into_mode!(InnerNumber)
} else {
... | }
#[derive(Debug)] | random_line_split |
number.rs | use core::*;
use lexer::*;
use util::*;
#[derive(Debug)]
pub struct ZeroScanner;
impl Scanner for ZeroScanner {
fn scan(&self, state: State, c: u8) -> ScanResult {
if state == State::Normal && c == b'0' {
push_into_mode!(ZeroNumber)
} else if state == State::ZeroNumber {
ma... | () {
let scanners: &mut Vec<&Scanner> = &mut vec![&ZeroScanner, &IntegerScanner];
lex_from_str("12", "Nmbr<12>", scanners);
}
| multiple_digits_integer | identifier_name |
util.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 ... |
#[cfg(unix)]
pub fn wouldblock() -> bool {
let err = os::errno();
err == libc::EWOULDBLOCK as int || err == libc::EAGAIN as int
}
#[cfg(windows)]
pub fn wouldblock() -> bool {
let err = os::errno();
err == libc::WSAEWOULDBLOCK as uint
}
#[cfg(unix)]
pub fn set_nonblocking(fd: net::sock_t, nb: bool) ... | {
libc::timeval {
tv_sec: (ms / 1000) as libc::time_t,
tv_usec: ((ms % 1000) * 1000) as libc::suseconds_t,
}
} | identifier_body |
util.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 ... | Err(last_error())
} else {
Ok(())
}
}
// See http://developerweb.net/viewtopic.php?id=3196 for where this is
// derived from.
pub fn connect_timeout(fd: net::sock_t,
addrp: *libc::sockaddr,
len: libc::socklen_t,
timeout_ms: u6... | pub fn set_nonblocking(fd: net::sock_t, nb: bool) -> IoResult<()> {
let mut set = nb as libc::c_ulong;
if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) != 0 } { | random_line_split |
util.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 ... | () -> bool {
let err = os::errno();
err == libc::WSAEWOULDBLOCK as uint
}
#[cfg(unix)]
pub fn set_nonblocking(fd: net::sock_t, nb: bool) -> IoResult<()> {
let set = nb as libc::c_int;
super::mkerr_libc(retry(|| unsafe { c::ioctl(fd, c::FIONBIO, &set) }))
}
#[cfg(windows)]
pub fn set_nonblocking(fd: ne... | wouldblock | identifier_name |
test.rs | #[macro_use]
extern crate nix;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate rand;
extern crate tempdir;
extern crate tempfile;
extern crate nix_test as nixtest;
mod sys;
mod test_fcntl;
#[cfg(target_os = "linux")]
mod test_mq;
mod test_net;
mod test_nix_path;
#[cfg(any(target_os = "linux", t... | {
// This test is mostly here to ensure that 32bit CI is correctly
// functioning
assert_size_of::<usize>("long");
} | identifier_body | |
test.rs | #[macro_use]
extern crate nix;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate rand;
extern crate tempdir;
extern crate tempfile;
extern crate nix_test as nixtest;
mod sys;
mod test_fcntl;
#[cfg(target_os = "linux")]
mod test_mq;
mod test_net;
mod test_nix_path;
#[cfg(any(target_os = "linux", t... | () {
// This test is mostly here to ensure that 32bit CI is correctly
// functioning
assert_size_of::<usize>("long");
}
| test_size_of_long | identifier_name |
test.rs | #[macro_use]
extern crate nix;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate rand;
extern crate tempdir;
extern crate tempfile;
extern crate nix_test as nixtest;
mod sys;
mod test_fcntl;
#[cfg(target_os = "linux")]
mod test_mq;
mod test_net;
mod test_nix_path;
#[cfg(any(target_os = "linux", t... | // This test is mostly here to ensure that 32bit CI is correctly
// functioning
assert_size_of::<usize>("long");
} | random_line_split | |
chown.rs | extern crate arg_parser;
extern crate extra;
extern crate syscall;
use std::env;
use std::io::{self, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{chown} */ r#"
NAME
chown - set user and/or group ownership of a file
SYNOPSIS... |
fn main() {
let stdout = io::stdout();
let mut stdout = stdout.lock();
let mut stderr = io::stderr();
let mut parser = ArgParser::new(1)
.add_flag(&["h", "help"]);
parser.parse(env::args());
if parser.found("help") {
stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr);
... | {
let fd = syscall::open(path, syscall::O_STAT)?;
let res = syscall::fchown(fd, uid, gid);
let _ = syscall::close(fd);
res
} | identifier_body |
chown.rs | extern crate arg_parser;
extern crate extra;
extern crate syscall;
use std::env;
use std::io::{self, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{chown} */ r#"
NAME
chown - set user and/or group ownership of a file
SYNOPSIS... | let _ = syscall::close(fd);
res
}
fn main() {
let stdout = io::stdout();
let mut stdout = stdout.lock();
let mut stderr = io::stderr();
let mut parser = ArgParser::new(1)
.add_flag(&["h", "help"]);
parser.parse(env::args());
if parser.found("help") {
stdout.write(MAN... | let res = syscall::fchown(fd, uid, gid); | random_line_split |
chown.rs | extern crate arg_parser;
extern crate extra;
extern crate syscall;
use std::env;
use std::io::{self, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{chown} */ r#"
NAME
chown - set user and/or group ownership of a file
SYNOPSIS... |
} else {
-1i32 as u32
};
for arg in args {
if let Err(err) = chown(arg, uid, gid) {
let _ = writeln!(stderr, "chown: failed to set uid and gid of {} to {} and {}: {}", arg, uid, gid, err);
exit(1);
}
}
} else {
... | {
match part.parse() {
Ok(id) => id,
Err(err) => {
let _ = writeln!(stderr, "chown: failed to parse gid {}: {}", part, err);
exit(1);
}
}
} | conditional_block |
chown.rs | extern crate arg_parser;
extern crate extra;
extern crate syscall;
use std::env;
use std::io::{self, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{chown} */ r#"
NAME
chown - set user and/or group ownership of a file
SYNOPSIS... | () {
let stdout = io::stdout();
let mut stdout = stdout.lock();
let mut stderr = io::stderr();
let mut parser = ArgParser::new(1)
.add_flag(&["h", "help"]);
parser.parse(env::args());
if parser.found("help") {
stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr);
stdout... | main | identifier_name |
xml.rs | /*
Copyright 2017 LambdaStack All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to i... | }
pub struct XmlErrorDeserializer;
impl XmlErrorDeserializer {
pub fn deserialize<'a, T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<XmlError, XmlParseError> {
try!(start_element(tag_name, stack));
let mut obj = XmlError::default();
loop {
match &try!(peek_at_name(stack))[..] {
"Type" => {
... | random_line_split | |
xml.rs | /*
Copyright 2017 LambdaStack All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to i... | ;
impl ErrorsParser {
#[allow(dead_code)]
#[allow(unused_variables)]
fn parse_xml<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<Errors, XmlParseError> {
let mut obj : Vec<String> = Vec::new();
while try!(peek_at_name(stack)) == "Error" {
obj.push(try!(ErrorsParser::parse_si... | ErrorsParser | identifier_name |
xml.rs | /*
Copyright 2017 LambdaStack All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to i... | try!(start_element("Detail", stack));
if let Ok(characters) = characters(stack){
obj.detail = Some(characters.to_string());
try!(end_element("Detail", stack));
}
continue;
},
_ => break
}
}
try!(end_element(tag_name, stack));
Ok(obj)
}
}
pub type Errors = Vec<String... | {
try!(start_element(tag_name, stack));
let mut obj = XmlError::default();
loop {
match &try!(peek_at_name(stack))[..] {
"Type" => {
obj.error_type = try!(string_field("Type", stack));
continue;
},
"Code" => {
obj.code = try!(string_field("Code", stack));
continue;
},
... | identifier_body |
perf.rs | //#![feature(plugin)]
//#![plugin(clippy)]
#![allow(float_cmp)]
extern crate cql_bindgen;
extern crate num;
extern crate threadpool;
use std::mem;
use std::ffi::CString;
use std::ffi::CStr;
use threadpool::ThreadPool;
use std::sync::mpsc::channel;
use cql_bindgen::*;
const NUM_THREADS:usize = 1;
const NUM_IO_WORKE... | let rc = cass_future_error_code(future);
if (rc!= CASS_OK) {
print_error(future);
} else {
let prepared = &cass_future_get_prepared(future);
}
cass_future_free(future);
return rc;
}
fn compare_dbl(d1:f64, d2:f64) -> isize {
if d1 < d2 {
return -1;
} else if d1 > d2 {
return 1;
} els... |
let future = cass_session_prepare(session, query);
cass_future_wait(future);
| random_line_split |
perf.rs | //#![feature(plugin)]
//#![plugin(clippy)]
#![allow(float_cmp)]
extern crate cql_bindgen;
extern crate num;
extern crate threadpool;
use std::mem;
use std::ffi::CString;
use std::ffi::CStr;
use threadpool::ThreadPool;
use std::sync::mpsc::channel;
use cql_bindgen::*;
const NUM_THREADS:usize = 1;
const NUM_IO_WORKE... | else if d1 > d2 {
return 1;
} else {
return 0;
}
}
fn insert_into_perf(session: &mut CassSession, query:&str, prepared:Option<CassPrepared>) {
let futures:Vec<CassFuture> = Vec::with_capacity(NUM_CONCURRENT_REQUESTS);
let collection = cass_collection_new(CASS_COLLECTION_TYPE_SET, 2);
cass_collectio... | {
return -1;
} | conditional_block |
perf.rs | //#![feature(plugin)]
//#![plugin(clippy)]
#![allow(float_cmp)]
extern crate cql_bindgen;
extern crate num;
extern crate threadpool;
use std::mem;
use std::ffi::CString;
use std::ffi::CStr;
use threadpool::ThreadPool;
use std::sync::mpsc::channel;
use cql_bindgen::*;
const NUM_THREADS:usize = 1;
const NUM_IO_WORKE... | (d1:f64, d2:f64) -> isize {
if d1 < d2 {
return -1;
} else if d1 > d2 {
return 1;
} else {
return 0;
}
}
fn insert_into_perf(session: &mut CassSession, query:&str, prepared:Option<CassPrepared>) {
let futures:Vec<CassFuture> = Vec::with_capacity(NUM_CONCURRENT_REQUESTS);
let collection = cass_... | compare_dbl | identifier_name |
svh-a-doc.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 ... | () -> int {
4
}
| an_unused_name | identifier_name |
svh-a-doc.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 ... | }
pub fn an_unused_name() -> int {
4
} | 3 | random_line_split |
svh-a-doc.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 ... | {
4
} | identifier_body | |
inputevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEventMethods};
use crate::dom::bindin... |
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.uievent.IsTrusted()
}
}
| {
self.is_composing
} | identifier_body |
inputevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEventMethods};
use crate::dom::bindin... | use crate::dom::window::Window;
use dom_struct::dom_struct;
#[dom_struct]
pub struct InputEvent {
uievent: UIEvent,
data: Option<DOMString>,
is_composing: bool,
}
impl InputEvent {
pub fn new(
window: &Window,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
... | use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::uievent::UIEvent; | random_line_split |
inputevent.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEventMethods};
use crate::dom::bindin... | (&self) -> Option<DOMString> {
self.data.clone()
}
// https://w3c.github.io/uievents/#dom-inputevent-iscomposing
fn IsComposing(&self) -> bool {
self.is_composing
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.uievent.IsTrusted(... | GetData | identifier_name |
pipe_operator.rs | # single line pipes not finished
bar = [1, 2, 3] |> Enum.uppcase
# [1, 2, 3].pipesCall(Enum.uppcase).pipesCall(Enum.uppcase).value();
# [1, 2, 3] |> Enum.uppcase |> Enum.uppcase
f = [1, 2, 3] |> Enum.uppcase(3, 2) |> Enum.uppcase
return [5, 2, 3] |> Enum.uppcase
b = bar |> Enum.uppcase
return bar |> Enum.uppcase
fo... |
res = foo
|> has_parens(10, 20)
|> map (x) => x * 2
|> map((x) => x * 2)
|> map(x => x * 2)
|> map x => x * 2 | random_line_split | |
demo.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 ... | /// The base price of a muffin on a non-holiday
static price_of_a_muffin: float = 70f;
struct WaitPerson {
hair_color: ~str
}
/// The type of things that produce omnomnom
enum OmNomNomy {
/// Delicious sugar cookies
Cookie,
/// It's pizza
PizzaPie(~[uint])
}
fn take_my_order_please(
_waitpers... | use core::prelude::*;
| random_line_split |
demo.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 ... | {
bored: bool,
}
impl Drop for Bored {
fn finalize(&self) { }
}
/**
* The Shunned House
*
* From even the greatest of horrors irony is seldom absent. Sometimes it
* enters directly into the composition of the events, while sometimes it
* relates only to their fortuitous position among persons and
* places.... | Bored | identifier_name |
lib.rs | //! # The Redox Library
//!
//! The Redox Library contains a collection of commonly used low-level software
//! constructs to be used on top of the base operating system, including graphics
//! support and windowing, a basic filesystem, audio support, a simple console
//! with shell style functions, an event system, an... | // doc pages are inlined from the public re-exports of core_collections::{slice,
// str} above.
pub use core::isize;
pub use core::i8;
pub use core::i16;
pub use core::i32;
pub use core::i64;
pub use core::usize;
pub use core::u8;
pub use core::u16;
pub use core::u32;
p... | random_line_split | |
webglobject.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use crate::dom::bindings::reflector::Reflect... |
pub fn context(&self) -> &WebGLRenderingContext {
&self.context
}
} | random_line_split | |
webglobject.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use crate::dom::bindings::reflector::Reflect... | (context: &WebGLRenderingContext) -> WebGLObject {
WebGLObject {
reflector_: Reflector::new(),
context: Dom::from_ref(context),
}
}
pub fn context(&self) -> &WebGLRenderingContext {
&self.context
}
}
| new_inherited | identifier_name |
webglobject.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use crate::dom::bindings::reflector::Reflect... |
pub fn context(&self) -> &WebGLRenderingContext {
&self.context
}
}
| {
WebGLObject {
reflector_: Reflector::new(),
context: Dom::from_ref(context),
}
} | identifier_body |
main.rs | use std::borrow::Cow::{self, Borrowed, Owned};
use std::fs::File;
use std::{env, fs};
use clap::{clap_app, crate_authors, crate_description, crate_name, crate_version, ArgMatches};
use log::error;
use log::warn;
use rustyline::completion::{Completer, FilenameCompleter, Pair};
use rustyline::config::OutputStreamType;
u... | <'b,'s: 'b, 'p: 'b>(
&'s self,
prompt: &'p str,
default: bool,
) -> Cow<'b, str> {
if default {
Borrowed(&self.colored_prompt)
} else {
Borrowed(prompt)
}
}
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> {
Owned("\... | highlight_prompt | identifier_name |
main.rs | use std::borrow::Cow::{self, Borrowed, Owned};
use std::fs::File;
use std::{env, fs};
use clap::{clap_app, crate_authors, crate_description, crate_name, crate_version, ArgMatches};
use log::error;
use log::warn;
use rustyline::completion::{Completer, FilenameCompleter, Pair};
use rustyline::config::OutputStreamType;
u... | Borrowed(prompt)
}
}
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> {
Owned("\x1b[1m".to_owned() + hint + "\x1b[m")
}
fn highlight_char(&self, line: &str, pos: usize) -> bool {
self.highlighter.highlight_char(line, pos)
}
}
/// Initializes the logg... | } else { | random_line_split |
main.rs | use std::borrow::Cow::{self, Borrowed, Owned};
use std::fs::File;
use std::{env, fs};
use clap::{clap_app, crate_authors, crate_description, crate_name, crate_version, ArgMatches};
use log::error;
use log::warn;
use rustyline::completion::{Completer, FilenameCompleter, Pair};
use rustyline::config::OutputStreamType;
u... |
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> {
Owned("\x1b[1m".to_owned() + hint + "\x1b[m")
}
fn highlight_char(&self, line: &str, pos: usize) -> bool {
self.highlighter.highlight_char(line, pos)
}
}
/// Initializes the logger using any args given.
fn setup_logger(arg... | {
if default {
Borrowed(&self.colored_prompt)
} else {
Borrowed(prompt)
}
} | identifier_body |
input.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::path::Path;
use std::mem::size_of;
use std::mem::transmute;
use std::mem::zeroed;
use std::os::errno;
use... | println!("Touch down");
last_x = slotA.x;
last_y = slotA.y;
first_x = slotA.x;
first_y = slotA.y;
if touch_count >= 2 {
... | sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseDown(0, click_pt)));
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseUp(0, click_pt)));
sender.send(WindowEvent::MouseWindowEventCla... | random_line_split |
input.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::path::Path;
use std::mem::size_of;
use std::mem::transmute;
use std::mem::zeroed;
use std::os::errno;
use... | (abs: u16) -> c_int {
ioc(IOC_READ, 'E' as c_int, (0x40 + abs) as i32, size_of::<linux_input_absinfo>() as i32)
}
const EV_SYN: u16 = 0;
const EV_ABS: u16 = 3;
const EV_REPORT: u16 = 0;
const ABS_MT_SLOT: u16 = 0x2F;
const ABS_MT_TOUCH_MAJOR: u16 = 0x30;
const ABS_MT_TOUCH_MINOR: u16 = 0x31;
const ABS_MT_WIDTH_M... | ev_ioc_g_abs | identifier_name |
input.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::path::Path;
use std::mem::size_of;
use std::mem::transmute;
use std::mem::zeroed;
use std::os::errno;
use... | if ret < 0 {
println!("Couldn't get ABS_MT_POSITION_Y info {} {}", ret, errno());
}
}
let touchWidth = xInfo.maximum - xInfo.minimum;
let touchHeight = yInfo.maximum - yInfo.minimum;
println!("xMin: {}, yMin: {}, touchWidth: {}, touchHeight: {}", xInfo.minimum, yInfo.minimu... | {
let mut device = match File::open(device_path) {
Ok(dev) => dev,
Err(e) => {
println!("Couldn't open device! {}", e);
return;
},
};
let fd = device.as_raw_fd();
let mut xInfo: linux_input_absinfo = unsafe { zeroed() };
let mut yInfo: linux_input_abs... | identifier_body |
varint.rs | use buf::{Appender, Error, GetIter, Prepender, ReadIter, SetIter};
use buf::codec::u64;
#[inline]
pub fn read(chain: &mut ReadIter) -> Result<i64, Error> {
u64::varint::read(chain).map(|v| v as i64)
}
#[inline]
pub fn get(chain: &mut GetIter) -> Result<i64, Error> |
#[inline]
pub fn set(v: i64, chain: &mut SetIter) -> Result<usize, Error> {
u64::varint::set(v as u64, chain)
}
#[inline]
pub fn append(v: i64, chain: &mut Appender) -> Result<usize, ()> {
u64::varint::append(v as u64, chain)
}
#[inline]
pub fn prepend(v: i64, chain: &mut Prepender) -> Result<usize, ()> {
... | {
u64::varint::get(chain).map(|v| v as i64)
} | identifier_body |
varint.rs | use buf::{Appender, Error, GetIter, Prepender, ReadIter, SetIter};
use buf::codec::u64;
#[inline]
pub fn read(chain: &mut ReadIter) -> Result<i64, Error> {
u64::varint::read(chain).map(|v| v as i64)
}
#[inline]
pub fn get(chain: &mut GetIter) -> Result<i64, Error> {
u64::varint::get(chain).map(|v| v as i64)
}... | } | random_line_split | |
varint.rs | use buf::{Appender, Error, GetIter, Prepender, ReadIter, SetIter};
use buf::codec::u64;
#[inline]
pub fn | (chain: &mut ReadIter) -> Result<i64, Error> {
u64::varint::read(chain).map(|v| v as i64)
}
#[inline]
pub fn get(chain: &mut GetIter) -> Result<i64, Error> {
u64::varint::get(chain).map(|v| v as i64)
}
#[inline]
pub fn set(v: i64, chain: &mut SetIter) -> Result<usize, Error> {
u64::varint::set(v as u64, c... | read | identifier_name |
combo_box_text.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | }
}
impl_drop!(ComboBoxText);
impl_TraitWidget!(ComboBoxText);
impl gtk::ContainerTrait for ComboBoxText {}
impl gtk::BinTrait for ComboBoxText {}
impl gtk::ComboBoxTrait for ComboBoxText {}
impl_widget_events!(ComboBoxText); | } | random_line_split |
combo_box_text.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | self) {
unsafe { ffi::gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(self.pointer)) }
}
pub fn get_active_text(&self) -> Option<String> {
unsafe {
FromGlibPtr::borrow(
ffi::gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(self.pointer)))
}
}
}
imp... | move_all(& | identifier_name |
combo_box_text.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | pub fn remove_all(&self) {
unsafe { ffi::gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(self.pointer)) }
}
pub fn get_active_text(&self) -> Option<String> {
unsafe {
FromGlibPtr::borrow(
ffi::gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(self.pointer)))... | unsafe { ffi::gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(self.pointer), position) }
}
| identifier_body |
command.rs | use self::SmtpInput::*;
use bytes::Bytes;
use std::fmt;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpInput {
Command(usize, usize, SmtpCommand),
Invalid(usize, usize, Bytes),
Incomplete(usize, usize, Bytes),
None(usize, usize, String),
Connect... |
}
impl fmt::Display for SmtpHost {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use self::SmtpHost::*;
match self {
&Domain(ref h) => f.write_str(h),
&Ipv4(ref h) => write!(f, "{}", h),
&Ipv6(ref h) => write!(f, "{}", h),
&Invali... | {
match self {
&SmtpPath::Direct(ref addr) => match addr {
&SmtpAddress::Mailbox(ref name, ref host) => write!(f, "<{}@{}>", name, host),
},
&SmtpPath::Null => write!(f, "<>"),
&SmtpPath::Postmaster => write!(f, "<POSTMASTER>"),
&SmtpPa... | identifier_body |
command.rs | use self::SmtpInput::*;
use bytes::Bytes;
use std::fmt;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpInput {
Command(usize, usize, SmtpCommand),
Invalid(usize, usize, Bytes),
Incomplete(usize, usize, Bytes),
None(usize, usize, String),
Connect... | Helo(SmtpHelo),
Mail(SmtpMail),
Rcpt(SmtpPath),
Expn(String),
Vrfy(String),
Help(Vec<String>),
Noop(Vec<String>),
Quit,
Rset,
Data,
Turn,
Unknown(String),
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpHost {
Domain(String),
Ipv4(Ipv4Addr),
Ipv6(Ipv6Ad... | #[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpCommand { | random_line_split |
command.rs | use self::SmtpInput::*;
use bytes::Bytes;
use std::fmt;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpInput {
Command(usize, usize, SmtpCommand),
Invalid(usize, usize, Bytes),
Incomplete(usize, usize, Bytes),
None(usize, usize, String),
Connect... | {
pub local_name: String,
pub local_addr: Option<SocketAddr>,
pub peer_addr: Option<SocketAddr>,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SmtpMail {
Mail(SmtpPath),
Send(SmtpPath),
Saml(SmtpPath),
Soml(SmtpPath),
}
impl SmtpMail {
pub fn from(&self) -> &SmtpPath {
mat... | SmtpConnection | identifier_name |
fragments.rs | {
// This represents the path described by the move path index
Just(MovePathIndex),
// This represents the collection of all but one of the elements
// from an array at the path described by the move path index.
// Note that attached MovePathIndex should have mem_categorization
// of InteriorE... | Fragment | identifier_name | |
fragments.rs | paths.len());
let find_var_id = |move_path_index: MovePathIndex| -> Option<ast::NodeId> {
let lp = move_data.path_loan_path(move_path_index);
match lp.kind {
LpVar(var_id) => Some(var_id),
LpUpvar(ty::UpvarId { var_id, closure_expr_id }) => {
// The `var_id` ... | fn add_fragment_sibling_core<'tcx>(this: &MoveData<'tcx>,
tcx: &ty::ctxt<'tcx>,
gathered_fragments: &mut Vec<Fragment>,
parent: Rc<LoanPath<'tcx>>, | random_line_split | |
fragments.rs | fn loan_path_repr(&self, move_data: &MoveData) -> String {
let lp = |mpi| move_data.path_loan_path(mpi);
match *self {
Just(mpi) => format!("{:?}", lp(mpi)),
AllButOneFrom(mpi) => format!("$(allbutone {:?})", lp(mpi)),
}
}
fn loan_path_user_string(&self, move_da... | // FIXME (pnkfelix): LV[j] should be tracked, at least in the
// sense of we will track the remaining drop obligation of the
// rest of the array.
//
// Well, either that or LV[j] should be made illegal.
// But even then, we will need to deal with destructuring
//... | {
match lp.kind {
LpVar(_) | LpUpvar(..) => {} // Local variables have no siblings.
// Consuming a downcast is like consuming the original value, so propage inward.
LpDowncast(ref loan_parent, _) => {
add_fragment_siblings(this, tcx, gathered_fragments, loan_parent.clone(), orig... | identifier_body |
lib.rs | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | //! | rust_icu_ulistformatter | icu::listformatter |
//! | rust_icu_uloc | icu::loc |
//! | rust_icu_umsg | icu::msg |
//! | rust_icu_unorm | unorm |
//! | rust_icu_ustring | icu::string |
//! | rust_icu_utext | text |
//! | rust_icu_utrans | trans |
pub use rust_icu_common as common;
pub use rust_icu_sys as sys;
pub ... | //! | rust_icu_ucal | icu::cal |
//! | rust_icu_ucol | icu::col |
//! | rust_icu_udat | icu::dat |
//! | rust_icu_udata | icu::data |
//! | rust_icu_uenum | icu::enums | | random_line_split |
issue-6157.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 ... | (&mut self, a:isize, b:isize) -> isize {
(*self)(a, b)
}
}
fn squarei<'a>(x: isize, op: &'a mut OpInt) -> isize { op.call(x, x) }
fn muli(x:isize, y:isize) -> isize { x * y }
pub fn main() {
let mut f = |x, y| muli(x, y);
{
let g = &mut f;
let h = g as &mut OpInt;
squarei(... | call | identifier_name |
issue-6157.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// pretty-expanded FIXME #23616
pub trait OpInt { fn call(&mut self, isize, isize) -> i... | // http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
issue-6157.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn muli(x:isize, y:isize) -> isize { x * y }
pub fn main() {
let mut f = |x, y| muli(x, y);
{
let g = &mut f;
let h = g as &mut OpInt;
squarei(3, h);
}
}
| { op.call(x, x) } | identifier_body |
luke_t.rs | use std::f64::consts::*;
use std::f64::*;
use std::i64;
static mut __LUKE_DEBUG: bool = false;
pub fn set_luke_debug(b: bool) { unsafe { __LUKE_DEBUG = b; } }
pub fn luke_debug() -> bool {
let mut b = false;
unsafe { b = __LUKE_DEBUG; }
return b;
}
pub fn lmax(l: f64, r: f64) -> f64 {
if l>r {
l
... | () -> (u8, u8, u8) {
return (255,192,203);
}
pub fn histogram_of_oriented_gradients(space: &Vec<usize>, screen: &mut Vec<u8>) -> (Vec<usize>, Vec<(f64,f64)>) {
if space.len()!=3 {
panic!("dimensionality unknown")
}
let width = space[0] as i64;
let height = space[1] as i64;
let depth = space[2]... | next_color | identifier_name |
luke_t.rs | use std::f64::consts::*;
use std::f64::*;
use std::i64;
static mut __LUKE_DEBUG: bool = false;
pub fn set_luke_debug(b: bool) { unsafe { __LUKE_DEBUG = b; } }
pub fn luke_debug() -> bool {
let mut b = false;
unsafe { b = __LUKE_DEBUG; }
return b;
}
pub fn lmax(l: f64, r: f64) -> f64 {
if l>r {
l
... | for _ in 0..draw.len() {
drawn.push(0.0);
}
if space.len()==3 && space[2]==3 {
let width = space[0] as i64;
let height = space[1] as i64;
for di in 0..draw.len() {
let oclock = draw[di];
let epi = epi.clone();
let ox = epi[0] as i64;
let oy = epi[1] a... | pub fn lidar(space: &Vec<usize>, screen: &mut Vec<u8>, epi: Vec<usize>, draw: Vec<f64>, threshold: i64) -> Vec<f64> {
let mut drawn = Vec::new(); | random_line_split |
luke_t.rs | use std::f64::consts::*;
use std::f64::*;
use std::i64;
static mut __LUKE_DEBUG: bool = false;
pub fn set_luke_debug(b: bool) { unsafe { __LUKE_DEBUG = b; } }
pub fn luke_debug() -> bool {
let mut b = false;
unsafe { b = __LUKE_DEBUG; }
return b;
}
pub fn lmax(l: f64, r: f64) -> f64 {
if l>r {
l
... | if x<(width-1) {
dr += ( (screen[3*(y*width + x+1)] as i64) - br).abs();
dg += ( (screen[3*(y*width + x+1)+1] as i64) - bg).abs();
db += ( (screen[3*(y*width + x+1)+2] as i64) - bb).abs();
d += 1;
}
if y>0 {
dr += ( (screen[3*((y-1)*... | {
let mut score = screen.clone();
if space.len()==3 && space[2]==3 {
let width = space[0];
let height = space[1];
for x in 0..width {
for y in 0..height {
let br = screen[3*(y*width + x)] as i64;
let bg = screen[3*(y*width + x)+1] as i64;
let bb = screen[3*(y*wid... | identifier_body |
luke_t.rs | use std::f64::consts::*;
use std::f64::*;
use std::i64;
static mut __LUKE_DEBUG: bool = false;
pub fn set_luke_debug(b: bool) { unsafe { __LUKE_DEBUG = b; } }
pub fn luke_debug() -> bool {
let mut b = false;
unsafe { b = __LUKE_DEBUG; }
return b;
}
pub fn lmax(l: f64, r: f64) -> f64 {
if l>r {
l
... |
if y>0 { vert -= (safe_space[ (width*(y-1) + x) as usize ] as f64); }
if (x+1)<width { horz += (safe_space[ (width*y + (x+1)) as usize ] as f64); }
if (y+1)<height { vert += (safe_space[ (width*(y+1) + x) as usize ] as f64); }
// convert vert/horz to rotation*magnitude
let... | { horz -= (safe_space[ (width*y + (x-1)) as usize ] as f64); } | conditional_block |
debug.rs | // c4puter embedded controller firmware
// Copyright (C) 2017 Chris Pavlina
// 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 2 of the License, or
// (at your option) any later v... |
}
false
}
impl DebugClass {
pub fn enabled(&self) -> bool
{
self.enabled.load(Ordering::SeqCst)
}
pub fn enable(&self, v: bool)
{
self.enabled.store(v, Ordering::SeqCst);
}
}
#[derive(Copy, Clone)]
pub struct Error {
pub message: &'static str,
}
impl PartialEq fo... | {
dbg.enable(enabled);
return true;
} | conditional_block |
debug.rs | // c4puter embedded controller firmware
// Copyright (C) 2017 Chris Pavlina
// 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 2 of the License, or
// (at your option) any later v... |
}
impl Eq for Error {}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
write!(f, "Error: {}", self.message)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
write!(f, "{}", self.message)
}
}
macro_rul... | {
let self_msg = self.message as *const str;
let other_msg = other.message as *const str;
self_msg == other_msg
} | identifier_body |
debug.rs | // c4puter embedded controller firmware
// Copyright (C) 2017 Chris Pavlina
// 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 2 of the License, or
// (at your option) any later v... | )*
}
}
pub type StdResult = Result<(), Error>; |
$(
#[allow(dead_code)]
pub static $name: Error = Error { message: $message }; | random_line_split |
debug.rs | // c4puter embedded controller firmware
// Copyright (C) 2017 Chris Pavlina
// 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 2 of the License, or
// (at your option) any later v... | (name: &str, enabled: bool) -> bool
{
for &dbg in messages::DEBUG_TABLE {
if *(dbg.name) == *name {
dbg.enable(enabled);
return true;
}
}
false
}
impl DebugClass {
pub fn enabled(&self) -> bool
{
self.enabled.load(Ordering::SeqCst)
}
pub fn e... | debug_set | identifier_name |
sum.rs | #![feature(test)]
extern crate test;
extern crate lilium;
use test::Bencher;
use lilium::*;
#[bench]
fn | (b: &mut Bencher) {
let Module {
functions: f,
constants: c,
entry_point: e,
code: i
} = compile(concat!(
"(def sum (a b)",
" (if ",
" (> a 0)",
" ((+ (sum (- a 1) (+ b 1)) 0))",
" ((+ b 1))))",
"(sum 900 0)"
));
... | sum | identifier_name |
sum.rs | #![feature(test)] |
#[bench]
fn sum(b: &mut Bencher) {
let Module {
functions: f,
constants: c,
entry_point: e,
code: i
} = compile(concat!(
"(def sum (a b)",
" (if ",
" (> a 0)",
" ((+ (sum (- a 1) (+ b 1)) 0))",
" ((+ b 1))))",
"(sum 90... | extern crate test;
extern crate lilium;
use test::Bencher;
use lilium::*; | random_line_split |
sum.rs | #![feature(test)]
extern crate test;
extern crate lilium;
use test::Bencher;
use lilium::*;
#[bench]
fn sum(b: &mut Bencher) {
let Module {
functions: f,
constants: c,
entry_point: e,
code: i
} = compile(concat!(
"(def sum (a b)",
" (if ",
" (> a 0)... | registers: &mut registers,
base: 0
};
b.iter(|| { run(&mut thread, e as usize) });
} | {
let Module {
functions: f,
constants: c,
entry_point: e,
code: i
} = compile(concat!(
"(def sum (a b)",
" (if ",
" (> a 0)",
" ((sum (- a 1) (+ b 1)))",
" ((+ b 1))))",
"(sum 900 0)"
));
let mut registers: [i... | identifier_body |
btree_builder.rs | use anyhow::Result;
use byteorder::{LittleEndian, WriteBytesExt};
use std::collections::VecDeque;
use std::io::Cursor;
use std::sync::{Arc, Mutex};
use crate::checksum;
use crate::io_engine::*;
use crate::pdata::btree::*;
use crate::pdata::space_map::*;
use crate::pdata::unpack::*;
use crate::write_batcher::*;
//----... | }
let wresult = self.nio.write(w, keys, values)?;
// Push a summary to the 'nodes' vector.
self.nodes.push(NodeSummary {
block: wresult.loc,
key: wresult.first_key,
nr_entries,
shared: self.shared,
});
Ok(())
}
//... | values.push(v); | random_line_split |
btree_builder.rs | use anyhow::Result;
use byteorder::{LittleEndian, WriteBytesExt};
use std::collections::VecDeque;
use std::io::Cursor;
use std::sync::{Arc, Mutex};
use crate::checksum;
use crate::io_engine::*;
use crate::pdata::btree::*;
use crate::pdata::space_map::*;
use crate::pdata::unpack::*;
use crate::write_batcher::*;
//----... |
}
Ok(())
}
/// Signal that no more values or nodes will be pushed. Returns a
/// vector of the built nodes. Consumes the builder.
pub fn complete(mut self, w: &mut WriteBatcher) -> Result<Vec<NodeSummary>> {
let half_full = self.max_entries_per_node / 2;
if!self.val... | {
// Add the nodes.
for n in nodes {
w.sm.lock().unwrap().inc(n.block, 1)?;
self.nodes.push(n.clone());
}
} | conditional_block |
btree_builder.rs | use anyhow::Result;
use byteorder::{LittleEndian, WriteBytesExt};
use std::collections::VecDeque;
use std::io::Cursor;
use std::sync::{Arc, Mutex};
use crate::checksum;
use crate::io_engine::*;
use crate::pdata::btree::*;
use crate::pdata::space_map::*;
use crate::pdata::unpack::*;
use crate::write_batcher::*;
//----... | (&mut self, v: &u64) -> Result<()> {
self.sm.lock().unwrap().dec(*v)?;
Ok(())
}
}
//------------------------------------------
// Building a btree for a given set of values is straight forward.
// But often we want to merge shared subtrees into the btree we're
// building, which _is_ complicated. ... | dec | identifier_name |
barrier.rs | #[cfg(test)]
mod tests;
use crate::fmt;
use crate::sync::{Condvar, Mutex};
/// A barrier enables multiple threads to synchronize the beginning
/// of some computation.
///
/// # Examples
///
/// ```
/// use std::sync::{Arc, Barrier};
/// use std::thread;
///
/// let mut handles = Vec::with_capacity(10);
/// let barri... | (&self) -> bool {
self.0
}
}
| is_leader | identifier_name |
barrier.rs | #[cfg(test)]
mod tests;
use crate::fmt;
use crate::sync::{Condvar, Mutex}; |
/// A barrier enables multiple threads to synchronize the beginning
/// of some computation.
///
/// # Examples
///
/// ```
/// use std::sync::{Arc, Barrier};
/// use std::thread;
///
/// let mut handles = Vec::with_capacity(10);
/// let barrier = Arc::new(Barrier::new(10));
/// for _ in 0..10 {
/// let c = Arc::c... | random_line_split | |
barrier.rs | #[cfg(test)]
mod tests;
use crate::fmt;
use crate::sync::{Condvar, Mutex};
/// A barrier enables multiple threads to synchronize the beginning
/// of some computation.
///
/// # Examples
///
/// ```
/// use std::sync::{Arc, Barrier};
/// use std::thread;
///
/// let mut handles = Vec::with_capacity(10);
/// let barri... |
}
impl BarrierWaitResult {
/// Returns `true` if this thread is the "leader thread" for the call to
/// [`Barrier::wait()`].
///
/// Only one thread will have `true` returned from their result, all other
/// threads will have `false` returned.
///
/// # Examples
///
/// ```
///... | {
f.debug_struct("BarrierWaitResult").field("is_leader", &self.is_leader()).finish()
} | identifier_body |
barrier.rs | #[cfg(test)]
mod tests;
use crate::fmt;
use crate::sync::{Condvar, Mutex};
/// A barrier enables multiple threads to synchronize the beginning
/// of some computation.
///
/// # Examples
///
/// ```
/// use std::sync::{Arc, Barrier};
/// use std::thread;
///
/// let mut handles = Vec::with_capacity(10);
/// let barri... |
}
}
#[stable(feature = "std_debug", since = "1.16.0")]
impl fmt::Debug for BarrierWaitResult {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BarrierWaitResult").field("is_leader", &self.is_leader()).finish()
}
}
impl BarrierWaitResult {
/// Returns `true` if this ... | {
lock.count = 0;
lock.generation_id = lock.generation_id.wrapping_add(1);
self.cvar.notify_all();
BarrierWaitResult(true)
} | conditional_block |
mod.rs | use actix::prelude::*;
use failure::*; | pub mod router;
pub mod forward_agent;
pub mod admin;
pub mod forward_agent_connection;
pub mod agent;
pub mod agent_connection;
pub mod requester;
#[derive(Debug, Clone)]
pub struct HandleAdminMessage(pub AdminQuery);
impl Message for HandleAdminMessage {
type Result = Result<ResAdminQuery, Error>;
}
#[derive(D... |
use crate::domain::a2connection::A2ConnMessage;
use crate::domain::admin_message::{AdminQuery, ResAdminQuery};
| random_line_split |
mod.rs | use actix::prelude::*;
use failure::*;
use crate::domain::a2connection::A2ConnMessage;
use crate::domain::admin_message::{AdminQuery, ResAdminQuery};
pub mod router;
pub mod forward_agent;
pub mod admin;
pub mod forward_agent_connection;
pub mod agent;
pub mod agent_connection;
pub mod requester;
#[derive(Debug, Clo... | (pub AdminQuery);
impl Message for HandleAdminMessage {
type Result = Result<ResAdminQuery, Error>;
}
#[derive(Debug)]
pub struct GetEndpoint();
#[derive(Debug, Serialize)]
pub struct Endpoint {
#[serde(rename = "DID")]
pub did: String,
#[serde(rename = "verKey")]
pub verkey: String,
}
impl Mess... | HandleAdminMessage | identifier_name |
lib.rs | #![feature(link_args)]
extern crate node_api_sys;
extern crate futures;
mod napi;
mod napi_value;
mod napi_futures;
pub mod error;
pub use napi::*;
pub use napi_value::{FromNapiValues, IntoNapiValue};
#[macro_export]
macro_rules! napi_module {
($module:expr, $register_func:ident) => {
const NAPI_MODULE_VERSION:... | () {}
}
| it_works | identifier_name |
lib.rs | #![feature(link_args)]
extern crate node_api_sys;
extern crate futures;
mod napi;
mod napi_value;
mod napi_futures;
pub mod error;
pub use napi::*;
pub use napi_value::{FromNapiValues, IntoNapiValue};
#[macro_export]
macro_rules! napi_module {
($module:expr, $register_func:ident) => {
const NAPI_MODULE_VERSION:... |
}
| {} | identifier_body |
lib.rs | #![feature(link_args)]
extern crate node_api_sys;
extern crate futures;
mod napi;
mod napi_value;
mod napi_futures;
pub mod error;
pub use napi::*;
pub use napi_value::{FromNapiValues, IntoNapiValue};
#[macro_export]
macro_rules! napi_module {
($module:expr, $register_func:ident) => {
const NAPI_MODULE_VERSION:... | filename: $module.to_string(),
register_func: Some($register_func),
modname: $module.to_string(),
})
.expect("error registering module");
}
__load_napi_module
};
}}
#[cfg(test)]
mod tests ... | version: NAPI_MODULE_VERSION,
flags: 0, | random_line_split |
abilities.rs | // Copyright (c) 2018 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless r... | } | } | random_line_split |
abilities.rs | // Copyright (c) 2018 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless r... |
/// Helper function; does the current thread have `cap` in its
/// effective capability set?
fn has(cap: Capability) -> bool {
caps::has_cap(None, CapSet::Effective, cap).unwrap_or(false)
}
}
#[cfg(target_os = "macos")]
mod imp {
pub fn can_run_services_as_svc_user() -> bool {
tru... | {
has(Capability::CAP_SETUID) && has(Capability::CAP_SETGID) && has(Capability::CAP_CHOWN)
} | identifier_body |
abilities.rs | // Copyright (c) 2018 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless r... | () -> bool {
true
}
}
| can_run_services_as_svc_user | identifier_name |
errors.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
NfsError::CoreError(ref error) => write!(f, "Client Errror: {}", error),
NfsError::FileExists => {
write!(f, "File already exists with the same name in a directory")
}
NfsError::FileNot... | fmt | identifier_name |
errors.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... |
NfsError::SelfEncryption(ref error) => {
write!(
f,
"Error while self-encrypting/-decrypting data: {:?}",
error
)
}
}
}
}
impl fmt::Debug for NfsError {
fn fmt(&self, f: &mut fmt::Format... | {
write!(
f,
"Unsuccessful Serialisation or Deserialisation: {:?}",
error
)
} | conditional_block |
errors.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... | "Error while self-encrypting/-decrypting data: {:?}",
error
)
}
}
}
}
impl fmt::Debug for NfsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
NfsError::CoreError(ref error) => write!(f, ... | {
match *self {
NfsError::CoreError(ref error) => write!(f, "Client Errror: {}", error),
NfsError::FileExists => {
write!(f, "File already exists with the same name in a directory")
}
NfsError::FileNotFound => write!(f, "File not found"),
... | identifier_body |
errors.rs | // Copyright 2016 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By ... | NfsError::CoreError(ref error) => write!(f, "Client Errror: {}", error),
NfsError::FileExists => {
write!(f, "File already exists with the same name in a directory")
}
NfsError::FileNotFound => write!(f, "File not found"),
NfsError::InvalidRan... |
impl fmt::Display for NfsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.