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 |
|---|---|---|---|---|
zlib.rs | //! An Implementation of RFC 1950
//!
//! Decoding of zlib compressed streams.
//! |
use std::old_io;
use std::old_io::IoResult;
use super::hash::Adler32;
use super::deflate::Inflater;
enum ZlibState {
Start,
CompressedData,
End
}
/// A Zlib compressed stream decoder.
pub struct ZlibDecoder<R> {
inflate: Inflater<R>,
adler: Adler32,
state: ZlibState,
}
impl<R: Reader> ZlibD... | //! # Related Links
//! *http://tools.ietf.org/html/rfc1950 - ZLIB Compressed Data Format Specification | random_line_split |
zlib.rs | //! An Implementation of RFC 1950
//!
//! Decoding of zlib compressed streams.
//!
//! # Related Links
//! *http://tools.ietf.org/html/rfc1950 - ZLIB Compressed Data Format Specification
use std::old_io;
use std::old_io::IoResult;
use super::hash::Adler32;
use super::deflate::Inflater;
enum ZlibState {
Start,
... | (&mut self) -> &mut R {
self.inflate.inner()
}
fn read_header(&mut self) -> IoResult<()> {
let cmf = try!(self.inner().read_u8());
let _cm = cmf & 0x0F;
let _cinfo = cmf >> 4;
let flg = try!(self.inner().read_u8());
let fdict = (flg & 0b100000)!= 0;
if ... | inner | identifier_name |
zlib.rs | //! An Implementation of RFC 1950
//!
//! Decoding of zlib compressed streams.
//!
//! # Related Links
//! *http://tools.ietf.org/html/rfc1950 - ZLIB Compressed Data Format Specification
use std::old_io;
use std::old_io::IoResult;
use super::hash::Adler32;
use super::deflate::Inflater;
enum ZlibState {
Start,
... |
fn read_checksum(&mut self) -> IoResult<()> {
let stream_adler32 = try!(self.inner().read_be_u32());
let adler32 = self.adler.checksum();
assert!(adler32 == stream_adler32);
self.adler.reset();
Ok(())
}
}
impl<R: Reader> Reader for ZlibDecoder<R> {
fn read(&mut s... | {
let cmf = try!(self.inner().read_u8());
let _cm = cmf & 0x0F;
let _cinfo = cmf >> 4;
let flg = try!(self.inner().read_u8());
let fdict = (flg & 0b100000) != 0;
if fdict {
let _dictid = try!(self.inner().read_be_u32());
panic!("invalid png: zlib... | identifier_body |
regions-pattern-typing-issue-19997.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let a0 = 0;
let f = 1;
let mut a1 = &a0;
match (&a1,) {
(&ref b0,) => {
a1 = &f; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed
drop(b0);
}
}
} | identifier_body | |
regions-pattern-typing-issue-19997.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 ... | drop(b0);
}
}
} | //[mir]~^ ERROR cannot assign to `a1` because it is borrowed | random_line_split |
regions-pattern-typing-issue-19997.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let a0 = 0;
let f = 1;
let mut a1 = &a0;
match (&a1,) {
(&ref b0,) => {
a1 = &f; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed
drop(b0);
}
}
}
| main | identifier_name |
regions-pattern-typing-issue-19997.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 ... |
}
}
| {
a1 = &f; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed
drop(b0);
} | conditional_block |
git.rs | use std::fs::{self, File};
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use url::Url;
use git2;
use craft::util::ProcessError;
use support::{ProjectBuilder, project, path2url};
pub struct RepoBuilder {
repo: git2::Repository,
files: Vec<PathBuf>,
}
pub fn repo(p: &Path) -> RepoBuilder {
Repo... |
}
pub fn new<F>(name: &str, callback: F) -> Result<ProjectBuilder, ProcessError>
where F: FnOnce(ProjectBuilder) -> ProjectBuilder
{
let mut git_project = project(name);
git_project = callback(git_project);
git_project.build();
let repo = t!(git2::Repository::init(&git_project.root()));
let m... | {
path2url(self.repo.workdir().unwrap().to_path_buf())
} | identifier_body |
git.rs | use std::fs::{self, File};
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use url::Url;
use git2;
use craft::util::ProcessError;
use support::{ProjectBuilder, project, path2url};
pub struct RepoBuilder {
repo: git2::Repository,
files: Vec<PathBuf>,
}
pub fn repo(p: &Path) -> RepoBuilder {
Repo... | t!(repo.commit(Some("HEAD"), &sig, &sig, "test",
&t!(repo.find_tree(tree_id)),
&parents))
}
pub fn tag(repo: &git2::Repository, name: &str) {
let head = repo.head().unwrap().target().unwrap();
t!(repo.tag(name,
&t!(repo.find_object(head, None)),
... | match repo.head().ok().map(|h| h.target().unwrap()) {
Some(parent) => parents.push(t!(repo.find_commit(parent))),
None => {}
}
let parents = parents.iter().collect::<Vec<_>>(); | random_line_split |
git.rs | use std::fs::{self, File};
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use url::Url;
use git2;
use craft::util::ProcessError;
use support::{ProjectBuilder, project, path2url};
pub struct RepoBuilder {
repo: git2::Repository,
files: Vec<PathBuf>,
}
pub fn repo(p: &Path) -> RepoBuilder {
Repo... | (p: &Path) -> RepoBuilder {
t!(fs::create_dir_all(p.parent().unwrap()));
let repo = t!(git2::Repository::init(p));
{
let mut config = t!(repo.config());
t!(config.set_str("user.name", "name"));
t!(config.set_str("user.email", "email"));
}
RepoB... | init | identifier_name |
struct.rs | // 一个 `Borrowed` 类型,含有一个指向 `i32` 类型的引用。
// 指向 `i32` 的引用必须比 `Borrowed` 寿命更长。
// (原望:A type `Borrowed` which houses a reference to an
// `i32`. The reference to `i32` must outlive `Borrowed`.)
#[derive(Debug)]
struct Borrowed<'a>(&'a i32);
// 和前面类似,这里的两个引用都必须比这个结构体长寿。
#[derive(Debug)]
struct NamedBorrowed<'a> {
x: &... | println!("y is *not* borrowed in {:?}", number);
} | random_line_split | |
struct.rs | // 一个 `Borrowed` 类型,含有一个指向 `i32` 类型的引用。
// 指向 `i32` 的引用必须比 `Borrowed` 寿命更长。
// (原望:A type `Borrowed` which houses a reference to an
// `i32`. The reference to `i32` must outlive `Borrowed`.)
#[derive(Debug)]
struct Borrowed<'a>(&'a i32);
// 和前面类似,这里的两个引用都必须比这个结构体长寿。
#[derive(Debug)]
struct NamedBorrowed<'a> {
x: &... | ::Num(y);
println!("x is borrowed in {:?}", single);
println!("x and y are borrowed in {:?}", double);
println!("x is borrowed in {:?}", reference);
println!("y is *not* borrowed in {:?}", number);
}
| identifier_body | |
struct.rs | // 一个 `Borrowed` 类型,含有一个指向 `i32` 类型的引用。
// 指向 `i32` 的引用必须比 `Borrowed` 寿命更长。
// (原望:A type `Borrowed` which houses a reference to an
// `i32`. The reference to `i32` must outlive `Borrowed`.)
#[derive(Debug)]
struct Borrowed<'a>(&'a i32);
// 和前面类似,这里的两个引用都必须比这个结构体长寿。
#[derive(Debug)]
struct NamedBorrowed<'a> {
x: &... | erence = Either::Ref(&x);
let number = Either::Num(y);
println!("x is borrowed in {:?}", single);
println!("x and y are borrowed in {:?}", double);
println!("x is borrowed in {:?}", reference);
println!("y is *not* borrowed in {:?}", number);
}
| et ref | identifier_name |
kms.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use async_trait::async_trait;
use crate::error::{Error, KmsError, Result};
use derive_more::Deref;
use kvproto::encryptionpb::MasterKeyKms;
#[derive(Debug, Clone)]
pub struct Location {
pub region: String,
pub endpoint: String,
}
#[derive(De... | region: mk.region,
endpoint: mk.endpoint,
},
vendor: mk.vendor,
})
}
}
#[derive(PartialEq, Debug, Clone, Deref)]
pub struct KeyId(String);
// KeyID is a newtype to mark a String as an ID of a key
// This ID exists in a foreign system such as AWS
// T... | location: Location { | random_line_split |
kms.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use async_trait::async_trait;
use crate::error::{Error, KmsError, Result};
use derive_more::Deref;
use kvproto::encryptionpb::MasterKeyKms;
#[derive(Debug, Clone)]
pub struct Location {
pub region: String,
pub endpoint: String,
}
#[derive(De... | (String);
// KeyID is a newtype to mark a String as an ID of a key
// This ID exists in a foreign system such as AWS
// The key id must be non-empty
impl KeyId {
pub fn new(id: String) -> Result<KeyId> {
if id.is_empty() {
let msg = "KMS key id can not be empty";
Err(Error::KmsError... | KeyId | identifier_name |
kms.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use async_trait::async_trait;
use crate::error::{Error, KmsError, Result};
use derive_more::Deref;
use kvproto::encryptionpb::MasterKeyKms;
#[derive(Debug, Clone)]
pub struct Location {
pub region: String,
pub endpoint: String,
}
#[derive(De... |
}
#[derive(Debug)]
pub struct DataKeyPair {
pub encrypted: EncryptedKey,
pub plaintext: PlainKey,
}
#[async_trait]
pub trait KmsProvider: Sync + Send +'static + std::fmt::Debug {
async fn generate_data_key(&self) -> Result<DataKeyPair>;
async fn decrypt_data_key(&self, data_key: &EncryptedKey) -> Res... | {
f.debug_tuple("PlainKey")
.field(&"REDACTED".to_string())
.finish()
} | identifier_body |
kms.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use async_trait::async_trait;
use crate::error::{Error, KmsError, Result};
use derive_more::Deref;
use kvproto::encryptionpb::MasterKeyKms;
#[derive(Debug, Clone)]
pub struct Location {
pub region: String,
pub endpoint: String,
}
#[derive(De... | else {
Ok(Self(key))
}
}
}
// PlainKey is a newtype used to mark a vector a plaintext key.
// It requires the vec to be a valid AesGcmCrypter key.
#[derive(Deref)]
pub struct PlainKey(Vec<u8>);
impl PlainKey {
pub fn new(key: Vec<u8>) -> Result<Self> {
// TODO: crypter.rs in encry... | {
Err(Error::KmsError(KmsError::EmptyKey(
"Encrypted Key".to_owned(),
)))
} | conditional_block |
ws_server.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/. */
extern crate url;
use self::url::Url;
use foxbox_core::traits::Controller;
use std::thread;
use ws;
use ws::{ Hand... | <T: Controller>(controller: T) {
let addrs: Vec<_> = controller.ws_as_addrs().unwrap().collect();
thread::Builder::new().name("WsServer".to_owned()).spawn(move || {
listen(addrs[0], |out| {
WsHandler {
out: out,
controller: controller.... | start | identifier_name |
ws_server.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/. */
extern crate url;
use self::url::Url;
use foxbox_core::traits::Controller;
use std::thread;
use ws;
use ws::{ Hand... |
}
| {
error!("The ws server encountered an error: {:?}", err);
} | identifier_body |
ws_server.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/. */
extern crate url;
use self::url::Url;
use foxbox_core::traits::Controller;
use std::thread;
use ws;
use ws::{ Hand... | }
fn on_message(&mut self, msg: Message) -> Result<()> {
info!("Message from websocket ({:?}): {}", self.out.token(), msg);
Ok(())
}
fn on_close(&mut self, code: CloseCode, reason: &str) {
match code {
CloseCode::Normal => info!("The ws client is done with the conn... |
Ok(()) | random_line_split |
inner_template_self.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LinkedList {
pub next: *mut LinkedList,
pub prev: *mut LinkedList,
}
impl Default for LinkedList {
fn default() -> Self {
let mut s = ::std::mem::... | concat!("Size of template specialization: ", stringify!(LinkedList))
);
assert_eq!(
::std::mem::align_of::<LinkedList>(),
8usize,
concat!(
"Alignment of template specialization: ",
stringify!(LinkedList)
)
);
} | ::std::mem::size_of::<LinkedList>(),
16usize, | random_line_split |
inner_template_self.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct | {
pub next: *mut LinkedList,
pub prev: *mut LinkedList,
}
impl Default for LinkedList {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
... | LinkedList | identifier_name |
inner_template_self.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LinkedList {
pub next: *mut LinkedList,
pub prev: *mut LinkedList,
}
impl Default for LinkedList {
fn default() -> Self {
let mut s = ::std::mem::... | "::",
stringify!(m_list)
)
);
}
impl Default for InstantiateIt {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[test... | {
assert_eq!(
::std::mem::size_of::<InstantiateIt>(),
16usize,
concat!("Size of: ", stringify!(InstantiateIt))
);
assert_eq!(
::std::mem::align_of::<InstantiateIt>(),
8usize,
concat!("Alignment of ", stringify!(InstantiateIt))
);
assert_eq!(
un... | identifier_body |
lib.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.
*/
#![deny(clippy::all)]
mod client;
mod code_action;
pub mod completion;
pub mod diagnostic_reporter;
mod explore_schema_for_type;... | use lsp_server::Connection;
use relay_compiler::config::Config;
use schema_documentation::{SchemaDocumentation, SchemaDocumentationLoader};
pub use server::LSPNotificationDispatch;
pub use server::LSPRequestDispatch;
pub use server::{GlobalState, LSPState, Schemas};
use std::sync::Arc;
pub use utils::position_to_offset... | pub use lsp_extra_data_provider::{
FieldDefinitionSourceInfo, FieldSchemaInfo, LSPExtraDataProvider,
};
use lsp_process_error::LSPProcessResult;
pub use lsp_runtime_error::{LSPRuntimeError, LSPRuntimeResult}; | random_line_split |
lib.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.
*/
#![deny(clippy::all)]
mod client;
mod code_action;
pub mod completion;
pub mod diagnostic_reporter;
mod explore_schema_for_type;... | <
TPerfLogger,
TSchemaDocumentation: SchemaDocumentation +'static,
>(
config: Config,
perf_logger: Arc<TPerfLogger>,
extra_data_provider: Box<dyn LSPExtraDataProvider + Send + Sync>,
schema_documentation_loader: Option<Box<dyn SchemaDocumentationLoader<TSchemaDocumentation>>>,
js_language_se... | start_language_server | identifier_name |
lib.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.
*/
#![deny(clippy::all)]
mod client;
mod code_action;
pub mod completion;
pub mod diagnostic_reporter;
mod explore_schema_for_type;... | Ok(())
}
}
| {
// Test with an in-memory connection pair
let (connection, client) = Connection::memory();
// Mock set of client parameters. The `root_path` field is deprecated, but
// still required to construct the params, so we allow deprecated fields here.
#[allow(deprecated)]
let ... | 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... |
}
impl Attr {
pub fn set_value(&self, mut value: AttrValue, owner: &Element) {
let name = self.local_name().clone();
let namespace = self.namespace().clone();
let old_value = DOMString::from(&**self.value());
let new_value = DOMString::from(&*value);
let mutation = Mutatio... | {
true // Always returns true
} | 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... | (&self) -> Option<DOMString> {
match self.identifier.namespace {
ns!() => None,
ref url => Some(DOMString::from(&**url)),
}
}
// https://dom.spec.whatwg.org/#dom-attr-prefix
fn GetPrefix(&self) -> Option<DOMString> {
// FIXME(ajeffrey): convert directly from ... | GetNamespaceURI | identifier_name |
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... |
// https://dom.spec.whatwg.org/#dom-attr-specified
fn Specified(&self) -> bool {
true // Always returns true
}
}
impl Attr {
pub fn set_value(&self, mut value: AttrValue, owner: &Element) {
let name = self.local_name().clone();
let namespace = self.namespace().clone();
... | 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... |
(Some(old), Some(new)) => assert!(&*old == new),
_ => {},
}
self.owner.set(owner);
}
pub fn owner(&self) -> Option<Root<Element>> {
self.owner.get()
}
pub fn summarize(&self) -> AttrInfo {
AttrInfo {
namespace: (*self.identifier.name... | {
// Already gone from the list of attributes of old owner.
assert!(old.get_attribute(&ns, &self.identifier.local_name).r() != Some(self))
} | conditional_block |
stack.rs | // http://rosettacode.org/wiki/Stack
#[derive(Debug)]
struct Stack<T> {
/// We use a vector because of simplicity
vec: Vec<T>,
}
impl<T> Stack<T> {
fn new() -> Stack<T> {
Stack { vec: Vec::new() }
}
/// Adds an element at the top of the stack
fn push(&mut self, elem: T) {
self.... | // The element at the top is now 8
assert!(stack.peek().unwrap() == &8);
}
| {
let mut stack = Stack::new();
// The stack is empty
assert!(stack.empty());
// Fill the stack
stack.push(5i32);
stack.push(8);
stack.push(9);
// The stack is not empty
assert!(!stack.empty());
// The element at the top is 9
assert!(stack.peek().unwrap() == &9);
// ... | identifier_body |
stack.rs | // http://rosettacode.org/wiki/Stack
#[derive(Debug)]
struct Stack<T> {
/// We use a vector because of simplicity
vec: Vec<T>,
}
impl<T> Stack<T> {
fn new() -> Stack<T> {
Stack { vec: Vec::new() }
}
/// Adds an element at the top of the stack
fn push(&mut self, elem: T) {
self.... | // The stack is not empty
assert!(!stack.empty());
// The element at the top is 9
assert!(stack.peek().unwrap() == &9);
// Remove one element
stack.pop();
// The element at the top is now 8
assert!(stack.peek().unwrap() == &8);
} | stack.push(9);
| random_line_split |
stack.rs | // http://rosettacode.org/wiki/Stack
#[derive(Debug)]
struct Stack<T> {
/// We use a vector because of simplicity
vec: Vec<T>,
}
impl<T> Stack<T> {
fn new() -> Stack<T> {
Stack { vec: Vec::new() }
}
/// Adds an element at the top of the stack
fn push(&mut self, elem: T) {
self.... | else {
println!("The stack is not empty.")
}
}
#[test]
fn test_basic() {
let mut stack = Stack::new();
// The stack is empty
assert!(stack.empty());
// Fill the stack
stack.push(5i32);
stack.push(8);
stack.push(9);
// The stack is not empty
assert!(!stack.empty());
... | {
println!("The stack is empty.")
} | conditional_block |
stack.rs | // http://rosettacode.org/wiki/Stack
#[derive(Debug)]
struct Stack<T> {
/// We use a vector because of simplicity
vec: Vec<T>,
}
impl<T> Stack<T> {
fn | () -> Stack<T> {
Stack { vec: Vec::new() }
}
/// Adds an element at the top of the stack
fn push(&mut self, elem: T) {
self.vec.push(elem);
}
/// Removes and returns the element at the top of the stack
fn pop(&mut self) -> Option<T> {
self.vec.pop()
}
/// Retur... | new | identifier_name |
xmlerror.rs | use xmlutil::{XmlParseError, Peek, Next};
use xmlutil::{characters, start_element, end_element, string_field, peek_at_name};
#[derive(Default, Debug)]
pub struct XmlError {
pub error_type: String,
pub code: String,
pub message: String,
pub detail: Option<String>,
}
pub struct XmlErrorDeserializer;
imp... | continue;
}
"Detail" => {
try!(start_element("Detail", stack));
if let Ok(characters) = characters(stack) {
obj.detail = Some(characters.to_string());
try!(end_element("Detail", st... | continue;
}
"Message" => {
obj.message = try!(string_field("Message", stack)); | random_line_split |
xmlerror.rs | use xmlutil::{XmlParseError, Peek, Next};
use xmlutil::{characters, start_element, end_element, string_field, peek_at_name};
#[derive(Default, Debug)]
pub struct XmlError {
pub error_type: String,
pub code: String,
pub message: String,
pub detail: Option<String>,
}
pub struct XmlErrorDeserializer;
imp... |
_ => break,
}
}
try!(end_element(tag_name, stack));
Ok(obj)
}
}
| {
try!(start_element("Detail", stack));
if let Ok(characters) = characters(stack) {
obj.detail = Some(characters.to_string());
try!(end_element("Detail", stack));
}
continue;
} | conditional_block |
xmlerror.rs | use xmlutil::{XmlParseError, Peek, Next};
use xmlutil::{characters, start_element, end_element, string_field, peek_at_name};
#[derive(Default, Debug)]
pub struct XmlError {
pub error_type: String,
pub code: String,
pub message: String,
pub detail: Option<String>,
}
pub struct | ;
impl XmlErrorDeserializer {
pub fn deserialize<T: Peek + Next>(tag_name: &str,
stack: &mut T)
-> Result<XmlError, XmlParseError> {
try!(start_element(tag_name, stack));
let mut obj = XmlError::default();
loop {... | XmlErrorDeserializer | identifier_name |
generation.rs | use std::sync::Arc;
use cge::{Network, Activation};
use rand::thread_rng;
use rand::distributions::{IndependentSample, Range};
use crate::utils::Individual;
use crate::cge_utils::Mutation;
use crate::NNFitnessFunction;
// Creates a generation of random, minimal neural networks
pub fn initialize_generation<T>(populat... | }
// Make sure all inputs are connected
for individual in &mut generation {
let range = Range::new(0, outputs);
for i in 0..inputs {
if individual.get_input_copies(i) == 0 {
let id = range.ind_sample(&mut rng);
let index = individual.network.get_... | {
let mut rng = thread_rng();
let mut generation = Vec::new();
for _ in 0..population_size * (offspring_count + 1) {
let mut network = Network {
size: 0,
genome: Vec::new(),
function: activation.clone(),
};
for i in (0..outputs).rev() {
... | identifier_body |
generation.rs | use std::sync::Arc;
use cge::{Network, Activation};
use rand::thread_rng;
use rand::distributions::{IndependentSample, Range};
use crate::utils::Individual;
use crate::cge_utils::Mutation;
use crate::NNFitnessFunction;
// Creates a generation of random, minimal neural networks
pub fn | <T>(population_size: usize,
offspring_count: usize,
inputs: usize,
outputs: usize,
activation: Activation,
object: Arc<T>) -> Vec<Individual<T>>
where T: NN... | initialize_generation | identifier_name |
generation.rs | use std::sync::Arc;
use cge::{Network, Activation};
use rand::thread_rng;
use rand::distributions::{IndependentSample, Range};
use crate::utils::Individual;
use crate::cge_utils::Mutation;
use crate::NNFitnessFunction;
// Creates a generation of random, minimal neural networks
pub fn initialize_generation<T>(populat... | individual.add_input(i, index);
}
}
}
generation
} | if individual.get_input_copies(i) == 0 {
let id = range.ind_sample(&mut rng);
let index = individual.network.get_neuron_index(id).unwrap() + 1;
| random_line_split |
generation.rs | use std::sync::Arc;
use cge::{Network, Activation};
use rand::thread_rng;
use rand::distributions::{IndependentSample, Range};
use crate::utils::Individual;
use crate::cge_utils::Mutation;
use crate::NNFitnessFunction;
// Creates a generation of random, minimal neural networks
pub fn initialize_generation<T>(populat... |
}
}
generation
}
| {
let id = range.ind_sample(&mut rng);
let index = individual.network.get_neuron_index(id).unwrap() + 1;
individual.add_input(i, index);
} | conditional_block |
check_static.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 ... |
_ => { visit::walk_item(self, i, false) }
}
}
/// This method is used to enforce the constraints on
/// immutable static items. It walks through the *value*
/// of the item walking down the expression and evaluating
/// every nested expression. if the expression is not part
... | {
match mutability {
ast::MutImmutable => {
self.visit_expr(&**expr, true);
}
ast::MutMutable => {
let safe = safe_type_for_static_mut(self.tcx, &**expr);
self.report_error... | conditional_block |
check_static.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Verifies that th... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
check_static.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 ... |
impl<'a> CheckStaticVisitor<'a> {
fn report_error(&self, span: Span, result: Option<String>) -> bool {
match result {
None => { false }
Some(msg) => {
self.tcx.sess.span_err(span, msg.as_slice());
true
}
}
}
}
impl<'a> Visito... | {
visit::walk_crate(&mut CheckStaticVisitor { tcx: tcx }, krate, false)
} | identifier_body |
check_static.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> {
tcx: &'a ty::ctxt,
}
pub fn check_crate(tcx: &ty::ctxt, krate: &ast::Crate) {
visit::walk_crate(&mut CheckStaticVisitor { tcx: tcx }, krate, false)
}
impl<'a> CheckStaticVisitor<'a> {
fn report_error(&self, span: Span, result: Option<String>) -> bool {
match result {
None => { f... | CheckStaticVisitor | identifier_name |
generic-object.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 = box S { x: 1 };
let y = x as Box<Foo<isize>>;
assert_eq!(y.get(), 1);
} | identifier_body | |
generic-object.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 | // run-pass
#![feature(box_syntax)]
trait Foo<T> {
fn get(&self) -> T;
}
struct S {
x: isize
}
impl Foo<isize> for S {
fn get(&self) -> isize {
self.x
}
}
pub fn main() {
let x = box S { x: 1 };
let y = x as Box<Foo<isize>>;
assert_eq!(y.get(), 1);
} | // 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.
| random_line_split |
generic-object.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 = box S { x: 1 };
let y = x as Box<Foo<isize>>;
assert_eq!(y.get(), 1);
}
| main | identifier_name |
main.rs | use std::env;
use std::fs::File;
use std::io::Read;
use std::path::Path;
enum Lang {
Python,
Unknown,
}
struct CommentDelimiters {
begin: &'static str,
end: &'static str,
}
fn main() {
let fname = env::args().nth(1).unwrap();
let lang = lang_guess(&fname);
let delims = comment_delims(lang... | fn lang_guess(s: &String) -> Lang {
let path = Path::new(&s);
let ext = path.extension();
match ext {
Some(x) => {
let y = x.to_str().unwrap();
match y {
"py" => Lang::Python,
_ => Lang::Unknown,
}
},
None => Lang::U... | random_line_split | |
main.rs | use std::env;
use std::fs::File;
use std::io::Read;
use std::path::Path;
enum Lang {
Python,
Unknown,
}
struct CommentDelimiters {
begin: &'static str,
end: &'static str,
}
fn main() {
let fname = env::args().nth(1).unwrap();
let lang = lang_guess(&fname);
let delims = comment_delims(lang... | (s: &String) -> Lang {
let path = Path::new(&s);
let ext = path.extension();
match ext {
Some(x) => {
let y = x.to_str().unwrap();
match y {
"py" => Lang::Python,
_ => Lang::Unknown,
}
},
None => Lang::Unknown,
}... | lang_guess | identifier_name |
test_multiverse_handling.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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... | ]
})
}
} | output_dir: "test_outputs",
query_expects: vec![
("test_query1_true", true),
("test_query2_false", false) | random_line_split |
test_multiverse_handling.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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... | () {
setup_dirs_and_run_query_test(QueryTest {
filename: "multiverse_handling",
input_dir: "test_inputs",
output_dir: "test_outputs",
query_expects: vec![
("test_query1_true", true),
("test_query2_false", false)
]
... | test_multiverse_handling | identifier_name |
test_multiverse_handling.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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
}
| {
setup_dirs_and_run_query_test(QueryTest {
filename: "multiverse_handling",
input_dir: "test_inputs",
output_dir: "test_outputs",
query_expects: vec![
("test_query1_true", true),
("test_query2_false", false)
]
}... | identifier_body |
factory.rs | // Integration tests
extern crate txtdb;
use txtdb::controller::*;
use txtdb::factory::*;
#[test]
fn test_create_record() {
let input = String::from_str("1 payload metadata");
let expected = Record {
id: 1,
payload: String::from_str("payload"),
metadata: String::from_str("metadata"),
... | () {
let input = String::from_str("5 cGF5bG9hZA== bWV0YWRhdGE=");
let expected = Record {
id: 5,
payload: String::from_str("payload"),
metadata: String::from_str("metadata"),
};
let reader = Reader::new(&Path::new("tests/base-test.txt"));
let factory: Factory = RecordFactory:... | test_create_from_encoded | identifier_name |
factory.rs |
extern crate txtdb;
use txtdb::controller::*;
use txtdb::factory::*;
#[test]
fn test_create_record() {
let input = String::from_str("1 payload metadata");
let expected = Record {
id: 1,
payload: String::from_str("payload"),
metadata: String::from_str("metadata"),
};
let reader... | // Integration tests | random_line_split | |
factory.rs | // Integration tests
extern crate txtdb;
use txtdb::controller::*;
use txtdb::factory::*;
#[test]
fn test_create_record() |
#[test]
fn test_create_from_encoded() {
let input = String::from_str("5 cGF5bG9hZA== bWV0YWRhdGE=");
let expected = Record {
id: 5,
payload: String::from_str("payload"),
metadata: String::from_str("metadata"),
};
let reader = Reader::new(&Path::new("tests/base-test.txt"));
... | {
let input = String::from_str("1 payload metadata");
let expected = Record {
id: 1,
payload: String::from_str("payload"),
metadata: String::from_str("metadata"),
};
let reader = Reader::new(&Path::new("tests/base-test.txt"));
let factory: Factory = RecordFactory::new(reader)... | identifier_body |
road.rs | //! `StructureRoad` data description.
use crate::data::RoomName;
with_structure_fields_and_update_struct! {
/// A road structure - a structure that speeds up creeps without sufficient move parts.
#[derive(Clone, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct StructureRoad {
//... | y: 20,
id: "58a1ec36947c6c2d324a2d39".to_owned(),
hits: 2600,
hits_max: 5000,
next_decay_time: 19894066,
notify_when_attacked: true,
}
);
obj.update(
serde_json::from_value(json!({
... | {
let json = json!({
"_id": "58a1ec36947c6c2d324a2d39",
"hits": 2600,
"hitsMax": 5000,
"nextDecayTime": 19894066,
"notifyWhenAttacked": true,
"room": "E4S61",
"type": "road",
"x": 14,
"y": 20
});
... | identifier_body |
road.rs | //! `StructureRoad` data description.
use crate::data::RoomName;
with_structure_fields_and_update_struct! {
/// A road structure - a structure that speeds up creeps without sufficient move parts.
#[derive(Clone, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct StructureRoad {
//... | }
);
obj.update(
serde_json::from_value(json!({
// note: these are fake values, not a real update.
"hits": 2000,
"nextDecayTime": 20000000,
}))
.unwrap(),
);
assert_eq!(
obj,
... | id: "58a1ec36947c6c2d324a2d39".to_owned(),
hits: 2600,
hits_max: 5000,
next_decay_time: 19894066,
notify_when_attacked: true, | random_line_split |
road.rs | //! `StructureRoad` data description.
use crate::data::RoomName;
with_structure_fields_and_update_struct! {
/// A road structure - a structure that speeds up creeps without sufficient move parts.
#[derive(Clone, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct StructureRoad {
//... | () {
let json = json!({
"_id": "58a1ec36947c6c2d324a2d39",
"hits": 2600,
"hitsMax": 5000,
"nextDecayTime": 19894066,
"notifyWhenAttacked": true,
"room": "E4S61",
"type": "road",
"x": 14,
"y": 20
}... | parse_road_and_update | identifier_name |
candidate.rs |
use super::events::*;
use super::server::RaftServerState;
use super::server::{RaftStateTransition, NextState, Continue};
use super::server::{RaftNextState, RaftLeader, RaftFollower};
// This file contains all the callback logic for Candidate Peers in
// Raft.
//
// Rust doesn't support arbitrary methods being define... | (&mut self) -> RaftStateTransition {
Continue
}
fn candidate_teardown(&mut self) {
}
fn candidate_append_entries_req(&mut self, req: AppendEntriesReq, chan: Sender<AppendEntriesRes>) -> RaftStateTransition {
Continue
}
fn candidate_append_entries_res(&mut self, res: AppendEnt... | candidate_setup | identifier_name |
candidate.rs | use super::events::*;
use super::server::RaftServerState;
use super::server::{RaftStateTransition, NextState, Continue};
use super::server::{RaftNextState, RaftLeader, RaftFollower};
// This file contains all the callback logic for Candidate Peers in
// Raft.
//
// Rust doesn't support arbitrary methods being defined... | pub trait Candidate {
fn candidate_setup(&mut self) -> RaftStateTransition;
fn candidate_teardown(&mut self);
fn candidate_append_entries_req(&mut self, req: AppendEntriesReq, chan: Sender<AppendEntriesRes>) -> RaftStateTransition;
fn candidate_append_entries_res(&mut self, res: AppendEntriesRes) -> Ra... | random_line_split | |
candidate.rs |
use super::events::*;
use super::server::RaftServerState;
use super::server::{RaftStateTransition, NextState, Continue};
use super::server::{RaftNextState, RaftLeader, RaftFollower};
// This file contains all the callback logic for Candidate Peers in
// Raft.
//
// Rust doesn't support arbitrary methods being define... |
fn candidate_append_entries_res(&mut self, res: AppendEntriesRes) -> RaftStateTransition {
Continue
}
fn candidate_vote_req(&mut self, req: VoteReq, chan: Sender<VoteRes>) -> RaftStateTransition {
Continue
}
fn candidate_vote_res(&mut self, res: VoteRes) -> RaftStateTransition ... | {
Continue
} | identifier_body |
knl.rs | #![feature(specialization)]
#![feature(conservative_impl_trait)]
#![feature(cfg_target_feature)]
#![feature(asm)]
#![allow(unused_imports)]
extern crate core;
extern crate typenum;
extern crate momms;
use std::time::{Instant};
use typenum::{Unsigned,U1};
use momms::kern::KernelNM;
use momms::matrix::{Scalar, Mat, C... | () {
test( );
}
| main | identifier_name |
knl.rs | #![feature(specialization)]
#![feature(conservative_impl_trait)]
#![feature(cfg_target_feature)]
#![feature(asm)]
#![allow(unused_imports)]
extern crate core;
extern crate typenum;
extern crate momms;
use std::time::{Instant};
use typenum::{Unsigned,U1};
use momms::kern::KernelNM;
use momms::matrix::{Scalar, Mat, C... | type NC = U14400;
type KC = typenum::U336; //
type MC = typenum::U120;
type MR = typenum::U24;//
type NR = typenum::U8;//
type JCWAY = Target<typenum::U4>;
type Goto<T,MTA,MTB,MTC>
= SpawnThreads<T, MTA, MTB, MTC,
ParallelN<T, MTA, MTB, MTC, NR, JCWAY,
... | {
use typenum::{UInt, UTerm, B0, B1, Unsigned};
//type U3000 = UInt<UInt<typenum::U750, B0>, B0>;
//type NC = U3000;
//type KC = typenum::U192;
//type MC = typenum::U120;
//type MR = typenum::U8; //typenum::U4;
//type NR = typenum::U4; //typenum::U12;
//type Goto<T,MTA,MTB,MTC>
/... | identifier_body |
knl.rs | #![feature(specialization)]
#![feature(conservative_impl_trait)]
#![feature(cfg_target_feature)]
#![feature(asm)]
#![allow(unused_imports)]
extern crate core;
extern crate typenum;
extern crate momms;
use std::time::{Instant};
use typenum::{Unsigned,U1};
use momms::kern::KernelNM;
use momms::matrix::{Scalar, Mat, C... | fn main() {
test( );
} | random_line_split | |
overloaded-autoderef.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.
// |
use std::cell::RefCell;
use std::rc::Rc;
use std::string::String;
#[deriving(PartialEq, Show)]
struct Point {
x: int,
y: int
}
pub fn main() {
assert_eq!(Rc::new(5u).to_uint(), Some(5));
assert_eq!((box &box &Rc::new(box box &box 5u)).to_uint(), Some(5));
let point = Rc::new(Point {x: 2, y: 4});
... | // 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. | random_line_split |
overloaded-autoderef.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 ... | () {
assert_eq!(Rc::new(5u).to_uint(), Some(5));
assert_eq!((box &box &Rc::new(box box &box 5u)).to_uint(), Some(5));
let point = Rc::new(Point {x: 2, y: 4});
assert_eq!(point.x, 2);
assert_eq!(point.y, 4);
let i = Rc::new(RefCell::new(2));
let i_value = *i.borrow();
*i.borrow_mut() = 5... | main | identifier_name |
main.rs | #![feature(env, old_io, old_path)]
extern crate zip;
use std::env;
use std::old_io::File;
use zip::ZipReader;
use zip::fileinfo::FileInfo;
// this is public so that rustdoc doesn't complain
pub fn | () {
let args: Vec<_> = env::args().collect(); // XXX
match args.len(){
2 => list_content(&mut zip_file(&args[1])),
3 => extract_file(&mut zip_file(&args[1]), &args[2]),
4 => extract_head(&mut zip_file(&args[1]), &args[2], &args[3]),
_ => print_usage(&args[0])
}
}
macro_rule... | main | identifier_name |
main.rs | #![feature(env, old_io, old_path)]
extern crate zip;
use std::env;
use std::old_io::File;
use zip::ZipReader;
use zip::fileinfo::FileInfo;
// this is public so that rustdoc doesn't complain
pub fn main() {
let args: Vec<_> = env::args().collect(); // XXX
match args.len(){
2 => list_content(&mut zip_f... |
fn list_content(reader: &mut ZipReader<File>)->(){
for file in reader.files(){
let (year, month, day, hour, minute, second) = file.last_modified_datetime;
let mod_time = format!("{:04}-{:02}-{:02} {:02}:{:02}:{:02}", year, month, day, hour, minute, second);
println!("{} ({}): bytes: {:10},... | {
do_or_die!(zip.info(file))
} | identifier_body |
main.rs | #![feature(env, old_io, old_path)]
extern crate zip;
use std::env;
use std::old_io::File;
use zip::ZipReader;
use zip::fileinfo::FileInfo;
// this is public so that rustdoc doesn't complain | match args.len(){
2 => list_content(&mut zip_file(&args[1])),
3 => extract_file(&mut zip_file(&args[1]), &args[2]),
4 => extract_head(&mut zip_file(&args[1]), &args[2], &args[3]),
_ => print_usage(&args[0])
}
}
macro_rules! do_or_die{
($expr:expr) => (match $expr {
O... | pub fn main() {
let args: Vec<_> = env::args().collect(); // XXX | random_line_split |
lib.rs | //! FFI bindings to the wayland system libraries. | //! the `ffi_dispatch` macro, like this:
//!
//! ```ignore
//! ffi_dispatch!(HANDLE_NAME, func_name, arg1, arg2, arg3);
//! ```
//!
//! Where `HANDLE_NAME` is the name of the handle generated if the cargo feature `dlopen` is on.
//!
//! For this to work, you must ensure every needed symbol is in scope (aka the static h... | //!
//! The names exported by this crate should *not* be used directly, but through | random_line_split |
test.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::collections::BTreeMap;
use std::io::Read;
use serde_json;
use serde_json::Error;
use trie::Trie;
/// TransactionTest test deserializer.
#[derive(Debug, PartialEq, Deserialize)]
pub struct Test(BTreeMap<String, Trie>);
impl IntoIterator for Test {
type Item = <BTreeMap<String, Trie> as IntoIterator>::Item;
... |
//! TransactionTest test deserializer. | random_line_split |
test.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... | (BTreeMap<String, Trie>);
impl IntoIterator for Test {
type Item = <BTreeMap<String, Trie> as IntoIterator>::Item;
type IntoIter = <BTreeMap<String, Trie> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl Test {
/// Loads test from json.
pub fn load<R>(reader: R) ... | Test | identifier_name |
llrepr.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<T:LlvmRepr> LlvmRepr for [T] {
fn llrepr(&self, ccx: &CrateContext) -> String {
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
format!("[{}]", reprs.connect(","))
}
}
impl LlvmRepr for Type {
fn llrepr(&self, ccx: &CrateContext) -> String {
ccx.tn().typ... | fn llrepr(&self, ccx: &CrateContext) -> String;
} | random_line_split |
llrepr.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 ... | (&self, ccx: &CrateContext) -> String {
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
format!("[{}]", reprs.connect(","))
}
}
impl LlvmRepr for Type {
fn llrepr(&self, ccx: &CrateContext) -> String {
ccx.tn().type_to_string(*self)
}
}
impl LlvmRepr for Valu... | llrepr | identifier_name |
llrepr.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 LlvmRepr for Type {
fn llrepr(&self, ccx: &CrateContext) -> String {
ccx.tn().type_to_string(*self)
}
}
impl LlvmRepr for ValueRef {
fn llrepr(&self, ccx: &CrateContext) -> String {
ccx.tn().val_to_string(*self)
}
}
| {
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
format!("[{}]", reprs.connect(","))
} | identifier_body |
shootout-k-nucleotide-pipes.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | let len = bb.len();
while ii < len - (nn - 1u) {
it(bb[ii..ii+nn]);
ii += 1u;
}
return bb[len - (nn - 1u)..len].to_vec();
}
fn make_sequence_processor(sz: uint,
from_parent: &Receiver<Vec<u8>>,
to_parent: &Sender<String>) {
let mut freqs... | // i.e., for "hello" and windows of size four,
// run it("hell") and it("ello"), then return "llo"
fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> {
let mut ii = 0u;
| random_line_split |
shootout-k-nucleotide-pipes.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (mm: &HashMap<Vec<u8>, uint>, total: uint) -> String {
fn pct(xx: uint, yy: uint) -> f64 {
return (xx as f64) * 100.0 / (yy as f64);
}
// sort by key, then by value
fn sortKV(mut orig: Vec<(Vec<u8>,f64)> ) -> Vec<(Vec<u8>,f64)> {
orig.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b));
orig... | sort_and_fmt | identifier_name |
shootout-k-nucleotide-pipes.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
6u => { format!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
12u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
18u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
"GGTATTTTAATTTATAGT") }
_ => { ""... | { format!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") } | conditional_block |
shootout-k-nucleotide-pipes.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | from_child.push(from_child_);
let (to_child, from_parent) = channel();
spawn(proc() {
make_sequence_processor(sz, &from_parent, &to_parent_);
});
to_child
}).collect::<Vec<Sender<Vec<u8> >> >();
// latch stores true after we've started
// reading the se... | {
use std::io::{stdio, MemReader, BufferedReader};
let rdr = if os::getenv("RUST_BENCH").is_some() {
let foo = include_bin!("shootout-k-nucleotide.data");
box MemReader::new(foo.to_vec()) as Box<Reader>
} else {
box stdio::stdin() as Box<Reader>
};
let mut rdr = BufferedRead... | identifier_body |
main_dialog.rs |
use ui;
use user32;
use winapi::*;
use super::{RcFile,RcRoot};
use std::path::{Path,PathBuf};
use std::rc::Rc;
use std::cell::RefCell;
use wtl::ctrls::CTreeItem;
pub struct MainDlgHandler{
rc_root: Rc<RefCell<RcRoot>>,
}
impl MainDlgHandler {
pub fn new()->MainDlgHandler {
MainDlgHand... | (rc_root: &mut RcRoot, t: &mut ui::Root) {
/*
items in listbox are all dialogs,when selecting a dialog,all containers in it will be added as children in tree_ctrl
items in tree_ctrl store node type(dialog/container) in itemdata
when unselect a item,the item type must be check,if the ... | call | identifier_name |
main_dialog.rs | use ui;
use user32;
use winapi::*;
use super::{RcFile,RcRoot};
use std::path::{Path,PathBuf};
use std::rc::Rc;
use std::cell::RefCell;
use wtl::ctrls::CTreeItem;
pub struct MainDlgHandler{
rc_root: Rc<RefCell<RcRoot>>,
}
impl MainDlgHandler {
pub fn new()->MainDlgHandler {
MainDlgHandle... | item_strings.push(t);
item.Delete();
}
return true;
}
fn delete_tree(item: &CTreeItem) ->Vec<String> {
let mut item_strings: Vec<String> = Vec::new();
Self::delete_child(item, &mut item_strings);
item_strings
} ... |
let t = item.GetText();
//Root can't be deleted
if t != "Root" {
| random_line_split |
main_dialog.rs |
use ui;
use user32;
use winapi::*;
use super::{RcFile,RcRoot};
use std::path::{Path,PathBuf};
use std::rc::Rc;
use std::cell::RefCell;
use wtl::ctrls::CTreeItem;
pub struct MainDlgHandler{
rc_root: Rc<RefCell<RcRoot>>,
}
impl MainDlgHandler {
pub fn new()->MainDlgHandler {
MainDlgHand... | let mut rt = rt2.borrow_mut();
SelectDialog::call(&mut *rt,t);
});
let rt3 = self.rc_root.clone();
r.main_dialog.btn_unselect_msg().on_click(move|_,t|{
let mut rt = rt3.borrow_mut();
UnSelectDialog::call(&mut *rt,t);
});
... | {
r.main_dialog.this_msg().on_close(|_,_|{
unsafe{user32::PostQuitMessage(0)};
});
r.main_dialog.this_msg().on_init_dialog(|_,t|{
println!("hello main dlg");
t.main_dialog.this.SetWindowText("GUI Generator");
//t.main_dialog.edt_rc_path.SetWin... | identifier_body |
main_dialog.rs |
use ui;
use user32;
use winapi::*;
use super::{RcFile,RcRoot};
use std::path::{Path,PathBuf};
use std::rc::Rc;
use std::cell::RefCell;
use wtl::ctrls::CTreeItem;
pub struct MainDlgHandler{
rc_root: Rc<RefCell<RcRoot>>,
}
impl MainDlgHandler {
pub fn new()->MainDlgHandler {
MainDlgHand... |
let mut v = Self::get_item_path(&parent);
v.push(item.GetText());
v
}
}
| {
//Root
let mut v = Vec::new();
v.push(item.GetText());
return v;
} | conditional_block |
rust.rs | // Location of the person
struct Location {
lat: float64,
long: float64,
}
// An application
struct Web {
name: String,
url: String,
}
// An simple author element with some description
struct Author {
title: String,
email: String,
categories: Vec<String>,
locations: Vec<Location>,
... | question: String,
version: String,
coffeeTime: time.Time,
profileUri: String,
captcha: String,
payload: Object,
} | price: float64,
rating: u64,
content: String, | random_line_split |
rust.rs | // Location of the person
struct Location {
lat: float64,
long: float64,
}
// An application
struct Web {
name: String,
url: String,
}
// An simple author element with some description
struct Author {
title: String,
email: String,
categories: Vec<String>,
locations: Vec<Location>,
... | {
config: Meta,
inlineConfig: HashMap<String, String>,
tags: Vec<String>,
receiver: Vec<Author>,
resources: Vec<Object>,
profileImage: String,
read: bool,
source: Object,
author: Author,
meta: Meta,
sendDate: time.Time,
readDate: time.Time,
expires: time.Duration,
... | News | identifier_name |
day17.rs | use std::collections::HashSet;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use itertools::Itertools;
use itertools::MinMaxResult;
use regex::Regex;
use common::Solution;
type Coordinate = (usize, usize);
#[derive(Default)]
pub struct Day17 {
clays: HashSet<Coordinate>,
flowing: HashSet<... |
if left_contained && right_contained {
self.contained.extend(range);
} else {
self.flowing.extend(range);
}
} else {
self.flowing.insert(pos);
}
}
}
impl Solution for Day17 {
fn part1(&mut self, input: &mut dyn Re... | {
let (x, y) = pos;
if y > self.ymax
|| self.clays.contains(&pos)
|| self.flowing.contains(&pos)
|| self.contained.contains(&pos)
{
return;
}
let below = (x, y + 1);
self.descend(below);
if self.is_supported(&bel... | identifier_body |
day17.rs | use std::collections::HashSet;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use itertools::Itertools;
use itertools::MinMaxResult;
use regex::Regex;
use common::Solution;
type Coordinate = (usize, usize);
#[derive(Default)]
pub struct Day17 {
clays: HashSet<Coordinate>,
flowing: HashSet<... | else {
self.flowing.insert(pos);
}
}
}
impl Solution for Day17 {
fn part1(&mut self, input: &mut dyn Read) -> String {
self.read_input(input);
self.descend((500, 0));
let result = self.contained.len() + self.flowing.len() - self.ymin;
result.to_string()
... | {
let (right, right_contained) = self.support_end(x, (x + 1).., y);
let (left, left_contained) = self.support_end(x, (0..x).rev(), y);
let range = (left..=right).map(|x| (x, y));
if left_contained && right_contained {
self.contained.extend(range);
... | conditional_block |
day17.rs | use std::collections::HashSet;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use itertools::Itertools;
use itertools::MinMaxResult;
use regex::Regex;
use common::Solution;
type Coordinate = (usize, usize);
#[derive(Default)]
pub struct Day17 {
clays: HashSet<Coordinate>,
flowing: HashSet<... | (&mut self, input: &mut dyn Read) -> String {
self.read_input(input);
self.descend((500, 0));
let result = self.contained.len() + self.flowing.len() - self.ymin;
result.to_string()
}
fn part2(&mut self, input: &mut dyn Read) -> String {
self.read_input(input);
... | part1 | identifier_name |
day17.rs | use std::collections::HashSet;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use itertools::Itertools;
use itertools::MinMaxResult;
use regex::Regex;
use common::Solution;
type Coordinate = (usize, usize);
#[derive(Default)]
pub struct Day17 {
clays: HashSet<Coordinate>,
flowing: HashSet<... | }
fn is_supported(&self, pos: &Coordinate) -> bool {
self.clays.contains(pos) || self.contained.contains(pos)
}
fn descend(&mut self, pos: Coordinate) {
let (x, y) = pos;
if y > self.ymax
|| self.clays.contains(&pos)
|| self.flowing.contains(&pos)
... | unreachable!(); | random_line_split |
version.rs | use crate::config::{Config, Container};
use crate::build_step::{BuildStep, Digest};
use super::error::Error;
#[cfg(feature="containers")]
fn | (container: &Container, cfg: &Config, debug_info: bool, dump: bool)
-> Result<String, (String, Error)>
{
debug!("Versioning items: {}", container.setup.len());
let mut hash = Digest::new(debug_info, dump);
hash.field("uids", &container.uids);
hash.field("gids", &container.gids);
for b in cont... | all | identifier_name |
version.rs | use crate::config::{Config, Container};
use crate::build_step::{BuildStep, Digest};
use super::error::Error;
#[cfg(feature="containers")]
fn all(container: &Container, cfg: &Config, debug_info: bool, dump: bool)
-> Result<String, (String, Error)>
{
debug!("Versioning items: {}", container.setup.len());
... |
if debug_info {
hash.print_debug_info();
}
if dump {
hash.dump_info();
}
Ok(format!("{:x}", hash))
}
#[cfg(feature="containers")]
pub fn short_version(container: &Container, cfg: &Config)
-> Result<String, (String, Error)>
{
let hash_str = all(container, cfg, false, false)... | {
hash.field("data_dirs", &container.data_dirs);
} | conditional_block |
version.rs | use crate::config::{Config, Container};
use crate::build_step::{BuildStep, Digest};
use super::error::Error;
#[cfg(feature="containers")]
fn all(container: &Container, cfg: &Config, debug_info: bool, dump: bool)
-> Result<String, (String, Error)>
{
debug!("Versioning items: {}", container.setup.len());
... |
#[cfg(feature="containers")]
pub fn long_version(container: &Container, cfg: &Config,
debug_info: bool, dump: bool)
-> Result<String, (String, Error)>
{
let hash_str = all(&container, cfg, debug_info, dump)?;
Ok(hash_str)
}
| {
let hash_str = all(container, cfg, false, false)?;
Ok(hash_str[..8].to_string())
} | identifier_body |
version.rs | use crate::config::{Config, Container};
use crate::build_step::{BuildStep, Digest};
use super::error::Error;
#[cfg(feature="containers")]
fn all(container: &Container, cfg: &Config, debug_info: bool, dump: bool)
-> Result<String, (String, Error)>
{
debug!("Versioning items: {}", container.setup.len());
... | {
let hash_str = all(container, cfg, false, false)?;
Ok(hash_str[..8].to_string())
}
#[cfg(feature="containers")]
pub fn long_version(container: &Container, cfg: &Config,
debug_info: bool, dump: bool)
-> Result<String, (String, Error)>
{
let hash_str = all(&container, cfg, debug_info, dump)?;
O... | -> Result<String, (String, Error)> | random_line_split |
unrooted_must_root.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 syntax::{ast, codemap, visit};
use syntax::attr::AttrMetaMethods;
use rustc::ast_map;
use rustc::lint::{Contex... | },
_ => ()
}
if unsafe_context(&cx.tcx.map, id) {
return;
}
match block.rules {
ast::DefaultBlock => {
for arg in decl.inputs.iter() {
lint_unrooted_ty(cx, &*arg.ty,
... | random_line_split | |
unrooted_must_root.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 syntax::{ast, codemap, visit};
use syntax::attr::AttrMetaMethods;
use rustc::ast_map;
use rustc::lint::{Contex... | ;
// Checks if a type has the #[must_root] annotation.
// Unwraps pointers as well
// TODO (#3874, sort of): unwrap other types like Vec/Option/HashMap/etc
fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
match ty.node {
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) =>
lin... | UnrootedPass | identifier_name |
issue-16151.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) {
unsafe {
DROP_COUNT += 1;
}
}
}
fn main() {
{
let mut fragments = vec![Fragment, Fragment, Fragment];
let _new_fragments: Vec<Fragment> = mem::replace(&mut fragments, vec![])
.into_iter()
.skip_while(|_fragment| {
t... | drop | identifier_name |
issue-16151.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 ... | }
} | random_line_split | |
issue-16151.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
{
let mut fragments = vec![Fragment, Fragment, Fragment];
let _new_fragments: Vec<Fragment> = mem::replace(&mut fragments, vec![])
.into_iter()
.skip_while(|_fragment| {
true
}).collect();
}
unsafe {
assert_eq!(DROP_COUNT, 3);
... | identifier_body | |
build.rs | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::env;
use std::process::Command;
use std::str::{self, FromStr};
fn main() {
println!("cargo:rustc-cfg=build_script_ran");
let minor = mat... | if target.contains("darwin") {
println!("cargo:rustc-cfg=is_mac");
}
}
fn rustc_minor_version() -> Option<u32> {
let rustc = match env::var_os("RUSTC") {
Some(rustc) => rustc,
None => return None,
};
let output = match Command::new(rustc).arg("--version").output() {
... | } | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.