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 |
|---|---|---|---|---|
global.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/. */
//! Abstractions for global scopes.
//!
//! This module contains smart pointers to global scopes, to simplify writ... |
/// Process a single event as if it were the next event in the task queue for
/// this global.
pub fn process_event(&self, msg: ScriptMsg) {
match *self {
GlobalRef::Window(_) => ScriptTask::process_event(msg),
GlobalRef::Worker(ref worker) => worker.process_event(msg),
... | {
match *self {
GlobalRef::Window(ref window) => window.new_script_pair(),
GlobalRef::Worker(ref worker) => worker.new_script_pair(),
}
} | identifier_body |
attr.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 devtools_traits::AttrInfo;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBind... | #[inline]
pub fn prefix(&self) -> &Option<Atom> {
&self.prefix
}
}
impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-localname
fn LocalName(&self) -> DOMString {
(**self.local_name()).to_owned()
}
// https://dom.spec.whatwg.org/#dom-attr-value
fn Valu... | &self.namespace
}
| random_line_split |
attr.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 devtools_traits::AttrInfo;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBind... |
#[inline]
unsafe fn local_name_atom_forever(&self) -> Atom {
(*self.unsafe_get()).local_name.clone()
}
#[inline]
unsafe fn value_for_layout(&self) -> &AttrValue {
(*self.unsafe_get()).value.borrow_for_layout()
}
}
| {
// This transmute is used to cheat the lifetime restriction.
match *self.value_forever() {
AttrValue::TokenList(_, ref tokens) => Some(tokens),
_ => None,
}
} | identifier_body |
attr.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 devtools_traits::AttrInfo;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBind... | (string: DOMString, default: u32) -> AttrValue {
let result = parse_unsigned_integer(string.chars()).unwrap_or(default);
let result = if result > 2147483647 {
default
} else {
result
};
AttrValue::UInt(string, result)
}
// https://html.spec.whatwg... | from_u32 | identifier_name |
simple-lexical-scope.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {()}
fn sentinel() {()}
| zzz | identifier_name |
simple-lexical-scope.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
{
zzz(); // #break
sentinel();
let x = 10.5f64;
zzz(); // #break
sentinel();
}
zzz(); // #break
sentinel();
}
zzz(); // #break
sentinel();
}
fn zzz() {()}
fn sentinel() {()} | zzz(); // #break
sentinel(); | random_line_split |
simple-lexical-scope.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn sentinel() {()}
| {()} | identifier_body |
issue-40001-plugin.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
}
| {
cx.span_lint(MISSING_WHITELISTED_ATTR, span,
"Missing 'whitelisted_attr' attribute");
} | conditional_block |
issue-40001-plugin.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&mut self,
cx: &LateContext<'a, 'tcx>,
_: intravisit::FnKind<'tcx>,
_: &'tcx hir::FnDecl,
_: &'tcx hir::Body,
span: source_map::Span,
id: ast::NodeId) {
let item = match cx.tcx.hir().get(id) {
Node::Ite... | check_fn | identifier_name |
issue-40001-plugin.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
declare_lint!(MISSING_WHITELISTED_ATTR, Deny,
"Checks for missing `whitelisted_attr` attribute");
struct MissingWhitelistedAttrPass;
impl LintPass for MissingWhitelistedAttrPass {
fn get_lints(&self) -> LintArray {
lint_array!(MISSING_WHITELISTED_ATTR)
}
}
impl<'a, 'tcx> LateLintPass<... | {
reg.register_late_lint_pass(box MissingWhitelistedAttrPass);
reg.register_attribute("whitelisted_attr".to_string(), Whitelisted);
} | identifier_body |
issue-40001-plugin.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | // except according to those terms.
#![feature(box_syntax, plugin, plugin_registrar, rustc_private)]
#![crate_type = "dylib"]
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
extern crate syntax;
use rustc_plugin::Registry;
use syntax::attr;
use syntax::ext::base::*;
use syntax::feature_gate::AttributeTyp... | // option. This file may not be copied, modified, or distributed | random_line_split |
main.rs | extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate curl;
extern crate inflections;
mod parser;
mod types;
mod writer;
use std::env;
use std::collections::HashMap;
use curl::easy::Easy;
fn main() |
let res = parser::parse(&events).unwrap();
let sections = types::to_sections(res, &mut types);
println!("\n\n\n");
println!("{:?}", sections);
writer::write(path, sections, types).unwrap();
}
fn download(url: &str) -> String {
let mut buf = Vec::new();
{
let mut easy = Easy::new()... | {
let mut args = env::args();
let name = args.next().unwrap();
let (version, path) = match (args.next(), args.next()) {
(Some(v), Some(f)) => (v,f),
_ => {
println!("Usage: {} [qemu-version] [export-path]", name);
::std::process::exit(1);
}
};
let sch... | identifier_body |
main.rs | extern crate serde;
extern crate serde_json;
#[macro_use] | extern crate serde_derive;
extern crate curl;
extern crate inflections;
mod parser;
mod types;
mod writer;
use std::env;
use std::collections::HashMap;
use curl::easy::Easy;
fn main() {
let mut args = env::args();
let name = args.next().unwrap();
let (version, path) = match (args.next(), args.next()) {
... | random_line_split | |
main.rs | extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate curl;
extern crate inflections;
mod parser;
mod types;
mod writer;
use std::env;
use std::collections::HashMap;
use curl::easy::Easy;
fn | () {
let mut args = env::args();
let name = args.next().unwrap();
let (version, path) = match (args.next(), args.next()) {
(Some(v), Some(f)) => (v,f),
_ => {
println!("Usage: {} [qemu-version] [export-path]", name);
::std::process::exit(1);
}
};
let ... | main | identifier_name |
stop_guard.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
}
| {
self.flag.store(true, Ordering::Relaxed)
} | identifier_body |
stop_guard.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | {
flag: Arc<AtomicBool>,
}
impl StopGuard {
/// Create a stop guard
pub fn new() -> StopGuard {
StopGuard {
flag: Arc::new(AtomicBool::new(false))
}
}
/// Share stop guard between the threads
pub fn share(&self) -> Arc<AtomicBool> {
self.flag.clone()
}
}
impl Drop for StopGuard {
fn drop(&mut self)... | StopGuard | identifier_name |
stop_guard.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
use std::sync::Arc;
use std::sync::atomic::*;
/// Stop guard that will set a stop flag on drop
pub struct StopGuard {
flag: Arc<AtomicBool>,
}
impl StopGuard {
/// Create a stop guard
pub fn new() -> StopGuard {
StopGuard {
flag: Arc::new(AtomicBool::new(false))
}
}
/// Share stop guard between the thre... | random_line_split | |
helm.rs | // Copyright (c) 2017 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... | (ui: &mut UI, args: Vec<OsString>) -> Result<()> {
::command::pkg::export::export_common::start(
ui,
args,
EXPORT_CMD,
EXPORT_CMD_ENVVAR,
EXPORT_PKG_IDENT,
EXPORT_PKG_IDENT_ENVVAR,
)
}
| start | identifier_name |
helm.rs | // Copyright (c) 2017 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... | pub fn start(ui: &mut UI, args: Vec<OsString>) -> Result<()> {
::command::pkg::export::export_common::start(
ui,
args,
EXPORT_CMD,
EXPORT_CMD_ENVVAR,
EXPORT_PKG_IDENT,
EXPORT_PKG_IDENT_ENVVAR,
)
} | const EXPORT_CMD: &'static str = "hab-pkg-export-helm";
const EXPORT_CMD_ENVVAR: &'static str = "HAB_PKG_EXPORT_HELM_BINARY";
const EXPORT_PKG_IDENT: &'static str = "core/hab-pkg-export-helm";
const EXPORT_PKG_IDENT_ENVVAR: &'static str = "HAB_PKG_EXPORT_HELM_PKG_IDENT";
| random_line_split |
helm.rs | // Copyright (c) 2017 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... | {
::command::pkg::export::export_common::start(
ui,
args,
EXPORT_CMD,
EXPORT_CMD_ENVVAR,
EXPORT_PKG_IDENT,
EXPORT_PKG_IDENT_ENVVAR,
)
} | identifier_body | |
mona.rs | extern crate mon_artist;
use mon_artist::render::svg::{SvgRender};
use mon_artist::render::{RenderS};
use mon_artist::grid::{Grid, ParseError};
use mon_artist::{SceneOpts};
use std::convert::From;
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Read, Write};
fn main() {
let mut args = en... | Parse(ParseError),
}
impl From<io::Error> for Error { fn from(e: io::Error) -> Self { Error::IO(e) } }
impl From<ParseError> for Error { fn from(e: ParseError) -> Self { Error::Parse(e) } }
use mon_artist::format::Table;
fn get_table(table: &str) -> Table {
match File::open(table) {
Ok(input) => Tabl... | IO(io::Error), | random_line_split |
mona.rs | extern crate mon_artist;
use mon_artist::render::svg::{SvgRender};
use mon_artist::render::{RenderS};
use mon_artist::grid::{Grid, ParseError};
use mon_artist::{SceneOpts};
use std::convert::From;
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Read, Write};
fn main() {
let mut args = en... | (table: &str) -> Table {
match File::open(table) {
Ok(input) => Table::from_lines(BufReader::new(input).lines()),
Err(err) => match table {
"default" => Table::default(),
"demo" => Table::demo(),
_ => panic!("Unknown table name: {}, file err: {:?}", table, err)... | get_table | identifier_name |
mona.rs | extern crate mon_artist;
use mon_artist::render::svg::{SvgRender};
use mon_artist::render::{RenderS};
use mon_artist::grid::{Grid, ParseError};
use mon_artist::{SceneOpts};
use std::convert::From;
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Read, Write};
fn main() {
let mut args = en... | else { break; };
let in_file = if let Some(arg) = args.next() { arg } else { break; };
let out_file = if let Some(arg) = args.next() { arg } else { break; };
println!("processing {} to {} via {}", in_file, out_file, table);
process(&table, &in_file, &out_file).unwrap();
}
// d... | { arg } | conditional_block |
util.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library 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 ... | let content = matches.name("content").map(|r| r.as_str()).unwrap_or("");
Ok((Value::parse(header.as_str())?, String::from(content)))
} | random_line_split | |
util.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library 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 ... | (buf: &str) -> Result<(Value, String)> {
debug!("Building entry from string");
lazy_static! {
static ref RE: Regex = Regex::new(r"(?smx)
^---$
(?P<header>.*) # Header
^---$\n
(?P<content>.*) # Content
").unwrap();
}
let matches = match RE.... | entry_buffer_to_header_content | identifier_name |
util.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library 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 ... |
let content = matches.name("content").map(|r| r.as_str()).unwrap_or("");
Ok((Value::parse(header.as_str())?, String::from(content)))
}
| {
debug!("Building entry from string");
lazy_static! {
static ref RE: Regex = Regex::new(r"(?smx)
^---$
(?P<header>.*) # Header
^---$\n
(?P<content>.*) # Content
").unwrap();
}
let matches = match RE.captures(buf) {
None => retu... | identifier_body |
lib.rs | /*
* Exopticon - A free video surveillance system.
* Copyright (C) 2020 David Matthew Mattli <dmm@mattli.us>
*
* This file is part of Exopticon.
*
* Exopticon 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 Founda... | let iso_begin_time = {
assert!(!iso_begin_time.is_null());
CStr::from_ptr(iso_begin_time)
.to_string_lossy()
.into_owned()
};
let message = CaptureMessage::NewFile {
filename,
begin_time: iso_begin_time,
};
print_message(message);
}
/// Send ... |
CStr::from_ptr(filename).to_string_lossy().into_owned()
};
| random_line_split |
lib.rs | /*
* Exopticon - A free video surveillance system.
* Copyright (C) 2020 David Matthew Mattli <dmm@mattli.us>
*
* This file is part of Exopticon.
*
* Exopticon 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 Founda... | print_message(message);
}
/// Send a message signaling the closing of a file.
///
/// # Safety
///
/// filename and iso_end_time must be null-terminated character arrays.
///
#[no_mangle]
pub unsafe extern "C" fn send_end_file_message(
filename: *const c_char,
iso_end_time: *const c_char,
) {
let file... | {
let filename = {
assert!(!filename.is_null());
CStr::from_ptr(filename).to_string_lossy().into_owned()
};
let iso_begin_time = {
assert!(!iso_begin_time.is_null());
CStr::from_ptr(iso_begin_time)
.to_string_lossy()
.into_owned()
};
let me... | identifier_body |
lib.rs | /*
* Exopticon - A free video surveillance system.
* Copyright (C) 2020 David Matthew Mattli <dmm@mattli.us>
*
* This file is part of Exopticon.
*
* Exopticon 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 Founda... | (_level: i32, message: *const c_char) {
let message = {
assert!(!message.is_null());
CStr::from_ptr(message).to_string_lossy().into_owned()
};
let capture_message = CaptureMessage::Log { message };
print_message(capture_message);
}
#[cfg(test)]
mod tests {
#[test]
fn it_works... | send_log_message | identifier_name |
lib.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 ... | (bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
unsafe {
let mut outsz : size_t = 0;
let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *c_void,
bytes.len() as size_t,
&mut outsz,
... | deflate_bytes_internal | identifier_name |
lib.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 {
None
}
}
}
/// Compress a buffer, without writing any sort of header on the output.
pub fn deflate_bytes(bytes: &[u8]) -> Option<CVec<u8>> {
deflate_bytes_internal(bytes, LZ_NORM)
}
/// Compress a buffer, using a header that zlib can understand.
pub fn deflate_bytes_zlib(bytes: &[u... | {
Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
} | conditional_block |
lib.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 deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
unsafe {
let mut outsz : size_t = 0;
let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *c_void,
bytes.len() as size_t,
... | static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum
static TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000; // write zlib header and adler32 checksum
| random_line_split |
lib.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 ... |
/// Decompress a buffer that starts with a zlib header.
pub fn inflate_bytes_zlib(bytes: &[u8]) -> Option<CVec<u8>> {
inflate_bytes_internal(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER)
}
#[cfg(test)]
mod tests {
use super::{inflate_bytes, deflate_bytes};
use std::rand;
use std::rand::Rng;
#[test]
#... | {
inflate_bytes_internal(bytes, 0)
} | identifier_body |
mutable.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use crate::*;
pub trait SyncMutable {
fn put(&self, key: &[u8], value: &[u8]) -> Result<()>;
fn put_cf(&self, cf: &str, key: &[u8], value: &[u8]) -> Result<()>;
fn delete(&self, key: &[u8]) -> Result<()>;
fn delete_cf(&self, cf: &st... |
}
| {
self.put_cf(cf, key, &m.write_to_bytes()?)
} | identifier_body |
mutable.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use crate::*;
pub trait SyncMutable {
fn put(&self, key: &[u8], value: &[u8]) -> Result<()>;
fn put_cf(&self, cf: &str, key: &[u8], value: &[u8]) -> Result<()>;
fn delete(&self, key: &[u8]) -> Result<()>;
fn delete_cf(&self, cf: &st... | <M: protobuf::Message>(&self, key: &[u8], m: &M) -> Result<()> {
self.put(key, &m.write_to_bytes()?)
}
fn put_msg_cf<M: protobuf::Message>(&self, cf: &str, key: &[u8], m: &M) -> Result<()> {
self.put_cf(cf, key, &m.write_to_bytes()?)
}
}
| put_msg | identifier_name |
mutable.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use crate::*;
pub trait SyncMutable {
fn put(&self, key: &[u8], value: &[u8]) -> Result<()>;
fn put_cf(&self, cf: &str, key: &[u8], value: &[u8]) -> Result<()>;
fn delete(&self, key: &[u8]) -> Result<()>;
fn delete_cf(&self, cf: &st... | }
fn put_msg_cf<M: protobuf::Message>(&self, cf: &str, key: &[u8], m: &M) -> Result<()> {
self.put_cf(cf, key, &m.write_to_bytes()?)
}
} | fn put_msg<M: protobuf::Message>(&self, key: &[u8], m: &M) -> Result<()> {
self.put(key, &m.write_to_bytes()?) | random_line_split |
elf_arch-i386.rs | pub const ELF_CLASS: u8 = 1;
pub type ElfAddr = u32;
pub type ElfHalf = u16;
pub type ElfOff = u32;
pub type ElfWord = u32;
/// An ELF header
#[repr(packed)]
pub struct ElfHeader {
/// The "magic number" (4 bytes)
pub magic: [u8; 4],
/// 64 or 32 bit?
pub class: u8,
/// Little (1) or big endianness... | pub ver_2: ElfWord,
/// The ELF entry
pub entry: ElfAddr,
/// The program header table offset
pub ph_off: ElfOff,
/// The section header table offset
pub sh_off: ElfOff,
/// The flags set
pub flags: ElfWord,
/// The header table length
pub h_len: ElfHalf,
/// The program ... | /// Second version | random_line_split |
elf_arch-i386.rs | pub const ELF_CLASS: u8 = 1;
pub type ElfAddr = u32;
pub type ElfHalf = u16;
pub type ElfOff = u32;
pub type ElfWord = u32;
/// An ELF header
#[repr(packed)]
pub struct ElfHeader {
/// The "magic number" (4 bytes)
pub magic: [u8; 4],
/// 64 or 32 bit?
pub class: u8,
/// Little (1) or big endianness... | {
pub _type: ElfWord,
pub off: ElfOff,
pub vaddr: ElfAddr,
pub paddr: ElfAddr,
pub file_len: ElfWord,
pub mem_len: ElfWord,
pub flags: ElfWord,
pub align: ElfWord,
}
/// An ELF section
#[repr(packed)]
pub struct ElfSection {
pub name: ElfWord,
pub _type: ElfWord,
pub flags:... | ElfSegment | identifier_name |
entity.rs | use std::str::FromStr;
use std::fmt::{self, Display};
/// An entity tag
///
/// An Etag consists of a string enclosed by two literal double quotes.
/// Preceding the first double quote is an optional weakness indicator,
/// which always looks like this: W/
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3
... |
// The etag is weak if its first char is not a DQUOTE.
if slice.char_at(0) == '"' /* '"' */ {
// No need to check if the last char is a DQUOTE,
// we already did that above.
if check_slice_validity(slice.slice_chars(1, length-1)) {
return Ok(EntityTa... | {
return Err(());
} | conditional_block |
entity.rs | use std::str::FromStr;
use std::fmt::{self, Display};
/// An entity tag
///
/// An Etag consists of a string enclosed by two literal double quotes.
/// Preceding the first double quote is an optional weakness indicator,
/// which always looks like this: W/
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3
... | () {
// Expected successes
let mut etag : EntityTag = "\"foobar\"".parse().unwrap();
assert_eq!(etag, (EntityTag {
weak: false,
tag: "foobar".to_string()
}));
etag = "\"\"".parse().unwrap();
assert_eq!(etag, EntityTag {
weak: false,
... | test_etag_successes | identifier_name |
entity.rs | use std::str::FromStr;
use std::fmt::{self, Display};
/// An entity tag
///
/// An Etag consists of a string enclosed by two literal double quotes.
/// Preceding the first double quote is an optional weakness indicator,
/// which always looks like this: W/
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3
... |
impl FromStr for EntityTag {
type Err = ();
fn from_str(s: &str) -> Result<EntityTag, ()> {
let length: usize = s.len();
let slice = &s[];
// Early exits:
// 1. The string is empty, or,
// 2. it doesn't terminate in a DQUOTE.
if slice.is_empty() ||!slice.ends_w... | {
for c in slice.bytes() {
match c {
b'\x21' | b'\x23' ... b'\x7e' | b'\x80' ... b'\xff' => (),
_ => { return false; }
}
}
true
} | identifier_body |
entity.rs | use std::str::FromStr;
use std::fmt::{self, Display};
/// An entity tag
///
/// An Etag consists of a string enclosed by two literal double quotes.
/// Preceding the first double quote is an optional weakness indicator,
/// which always looks like this: W/
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3
... | return Ok(EntityTag {
weak: false,
tag: slice.slice_chars(1, length-1).to_string()
});
} else {
return Err(());
}
}
if slice.slice_chars(0, 3) == "W/\"" {
if check_slice_validity(... | // The etag is weak if its first char is not a DQUOTE.
if slice.char_at(0) == '"' /* '"' */ {
// No need to check if the last char is a DQUOTE,
// we already did that above.
if check_slice_validity(slice.slice_chars(1, length-1)) { | random_line_split |
dst-index.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>(&'a self, _: &uint) -> &'a str {
"hello"
}
}
struct T;
impl Index<uint, Show +'static> for T {
fn index<'a>(&'a self, idx: &uint) -> &'a (Show +'static) {
static x: uint = 42;
&x
}
}
fn main() {
S[0];
//~^ ERROR E0161
T[0];
//~^ ERROR cannot move out of derefe... | index | identifier_name |
dst-index.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
struct S;
impl Index<uint, str> for S {
fn index<'a>(&'a self, _: &uint) -> &'a str {
"hello"
}
}
struct T;
impl Index<uint, Show +'static> for T {
fn index<'a>(&'a self, idx: &uint) -> &'a (Show +'static) {
static x: uint = 42;
&x
}
}
fn main() {
S[0];
//~^ ERROR E0... |
use std::ops::Index;
use std::fmt::Show; | random_line_split |
player_unit.rs | // OpenAOE: An open source reimplementation of Age of Empires (1997)
// Copyright (c) 2016 Kevin Fuller
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including wi... | <S: Read>(stream: &mut S) -> Result<PlayerUnit> {
let mut data: PlayerUnit = Default::default();
data.position_x = try!(stream.read_f32());
data.position_y = try!(stream.read_f32());
data.position_z = try!(stream.read_f32());
data.spawn_id = optional_id!(try!(stream.read_i32()));... | read_from_stream | identifier_name |
player_unit.rs | // OpenAOE: An open source reimplementation of Age of Empires (1997)
// Copyright (c) 2016 Kevin Fuller
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including wi... | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SO... | // copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | random_line_split |
trait-with-bounds-default.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
assert_eq!(3.do_get2(), (3, 3));
assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
}
| main | identifier_name |
trait-with-bounds-default.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
pub fn main() {
assert_eq!(3.do_get2(), (3, 3));
assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
}
| { self.as_ref().unwrap().clone() } | identifier_body |
trait-with-bounds-default.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn do_get(&self) -> T;
fn do_get2(&self) -> (T, T) {
let x = self.do_get();
(x.clone(), x.clone())
}
}
impl Getter<isize> for isize {
fn do_get(&self) -> isize { *self }
}
impl<T: Clone> Getter<T> for Option<T> {
fn do_get(&self) -> T { self.as_ref().unwrap().clone() }
}
pub fn... | trait Getter<T: Clone> { | random_line_split |
mod.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 ... |
#[test]
fn test_int_from_str_overflow() {
let mut i8_val: i8 = 127;
assert_eq!("127".parse::<i8>().ok(), Some(i8_val));
assert_eq!("128".parse::<i8>().ok(), None);
i8_val = i8_val.wrapping_add(1);
assert_eq!("-128".parse::<i8>().ok(), Some(i8_val));
assert_eq!(... | {
let x1 : Option<f64> = f64::from_str_radix("-123.456", 10).ok();
assert_eq!(x1, Some(-123.456));
let x2 : Option<f32> = f32::from_str_radix("123.456", 10).ok();
assert_eq!(x2, Some(123.456));
let x3 : Option<f32> = f32::from_str_radix("-0.0", 10).ok();
assert_eq!(x3, So... | identifier_body |
mod.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 ... | <T>(ten: T, two: T) where
T: PartialEq
+ Add<Output=T> + Sub<Output=T>
+ Mul<Output=T> + Div<Output=T>
+ Rem<Output=T> + Debug
+ Copy
{
assert_eq!(ten.add(two), ten + two);
assert_eq!(ten.sub(two), ten - two);
assert_eq!(ten.mul(two), ten * two);
assert_eq!(ten.div(two), ten ... | test_num | identifier_name |
mod.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 ... | #[test]
fn test_int_from_str_overflow() {
let mut i8_val: i8 = 127;
assert_eq!("127".parse::<i8>().ok(), Some(i8_val));
assert_eq!("128".parse::<i8>().ok(), None);
i8_val = i8_val.wrapping_add(1);
assert_eq!("-128".parse::<i8>().ok(), Some(i8_val));
assert_eq!("-... | assert_eq!(x4, Some(1.0));
let x5 : Option<f32> = f32::from_str_radix("-1.0", 10).ok();
assert_eq!(x5, Some(-1.0));
}
| random_line_split |
issue-34798.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | pub struct ZeroSizeWithPhantomData<T>(::std::marker::PhantomData<T>);
#[repr(C)]
pub struct Bar {
size: u8,
baz: ZeroSizeWithPhantomData<i32>,
}
extern "C" {
pub fn bar(_: *mut Foo, _: *mut Bar);
}
fn main() {
} | #[repr(C)] | random_line_split |
issue-34798.rs | // Copyright 2017 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 ... | {
size: u8,
baz: ZeroSizeWithPhantomData<i32>,
}
extern "C" {
pub fn bar(_: *mut Foo, _: *mut Bar);
}
fn main() {
}
| Bar | identifier_name |
vec-res-add.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 ... |
impl Drop for r {
fn drop(&mut self) {}
}
fn main() {
// This can't make sense as it would copy the classes
let i = vec!(r(0));
let j = vec!(r(1));
let k = i + j;
//~^ ERROR binary operation `+` cannot be applied to type
println!("{}", j);
} |
fn r(i:int) -> r { r { i: i } } | random_line_split |
vec-res-add.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 ... | (&mut self) {}
}
fn main() {
// This can't make sense as it would copy the classes
let i = vec!(r(0));
let j = vec!(r(1));
let k = i + j;
//~^ ERROR binary operation `+` cannot be applied to type
println!("{}", j);
}
| drop | identifier_name |
vec-res-add.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 ... |
impl Drop for r {
fn drop(&mut self) {}
}
fn main() {
// This can't make sense as it would copy the classes
let i = vec!(r(0));
let j = vec!(r(1));
let k = i + j;
//~^ ERROR binary operation `+` cannot be applied to type
println!("{}", j);
}
| { r { i: i } } | identifier_body |
generic_path.rs | use std::io::Write;
use std::ops::Deref;
use syn::ext::IdentExt;
use crate::bindgen::config::{Config, Language};
use crate::bindgen::declarationtyperesolver::{DeclarationType, DeclarationTypeResolver};
use crate::bindgen::ir::{Path, Type};
use crate::bindgen::utilities::IterHelpers;
use crate::bindgen::writer::{Sourc... | (&self) -> &[Path] {
&self.0
}
}
impl Source for GenericParams {
fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {
self.write_internal(config, out, false);
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GenericPath {
path: Path,
e... | deref | identifier_name |
generic_path.rs | use std::io::Write;
use std::ops::Deref;
use syn::ext::IdentExt;
use crate::bindgen::config::{Config, Language};
use crate::bindgen::declarationtyperesolver::{DeclarationType, DeclarationTypeResolver};
use crate::bindgen::ir::{Path, Type};
use crate::bindgen::utilities::IterHelpers;
use crate::bindgen::writer::{Sourc... |
pub fn name(&self) -> &str {
self.path.name()
}
pub fn export_name(&self) -> &str {
&self.export_name
}
pub fn rename_for_config(&mut self, config: &Config, generic_params: &GenericParams) {
for generic in &mut self.generics {
generic.rename_for_config(config,... | {
self.ctype.as_ref()
} | identifier_body |
generic_path.rs | use std::io::Write;
use std::ops::Deref;
use syn::ext::IdentExt;
use crate::bindgen::config::{Config, Language};
use crate::bindgen::declarationtyperesolver::{DeclarationType, DeclarationTypeResolver};
use crate::bindgen::ir::{Path, Type};
use crate::bindgen::utilities::IterHelpers;
use crate::bindgen::writer::{Sourc... | }
impl Deref for GenericParams {
type Target = [Path];
fn deref(&self) -> &[Path] {
&self.0
}
}
impl Source for GenericParams {
fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {
self.write_internal(config, out, false);
}
}
#[derive(Debug, Clone, PartialEq, E... |
pub fn write_with_default<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {
self.write_internal(config, out, true);
} | random_line_split |
generic_path.rs | use std::io::Write;
use std::ops::Deref;
use syn::ext::IdentExt;
use crate::bindgen::config::{Config, Language};
use crate::bindgen::declarationtyperesolver::{DeclarationType, DeclarationTypeResolver};
use crate::bindgen::ir::{Path, Type};
use crate::bindgen::utilities::IterHelpers;
use crate::bindgen::writer::{Sourc... |
write!(out, "typename {}", item);
if with_default {
write!(out, " = void");
}
}
out.write(">");
out.new_line();
}
}
pub fn write_with_default<F: Write>(&self, config: &Config, out: &mut SourceWriter... | {
out.write(", ");
} | conditional_block |
detect.rs | /* Copyright (C) 2018 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... |
}
0
}
| {
let value = &s.name_string[i as usize];
*buffer = value.as_ptr();
*buffer_len = value.len() as u32;
return 1;
} | conditional_block |
detect.rs | /* Copyright (C) 2018 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... | -> u8
{
if let Some(ref s) = tx.cname {
if (i as usize) < s.name_string.len() {
let value = &s.name_string[i as usize];
*buffer = value.as_ptr();
*buffer_len = value.len() as u32;
return 1;
}
}
0
}
... | buffer_len: *mut u32) | random_line_split |
detect.rs | /* Copyright (C) 2018 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... |
#[no_mangle]
pub unsafe extern "C" fn rs_krb5_tx_get_sname(tx: &mut KRB5Transaction,
i: u16,
buffer: *mut *const u8,
buffer_len: *mut u32)
... | {
if let Some(ref s) = tx.cname {
if (i as usize) < s.name_string.len() {
let value = &s.name_string[i as usize];
*buffer = value.as_ptr();
*buffer_len = value.len() as u32;
return 1;
}
}
0
} | identifier_body |
detect.rs | /* Copyright (C) 2018 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: &mut KRB5Transaction,
ptr: *mut i32) -> u32
{
match tx.error_code {
Some(ref e) => {
*ptr = e.0;
0
},
None => 1
}
}
#[no_mangle]
pub unsafe extern "C" fn rs_krb5_tx_get_cname(tx: &mut KRB5Transaction,
... | rs_krb5_tx_get_errcode | identifier_name |
fp.rs | // Copyright 2021 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | (idf: bool) -> &'static str {
if idf {
"Input denormal floating-point exception occurred."
} else {
"Input denormal floating-point exception did not occur."
}
}
fn describe_ixf(ixf: bool) -> &'static str {
if ixf {
"Inexact floating-point exception occurred."
} else {
... | describe_idf | identifier_name |
fp.rs | // Copyright 2021 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | }
}
fn describe_idf(idf: bool) -> &'static str {
if idf {
"Input denormal floating-point exception occurred."
} else {
"Input denormal floating-point exception did not occur."
}
}
fn describe_ixf(ixf: bool) -> &'static str {
if ixf {
"Inexact floating-point exception occurr... | } else {
"IDF, IXF, UFF, OFF, DZF and IOF do not hold valid information." | random_line_split |
fp.rs | // Copyright 2021 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
}
fn describe_uff(uff: bool) -> &'static str {
if uff {
"Underflow floating-point exception occurred."
} else {
"Underflow floating-point exception did not occur."
}
}
fn describe_off(off: bool) -> &'static str {
if off {
"Overflow floating-point exception occurred."
} els... | {
"Inexact floating-point exception did not occur."
} | conditional_block |
fp.rs | // Copyright 2021 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | {
if iof {
"Invalid Operation floating-point exception occurred."
} else {
"Invalid Operation floating-point exception did not occur."
}
} | identifier_body | |
const-vec-of-fns.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () { }
static bare_fns: &'static [fn()] = &[f, f];
struct S<F: FnOnce()>(F);
static mut closures: &'static mut [S<fn()>] = &mut [S(f as fn()), S(f as fn())];
pub fn main() {
unsafe {
for &bare_fn in bare_fns { bare_fn() }
for closure in &mut *closures {
let S(ref mut closure) = *closure... | f | identifier_name |
const-vec-of-fns.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/*!
* Try to do... | random_line_split | |
shootout-k-nucleotide.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 ... | else {
get_sequence(&mut std::io::stdin(), ">THREE")
};
let input = Arc::new(input);
let nb_freqs: Vec<(uint, Future<Table>)> = range(1u, 3).map(|i| {
let input = input.clone();
(i, Future::spawn(proc() generate_frequencies(input.as_slice(), i)))
}).collect();
let occ_freqs... | {
let fd = std::io::File::open(&Path::new("shootout-k-nucleotide.data"));
get_sequence(&mut std::io::BufferedReader::new(fd), ">THREE")
} | conditional_block |
shootout-k-nucleotide.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, frame: uint) -> String {
let mut key = self.hash();
let mut result = Vec::new();
for _ in range(0, frame) {
result.push(unpack_symbol((key as u8) & 3));
key >>= 2;
}
result.reverse();
String::from_utf8(result).unwrap()
}
}
// Hash tab... | unpack | identifier_name |
shootout-k-nucleotide.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 ... | }
Table::search_remainder(&mut **entry, key, c)
}
}
fn iter<'a>(&'a self) -> Items<'a> {
Items { cur: None, items: self.items.iter() }
}
}
impl<'a> Iterator<&'a Entry> for Items<'a> {
fn next(&mut self) -> Option<&'a Entry> {
let ret = match self.cur {
... | if entry.code == key {
c.f(&mut **entry);
return; | random_line_split |
pat-tuple-2.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
tuple();
tuple_struct();
}
| main | identifier_name |
pat-tuple-2.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (..) => ()
}
}
fn tuple_struct() {
struct S(u8);
let x = S(1);
match x {
S(2,..) => panic!(),
S(..) => ()
}
}
fn main() {
tuple();
tuple_struct();
} | (2, ..) => panic!(), | random_line_split |
cabi_x86_64.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (ccx: &CrateContext, cls: &[RegClass]) -> Type {
fn llvec_len(cls: &[RegClass]) -> usize {
let mut len = 1;
for c in cls {
if *c!= SSEUp {
break;
}
len += 1;
}
return len;
}
let mut tys = Vec::new();
let mut i = 0;
... | llreg_ty | identifier_name |
cabi_x86_64.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | if self.is_empty() { return false; }
self[0] == Memory
}
}
fn classify_ty(ty: Type) -> Vec<RegClass> {
fn align(off: usize, ty: Type) -> usize {
let a = ty_align(ty);
return (off + a - 1) / a * a;
}
fn ty_align(ty: Type) -> usize {
match ty.kind() {
... |
fn is_ret_bysret(&self) -> bool { | random_line_split |
cabi_x86_64.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
trait ClassList {
fn is_pass_byval(&self) -> bool;
fn is_ret_bysret(&self) -> bool;
}
impl ClassList for [RegClass] {
fn is_pass_byval(&self) -> bool {
if self.is_empty() { return false; }
let class = self[0];
class == Memory
|| class == X87
|| class == Compl... | {
match *self {
SSEFs | SSEFv | SSEDs | SSEDv | SSEInt(_) => true,
_ => false
}
} | identifier_body |
lib.rs | #[macro_use(expect)]
extern crate expectest;
extern crate sql;
pub mod lexer;
pub mod parser;
pub mod query_typer;
pub mod query_validator; | use sql::parser::parse;
use sql::query_typer::type_inferring_old;
use sql::query_validator::validate_old;
use sql::query_executer::{execute, ExecutionResult};
use sql::data_manager::DataManager;
use sql::catalog_manager::CatalogManager;
pub fn evaluate_query(query: &str, data_manager: &DataManager, catalog_manager: &C... | pub mod query_executer;
pub mod catalog_manager;
pub mod data_manager;
use sql::lexer::tokenize; | random_line_split |
lib.rs | #[macro_use(expect)]
extern crate expectest;
extern crate sql;
pub mod lexer;
pub mod parser;
pub mod query_typer;
pub mod query_validator;
pub mod query_executer;
pub mod catalog_manager;
pub mod data_manager;
use sql::lexer::tokenize;
use sql::parser::parse;
use sql::query_typer::type_inferring_old;
use sql::query... | {
tokenize(query)
.and_then(parse)
.and_then(|statement| type_inferring_old(catalog_manager, statement))
.and_then(|statement| validate_old(catalog_manager, statement))
.and_then(|statement| execute(catalog_manager, data_manager, statement))
} | identifier_body | |
lib.rs | #[macro_use(expect)]
extern crate expectest;
extern crate sql;
pub mod lexer;
pub mod parser;
pub mod query_typer;
pub mod query_validator;
pub mod query_executer;
pub mod catalog_manager;
pub mod data_manager;
use sql::lexer::tokenize;
use sql::parser::parse;
use sql::query_typer::type_inferring_old;
use sql::query... | (query: &str, data_manager: &DataManager, catalog_manager: &CatalogManager) -> Result<ExecutionResult, String> {
tokenize(query)
.and_then(parse)
.and_then(|statement| type_inferring_old(catalog_manager, statement))
.and_then(|statement| validate_old(catalog_manager, statement))
.and_the... | evaluate_query | identifier_name |
project-cache-issue-31849.rs | // run-pass
// Regression test for #31849: the problem here was actually a performance
// cliff, but I'm adding the test for reference.
pub trait Upcast<T> {
fn upcast(self) -> T;
}
impl<S1, S2, T1, T2> Upcast<(T1, T2)> for (S1,S2)
where S1: Upcast<T1>,
S2: Upcast<T2>,
{
fn upcast(self) -> (T1, ... |
impl<S,T> Factory for (S, T)
where S: Factory,
T: Factory,
S::Output: ToStatic,
<S::Output as ToStatic>::Static: Upcast<S::Output>,
{
type Output = (S::Output, T::Output);
fn build(&self) -> Self::Output { (self.0.build().to_static().upcast(), self.1.build()) }
}
impl Factory... | fn build(&self) -> Self::Output;
} | random_line_split |
project-cache-issue-31849.rs | // run-pass
// Regression test for #31849: the problem here was actually a performance
// cliff, but I'm adding the test for reference.
pub trait Upcast<T> {
fn upcast(self) -> T;
}
impl<S1, S2, T1, T2> Upcast<(T1, T2)> for (S1,S2)
where S1: Upcast<T1>,
S2: Upcast<T2>,
{
fn upcast(self) -> (T1, ... |
}
impl Upcast<()> for ()
{
fn upcast(self) -> () { () }
}
pub trait ToStatic {
type Static:'static;
fn to_static(self) -> Self::Static where Self: Sized;
}
impl<T, U> ToStatic for (T, U)
where T: ToStatic,
U: ToStatic
{
type Static = (T::Static, U::Static);
fn to_static(self) -> Se... | { (self.0.upcast(), self.1.upcast()) } | identifier_body |
project-cache-issue-31849.rs | // run-pass
// Regression test for #31849: the problem here was actually a performance
// cliff, but I'm adding the test for reference.
pub trait Upcast<T> {
fn upcast(self) -> T;
}
impl<S1, S2, T1, T2> Upcast<(T1, T2)> for (S1,S2)
where S1: Upcast<T1>,
S2: Upcast<T2>,
{
fn upcast(self) -> (T1, ... | (self) -> Self::Static { (self.0.to_static(), self.1.to_static()) }
}
impl ToStatic for ()
{
type Static = ();
fn to_static(self) -> () { () }
}
trait Factory {
type Output;
fn build(&self) -> Self::Output;
}
impl<S,T> Factory for (S, T)
where S: Factory,
T: Factory,
S::Outpu... | to_static | identifier_name |
prime_field.rs | use normalize::*;
use pack::Pack;
use rand::Rand;
use std::marker::Sized;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Neg;
use std::ops::Sub;
use std::ops::SubAssign;
| Div<Self, Output = Self> + DivAssign<Self> +
MulAssign<i32> + MulAssign<i16> + MulAssign<i8> + MulAssign<Self> +
Mul<i32, Output = Self> + Mul<i16, Output = Self> +
Mul<i8, Output = Self> + Mul<Self, Output = Self> +
Neg<Output = Self> + Normalize + NormalizeEq + Pack + Rand + Sized +
SubAssign<... | /// Operations on prime fields.
pub trait PrimeField : Add<i32, Output = Self> + Add<i16, Output = Self> +
Add<i8, Output = Self> + Add<Self, Output = Self> +
AddAssign<i32> + AddAssign<i16> + AddAssign<i8> + AddAssign<Self> + | random_line_split |
lib.rs | //! D-Bus bindings for Rust
//!
//! [D-Bus](http://dbus.freedesktop.org/) is a message bus, and is mainly used in Linux
//! for communication between processes. It is present by default on almost every
//! Linux distribution out there, and runs in two instances - one per session, and one
//! system-wide.
//!
//! See th... |
let mut v = Vec::new();
let mut i = 0;
loop {
let s = unsafe {
let citer = clist.offset(i);
if *citer == ptr::null_mut() { break };
std::mem::transmute(citer)
};
v.push(format!("{}", c_str_to_slice(s).unwrap()))... | { panic!("Out of memory"); } | conditional_block |
lib.rs | //! D-Bus bindings for Rust
//!
//! [D-Bus](http://dbus.freedesktop.org/) is a message bus, and is mainly used in Linux
//! for communication between processes. It is present by default on almost every
//! Linux distribution out there, and runs in two instances - one per session, and one
//! system-wide.
//!
//! See th... | {
conn: Cell<*mut ffi::DBusConnection>,
pending_items: RefCell<LinkedList<ConnectionItem>>,
}
/// A D-Bus connection. Start here if you want to get on the D-Bus!
pub struct Connection {
i: Box<IConnection>,
}
extern "C" fn filter_message_cb(conn: *mut ffi::DBusConnection, msg: *mut ffi::DBusMessage,
... | IConnection | identifier_name |
lib.rs | //! D-Bus bindings for Rust
//!
//! [D-Bus](http://dbus.freedesktop.org/) is a message bus, and is mainly used in Linux
//! for communication between processes. It is present by default on almost every
//! Linux distribution out there, and runs in two instances - one per session, and one
//! system-wide.
//!
//! See th... |
#[test]
fn object_path() {
use std::sync::mpsc;
let (tx, rx) = mpsc::channel();
let thread = ::std::thread::spawn(move || {
let c = Connection::get_private(BusType::Session).unwrap();
c.register_object_path("/hello").unwrap();
// println!("Waiting...... | assert_eq!(reply, vec!(MessageItem::Bool(true)));
} | random_line_split |
to_str.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | }
_ => cx.bug("expected Struct or EnumMatching in deriving(ToStr)")
};
} | } | random_line_split |
mod.rs | use alloc::boxed::{Box, FnBox};
use super::stack::Stack;
#[cfg(target_arch = "x86")]
mod i686;
#[cfg(target_arch = "x86_64")]
mod x86_64;
mod imp {
#[cfg(target_arch = "x86")]
pub use super::i686::*;
#[cfg(target_arch = "x86_64")]
pub use super::x86_64::*;
}
/// A thread has to be wrapped by a cal... |
#[inline(always)]
#[cfg_attr(feature = "clippy", allow(inline_always))]
/// Save the current context. This function will actually return twice.
/// The first return is just after saving the context and will return false
/// The second time is when the saved context gets restored and will return
... | {
unsafe {
imp::registers_load(&self.regs);
}
} | identifier_body |
mod.rs | use alloc::boxed::{Box, FnBox};
use super::stack::Stack;
#[cfg(target_arch = "x86")]
mod i686;
#[cfg(target_arch = "x86_64")]
mod x86_64;
mod imp {
#[cfg(target_arch = "x86")]
pub use super::i686::*;
#[cfg(target_arch = "x86_64")]
pub use super::x86_64::*;
}
/// A thread has to be wrapped by a cal... | <F>(wrapper: WrapperFn, mut f: F, stack: &mut Stack) -> Self
where F: FnMut() -> (), F: Send +'static {
let fun = move || {
f();
};
let boxed_fun: Box<FnBox()> = Box::new(fun);
let fun_ptr = Box::into_raw(Box::new(boxed_fun)) as *mut u8;
Context {
... | new | identifier_name |
mod.rs | use alloc::boxed::{Box, FnBox};
use super::stack::Stack;
#[cfg(target_arch = "x86")]
mod i686;
#[cfg(target_arch = "x86_64")]
mod x86_64;
mod imp {
#[cfg(target_arch = "x86")]
pub use super::i686::*;
#[cfg(target_arch = "x86_64")]
pub use super::x86_64::*;
}
/// A thread has to be wrapped by a cal... | pub fn load(&self) ->! {
unsafe {
imp::registers_load(&self.regs);
}
}
#[inline(always)]
#[cfg_attr(feature = "clippy", allow(inline_always))]
/// Save the current context. This function will actually return twice.
/// The first return is just after saving the contex... |
/// Load the current context to the CPU | random_line_split |
borrowck-preserve-box-in-pat.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 ... | // exec-env:RUST_POISON_ON_FREE=1
use std::ptr;
struct F { f: ~int }
pub fn main() {
let x = @mut @F {f: ~3};
match x {
@@F{f: ref b_x} => {
assert_eq!(**b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(x.f)), ptr::to_unsafe_ptr(b_x));
*x = @F {f: ~4};
info!("ptr::to_unsafe_pt... | // option. This file may not be copied, modified, or distributed
// except according to those terms.
| random_line_split |
borrowck-preserve-box-in-pat.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 ... | {
let x = @mut @F {f: ~3};
match x {
@@F{f: ref b_x} => {
assert_eq!(**b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(x.f)), ptr::to_unsafe_ptr(b_x));
*x = @F {f: ~4};
info!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
assert_... | identifier_body | |
borrowck-preserve-box-in-pat.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 ... | () {
let x = @mut @F {f: ~3};
match x {
@@F{f: ref b_x} => {
assert_eq!(**b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(x.f)), ptr::to_unsafe_ptr(b_x));
*x = @F {f: ~4};
info!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
asse... | main | identifier_name |
mdata_info.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... | else {
(false, Default::default(), Default::default())
}
}
fn enc_info_from_repr_c(
is_set: bool,
key: SymSecretKey,
nonce: SymNonce,
) -> Option<(shared_secretbox::Key, secretbox::Nonce)> {
if is_set {
Some((
shared_secretbox::Key::from_raw(&key),
secretbox... | {
(true, key.0, nonce.0)
} | conditional_block |
mdata_info.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... | (&mut self) {
if let Some(new_enc_info) = self.new_enc_info.take() {
self.enc_info = Some(new_enc_info);
}
}
/// Construct FFI wrapper for the native Rust object, consuming self.
pub fn into_repr_c(self) -> FfiMDataInfo {
let (has_enc_info, enc_key, enc_nonce) = enc_info... | commit_new_enc_info | identifier_name |
mdata_info.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... |
Ok(output)
}
fn encrypt_value(info: &MDataInfo, value: &Value) -> Result<Value, CoreError> {
Ok(Value {
content: info.enc_entry_value(&value.content)?,
entry_version: value.entry_version,
})
}
fn decrypt_value(info: &MDataInfo, value: &Value) -> Result<Value, CoreError> {
Ok(Value {
... | random_line_split | |
mdata_info.rs | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... |
fn encrypt_value(info: &MDataInfo, value: &Value) -> Result<Value, CoreError> {
Ok(Value {
content: info.enc_entry_value(&value.content)?,
entry_version: value.entry_version,
})
}
fn decrypt_value(info: &MDataInfo, value: &Value) -> Result<Value, CoreError> {
Ok(Value {
content: i... | {
let mut output = Vec::with_capacity(values.len());
for value in values {
output.push(decrypt_value(info, value)?);
}
Ok(output)
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.