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 |
|---|---|---|---|---|
watch.rs | // Copyright 2015 Matthias Schorsch
//
// 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 ... |
// consts
const FILE_LIST_DIRECTORY: DWORD = 0x0001;
#[derive(Debug,Clone)]
pub struct FileNotifyInformation {
action: FileAction,
filename: String,
}
impl fmt::Display for FileNotifyInformation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} -> {}", self.action, self.... | use std::slice; | random_line_split |
watch.rs | // Copyright 2015 Matthias Schorsch
//
// 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 ... | {
h_directory: HANDLE,
watch_subdirs: bool,
buffer_size: u32,
result_buffer: Box<Vec<u8>>,
dw_notify_filter: DWORD,
}
impl Drop for WinWatch {
fn drop(&mut self) {
close_dir_handle(self.h_directory);
}
}
impl WinWatch {
pub fn new(directory: &Path, notify_changes: Box<... | WinWatch | identifier_name |
watch.rs | // Copyright 2015 Matthias Schorsch
//
// 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 ... |
fn to_file_notify_information(v: &[u8], offset: usize) -> FileNotifyInformation {
let action = as_u32le(v, offset + 4);
let file_name_length = as_u32le(v, offset + 8) as usize;
let filename = to_filename(v, offset + 12, file_name_length);
let fni = FileNotifyInformation {
action: FileAction::... | {
let mut result:Vec<FileNotifyInformation> = Vec::new();
let mut offset: usize = 0;
loop {
let next_entry_offset = as_u32le(v, offset);
result.push(to_file_notify_information(v, offset));
// check for 0.
// 0 indicates that this is the last record
if next_entry_offs... | identifier_body |
htmltableelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
use dom::htmlelement::HTMLElement;
pub struct HT... | (&self, _cell_padding: &DOMString, _rv: &mut ErrorResult) {
}
pub fn CellSpacing(&self) -> DOMString {
null_string
}
pub fn SetCellSpacing(&self, _cell_spacing: &DOMString, _rv: &mut ErrorResult) {
}
}
| SetCellPadding | identifier_name |
htmltableelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
use dom::htmlelement::HTMLElement;
pub struct HT... | pub fn Border(&self) -> DOMString {
null_string
}
pub fn SetBorder(&self, _border: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Frame(&self) -> DOMString {
null_string
}
pub fn SetFrame(&self, _frame: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Rules(&self) -> ... | random_line_split | |
lib.rs | use std::borrow::Cow;
use std::error::Error;
use std::path::{Path, PathBuf};
use std::io;
use std::fs;
pub trait Filesystem {
type Error: Error + Send + Sync +'static;
type File: io::Read + io::Write + io::Seek;
fn create_dir(&self, path: &Path) -> Result<(), Self::Error>;
fn create_dir_all(&self, pat... | }
pub type FilesystemObject = Filesystem<Error = io::Error, File = Box<ReadWriteSeek>>;
pub struct FilesystemDynamic<F>(F);
pub struct FileDynamic<F>(F);
pub trait ReadWriteSeek: io::Read + io::Write + io::Seek { }
impl<F: io::Read + io::Write + io::Seek> ReadWriteSeek for F { }
fn io_error<E: Error + Send + Sync +'s... | fs::create_dir_all(self.path(path))
} | random_line_split |
lib.rs | use std::borrow::Cow;
use std::error::Error;
use std::path::{Path, PathBuf};
use std::io;
use std::fs;
pub trait Filesystem {
type Error: Error + Send + Sync +'static;
type File: io::Read + io::Write + io::Seek;
fn create_dir(&self, path: &Path) -> Result<(), Self::Error>;
fn create_dir_all(&self, pat... | else {
Cow::Borrowed(path)
}
}
}
impl Default for StdFilesystem {
fn default() -> Self {
StdFilesystem(None)
}
}
impl Filesystem for StdFilesystem {
type Error = io::Error;
type File = fs::File;
fn create(&self, path: &Path) -> Result<Self::File, Self::Error> {
... | {
root.push(path);
Cow::Owned(root)
} | conditional_block |
lib.rs | use std::borrow::Cow;
use std::error::Error;
use std::path::{Path, PathBuf};
use std::io;
use std::fs;
pub trait Filesystem {
type Error: Error + Send + Sync +'static;
type File: io::Read + io::Write + io::Seek;
fn create_dir(&self, path: &Path) -> Result<(), Self::Error>;
fn create_dir_all(&self, pat... | <'a>(&self, path: &'a Path) -> Cow<'a, Path> {
if let Some(mut root) = self.0.as_ref().map(Clone::clone) {
root.push(path);
Cow::Owned(root)
} else {
Cow::Borrowed(path)
}
}
}
impl Default for StdFilesystem {
fn default() -> Self {
StdFilesyst... | path | identifier_name |
arm.rs | use std::any::{Any, TypeId};
use std::mem;
use crate::runtime::Imp;
extern {
fn objc_msgSend();
fn objc_msgSend_stret();
fn objc_msgSendSuper();
fn objc_msgSendSuper_stret();
}
pub fn msg_send_fn<R: Any>() -> Imp |
pub fn msg_send_super_fn<R: Any>() -> Imp {
let type_id = TypeId::of::<R>();
if mem::size_of::<R>() <= 4 ||
type_id == TypeId::of::<i64>() ||
type_id == TypeId::of::<u64>() ||
type_id == TypeId::of::<f64>() {
objc_msgSendSuper
} else {
objc_msgSendSuper_... | {
// Double-word sized fundamental data types don't use stret,
// but any composite type larger than 4 bytes does.
// <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf>
let type_id = TypeId::of::<R>();
if mem::size_of::<R>() <= 4 ||
type_id == TypeId::of::<i6... | identifier_body |
arm.rs | use std::any::{Any, TypeId};
use std::mem;
use crate::runtime::Imp;
extern {
fn objc_msgSend();
fn objc_msgSend_stret();
fn objc_msgSendSuper();
fn objc_msgSendSuper_stret();
}
pub fn | <R: Any>() -> Imp {
// Double-word sized fundamental data types don't use stret,
// but any composite type larger than 4 bytes does.
// <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf>
let type_id = TypeId::of::<R>();
if mem::size_of::<R>() <= 4 ||
type_id ... | msg_send_fn | identifier_name |
arm.rs | use std::any::{Any, TypeId};
use std::mem;
use crate::runtime::Imp;
extern {
fn objc_msgSend();
fn objc_msgSend_stret();
fn objc_msgSendSuper();
fn objc_msgSendSuper_stret();
}
pub fn msg_send_fn<R: Any>() -> Imp {
// Double-word sized fundamental data types don't use stret,
// but any compo... | else {
objc_msgSend_stret
}
}
pub fn msg_send_super_fn<R: Any>() -> Imp {
let type_id = TypeId::of::<R>();
if mem::size_of::<R>() <= 4 ||
type_id == TypeId::of::<i64>() ||
type_id == TypeId::of::<u64>() ||
type_id == TypeId::of::<f64>() {
objc_msgSendSup... | {
objc_msgSend
} | conditional_block |
arm.rs | use std::any::{Any, TypeId};
use std::mem;
use crate::runtime::Imp;
extern {
fn objc_msgSend();
fn objc_msgSend_stret();
fn objc_msgSendSuper();
fn objc_msgSendSuper_stret();
}
pub fn msg_send_fn<R: Any>() -> Imp {
// Double-word sized fundamental data types don't use stret,
// but any compo... | }
} | type_id == TypeId::of::<f64>() {
objc_msgSendSuper
} else {
objc_msgSendSuper_stret | random_line_split |
api.rs | //=============================================================================
//
// WARNING: This file is AUTO-GENERATED
//
// Do not make changes directly to this file.
//
// If you would like to make a change to the library, please update the schema
// definitions at https://github.com/slack-rs/s... | request.foo.map(|foo| ("foo", foo)),
];
let params = params.into_iter().filter_map(|x| x).collect::<Vec<_>>();
let url = crate::get_slack_url_for_method("api.test");
client
.send(&url, ¶ms[..])
.map_err(TestError::Client)
.and_then(|result| {
serde_json::from... | where
R: SlackWebRequestSender,
{
let params = vec![
request.error.map(|error| ("error", error)), | random_line_split |
api.rs | //=============================================================================
//
// WARNING: This file is AUTO-GENERATED
//
// Do not make changes directly to this file.
//
// If you would like to make a change to the library, please update the schema
// definitions at https://github.com/slack-rs/s... | <R>(client: &R, request: &TestRequest<'_>) -> Result<TestResponse, TestError<R::Error>>
where
R: SlackWebRequestSender,
{
let params = vec![
request.error.map(|error| ("error", error)),
request.foo.map(|foo| ("foo", foo)),
];
let params = params.into_iter().filter_map(|x| x).collect::<Ve... | test | identifier_name |
api.rs | //=============================================================================
//
// WARNING: This file is AUTO-GENERATED
//
// Do not make changes directly to this file.
//
// If you would like to make a change to the library, please update the schema
// definitions at https://github.com/slack-rs/s... | {
let params = vec![
request.error.map(|error| ("error", error)),
request.foo.map(|foo| ("foo", foo)),
];
let params = params.into_iter().filter_map(|x| x).collect::<Vec<_>>();
let url = crate::get_slack_url_for_method("api.test");
client
.send(&url, ¶ms[..])
.map... | identifier_body | |
action.rs | extern crate toml;
extern crate collections;
use std::io::fs;
use std::io::fs::PathExtensions;
use std::io::{Process, Command};
use std::collections::treemap::TreeMap;
#[deriving(Clone)]
pub struct Action {
pub name: String,
pub command: String,
pub do_file: Option<Path>,
pub undo_file: Option<Path>
}... | execute_command(&self.undo_file, &self.command, "No 'undo' file")
}
pub fn find_actions(root: &Path, cmd: &String, special: &TreeMap<String, toml::Value>) -> Result<Vec<Action>, &'static str> {
let dirs = try!(select_files(root, |_, path| valid_action_dir(path)));
let mut actions: Vec<A... | execute_command(&self.do_file, &self.command, "No 'do' file")
}
pub fn undo_command(&self) -> Result<String, String> { | random_line_split |
action.rs | extern crate toml;
extern crate collections;
use std::io::fs;
use std::io::fs::PathExtensions;
use std::io::{Process, Command};
use std::collections::treemap::TreeMap;
#[deriving(Clone)]
pub struct Action {
pub name: String,
pub command: String,
pub do_file: Option<Path>,
pub undo_file: Option<Path>
}... |
fn execute_command(file: &Option<Path>, cmd: &String, error: &'static str) -> Result<String, String> {
let path = match file {
&Some(ref path) => path,
&None => return Ok(error.to_string())
};
let command = parse_command(cmd.as_slice(), path);
let process = Command::new(comm... | {
match process.wait_with_output() {
Err(error) => Err(error.desc.to_string()),
Ok(exit) => {
if exit.status.success() {
Ok(exit.output.into_ascii().into_string())
} else {
Err(exit.error.into_ascii().into_string())
}
}
... | identifier_body |
action.rs | extern crate toml;
extern crate collections;
use std::io::fs;
use std::io::fs::PathExtensions;
use std::io::{Process, Command};
use std::collections::treemap::TreeMap;
#[deriving(Clone)]
pub struct | {
pub name: String,
pub command: String,
pub do_file: Option<Path>,
pub undo_file: Option<Path>
}
impl Action {
pub fn do_command(&self) -> Result<String, String> {
execute_command(&self.do_file, &self.command, "No 'do' file")
}
pub fn undo_command(&self) -> Result<String, String>... | Action | 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 ... | //- pub mod at_exit_imp;
//- #[cfg(feature = "backtrace")]
//- pub mod backtrace;
//- pub mod condvar;
//- pub mod io;
//- pub mod mutex;
//- pub mod poison;
//- pub mod remutex;
//- pub mod rwlock;
//- pub mod thread;
//- pub mod thread_info;
//- pub mod thread_local;
//- pub mod util;
//- pub mod wtf8;
pub mod bytest... | random_line_split | |
lib.rs | /*--------------------------------------------------------------------------
smoke-rs
The MIT License (MIT) | of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do ... |
Copyright (c) 2016 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy | random_line_split |
sup.rs | use std::ffi::OsString;
use crate::common::ui::UI;
use crate::error::Result;
pub const SUP_CMD: &str = "hab-sup";
pub const SUP_CMD_ENVVAR: &str = "HAB_SUP_BINARY";
pub const SUP_PKG_IDENT: &str = "core/hab-sup";
pub async fn start(ui: &mut UI, args: &[OsString]) -> Result<()> { inner::start(ui, args).await }
#[cf... |
}
| {
let subcmd = env::args().nth(1).unwrap_or("<unknown>".to_string());
ui.warn("Launching a native Supervisor on this operating system is not yet supported. \
Try running this command again on 64-bit Linux or Windows.")?;
ui.br()?;
Err(Error::SubcommandNotSupported(subcmd... | identifier_body |
sup.rs | use std::ffi::OsString;
use crate::common::ui::UI;
use crate::error::Result;
pub const SUP_CMD: &str = "hab-sup";
pub const SUP_CMD_ENVVAR: &str = "HAB_SUP_BINARY";
pub const SUP_PKG_IDENT: &str = "core/hab-sup";
pub async fn start(ui: &mut UI, args: &[OsString]) -> Result<()> { inner::start(ui, args).await }
#[cf... | (ui: &mut UI, _args: &[OsString]) -> Result<()> {
let subcmd = env::args().nth(1).unwrap_or("<unknown>".to_string());
ui.warn("Launching a native Supervisor on this operating system is not yet supported. \
Try running this command again on 64-bit Linux or Windows.")?;
ui.br()?;
... | start | identifier_name |
sup.rs | use std::ffi::OsString;
use crate::common::ui::UI;
use crate::error::Result;
pub const SUP_CMD: &str = "hab-sup";
pub const SUP_CMD_ENVVAR: &str = "HAB_SUP_BINARY";
pub const SUP_PKG_IDENT: &str = "core/hab-sup";
pub async fn start(ui: &mut UI, args: &[OsString]) -> Result<()> { inner::start(ui, args).await }
#[cf... |
pub async fn start(ui: &mut UI, args: &[OsString]) -> Result<()> {
let command = match henv::var(SUP_CMD_ENVVAR) {
Ok(command) => PathBuf::from(command),
Err(_) => {
init()?;
let version: Vec<&str> = VERSION.split('/').collect();
exec:... | Result},
exec,
VERSION}; | random_line_split |
type_of.rs | 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.
#![allow(non_camel_case_types)]
use middle::subst;
use middle::trans::adt;
use middle::trans::common::*;
use mid... |
}
}
pub fn arg_is_indirect(ccx: &CrateContext, arg_ty: ty::t) -> bool {
!type_is_immediate(ccx, arg_ty)
}
pub fn return_uses_outptr(ccx: &CrateContext, ty: ty::t) -> bool {
!type_is_immediate(ccx, ty)
}
pub fn type_of_explicit_arg(ccx: &CrateContext, arg_ty: ty::t) -> Type {
let llty = arg_type_of(ccx... | { ccx.report_overbig_object(scapegoat) } | conditional_block |
type_of.rs | 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.
#![allow(non_camel_case_types)]
use middle::subst;
use middle::trans::adt;
use middle::trans::common::*;
use mid... | (ccx: &CrateContext,
llet: Type,
size: machine::llsize,
scapegoat: ty::t) {
let esz = machine::llsize_of_alloc(ccx, llet);
match esz.checked_mul(size) {
Some(n) if n < ccx.max_obj_size() => ... | ensure_array_fits_in_address_space | identifier_name |
type_of.rs | /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.
#![allow(non_camel_case_types)]
use middle::subst;
use middle::trans::adt;
use middle::trans::common::*;
use mi... | }
// Check the cache.
match cx.lltypes().borrow().get(&t) {
Some(&llty) => return llty,
None => ()
}
debug!("type_of {} {}", t.repr(cx.tcx()), ty::get(t).sty);
// Replace any typedef'd types with their equivalent non-typedef
// type. This ensures that all LLVM nominal type... | } | random_line_split |
type_of.rs | 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.
#![allow(non_camel_case_types)]
use middle::subst;
use middle::trans::adt;
use middle::trans::common::*;
use mid... |
// NB: If you update this, be sure to update `sizing_type_of()` as well.
pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
fn type_of_unsize_info(cx: &CrateContext, t: ty::t) -> Type {
// It is possible to end up here with a sized type. This happens with a
// struct which might be unsized, but... | {
if ty::type_is_bool(t) {
Type::i1(cx)
} else {
type_of(cx, t)
}
} | identifier_body |
mod.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 mod local;
/// Bindings to system threading libraries.
pub mod thread;
/// The runtime configuration, read from environment variables.
pub mod env;
/// The local, managed heap
pub mod local_heap;
/// The runtime needs to be able to put a pointer into thread-local storage.
mod local_ptr;
/// Bindings to pthread... | pub mod rtio;
/// The Local trait for types that are accessible via thread-local
/// or task-local storage. | random_line_split |
mod.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 ... |
/// One-time runtime cleanup.
///
/// This function is unsafe because it performs no checks to ensure that the
/// runtime has completely ceased running. It is the responsibility of the
/// caller to ensure that the runtime is entirely shut down and nothing will be
/// poking around at the internal components.
///
//... | {
at_exit_imp::push(f);
} | identifier_body |
mod.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 ... | (argc: int, argv: **u8) {
// FIXME: Derefing these pointers is not safe.
// Need to propagate the unsafety to `start`.
unsafe {
args::init(argc, argv);
env::init();
local_ptr::init();
at_exit_imp::init();
}
}
/// Enqueues a procedure to run when the runtime is cleaned up... | init | identifier_name |
gdp.rs | mod named {
use core::marker::PhantomData;
#[derive(Clone)]
pub struct Named<Name, A>(pub A, PhantomData<Name>);
// don't use this, use the macro name!
pub fn name<Name: Fn(), T, A, K: Fn(Named<Name, A>) -> T>(_: Name, x: A, k: K) -> T {
k(Named(x, PhantomData))
}
#[macro_expo... | pub struct SortedBy<Comp, A>(pub A, PhantomData<Comp>);
pub fn sort_by<Comp, A, CompFn: Fn(&A, &A) -> Ordering>(comp: Named<Comp, CompFn>, mut xs: Vec<A>) -> SortedBy<Comp, Vec<A>> {
SortedBy({ xs.sort_unstable_by(comp.0); xs }, PhantomData)
}
pub fn merge_by<Comp, A, CompFn: Fn(&A, &A... | use core::cmp::Ordering;
#[derive(Clone)] | random_line_split |
gdp.rs | mod named {
use core::marker::PhantomData;
#[derive(Clone)]
pub struct Named<Name, A>(pub A, PhantomData<Name>);
// don't use this, use the macro name!
pub fn name<Name: Fn(), T, A, K: Fn(Named<Name, A>) -> T>(_: Name, x: A, k: K) -> T {
k(Named(x, PhantomData))
}
#[macro_expo... | <Comp, A>(pub A, PhantomData<Comp>);
pub fn sort_by<Comp, A, CompFn: Fn(&A, &A) -> Ordering>(comp: Named<Comp, CompFn>, mut xs: Vec<A>) -> SortedBy<Comp, Vec<A>> {
SortedBy({ xs.sort_unstable_by(comp.0); xs }, PhantomData)
}
pub fn merge_by<Comp, A, CompFn: Fn(&A, &A) -> Ordering>(comp: Na... | SortedBy | identifier_name |
gdp.rs | mod named {
use core::marker::PhantomData;
#[derive(Clone)]
pub struct Named<Name, A>(pub A, PhantomData<Name>);
// don't use this, use the macro name!
pub fn name<Name: Fn(), T, A, K: Fn(Named<Name, A>) -> T>(_: Name, x: A, k: K) -> T {
k(Named(x, PhantomData))
}
#[macro_expo... |
if ys.is_empty() { return xs; }
match comp(&xs[xs.len() - 1], &ys[ys.len() - 1]) {
Ordering::Greater => {
let x = xs.pop().unwrap();
let mut ret = merge_by(comp, xs, ys);
ret.push(x);
ret
},
_ => {
... | { return ys; } | conditional_block |
issue-3904.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 ... | {
err: ErrPrinter
}
pub impl X {
fn boom() {
exit(self.err, "prog", "arg");
}
}
pub fn main(){
let val = &X{
err: example_err,
};
val.boom();
}
| X | identifier_name |
issue-3904.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 ... |
pub impl X {
fn boom() {
exit(self.err, "prog", "arg");
}
}
pub fn main(){
let val = &X{
err: example_err,
};
val.boom();
} |
struct X {
err: ErrPrinter
} | random_line_split |
issue-3904.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 ... |
struct X {
err: ErrPrinter
}
pub impl X {
fn boom() {
exit(self.err, "prog", "arg");
}
}
pub fn main(){
let val = &X{
err: example_err,
};
val.boom();
}
| {
print(prog, arg);
} | identifier_body |
resource-destruct.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) {
error!("Hello!"); self.i.set(self.i.get() - 1);
}
}
impl shrinky_pointer {
pub fn look_at(&self) -> int { return self.i.get(); }
}
fn shrinky_pointer(i: @@Cell<int>) -> shrinky_pointer {
shrinky_pointer {
i: i
}
}
pub fn main() {
let my_total = @@Cell::new(10);
{... | drop | identifier_name |
resource-destruct.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 shrinky_pointer(i: @@Cell<int>) -> shrinky_pointer {
shrinky_pointer {
i: i
}
}
pub fn main() {
let my_total = @@Cell::new(10);
{ let pt = shrinky_pointer(my_total); assert!((pt.look_at() == 10)); }
error!("my_total = {}", my_total.get());
assert_eq!(my_total.get(), 9);
}
| { return self.i.get(); } | identifier_body |
resource-destruct.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 ... | #[unsafe_destructor]
impl Drop for shrinky_pointer {
fn drop(&mut self) {
error!("Hello!"); self.i.set(self.i.get() - 1);
}
}
impl shrinky_pointer {
pub fn look_at(&self) -> int { return self.i.get(); }
}
fn shrinky_pointer(i: @@Cell<int>) -> shrinky_pointer {
shrinky_pointer {
i: i
... | i: @@Cell<int>,
}
| random_line_split |
clone.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... | methods: ~[
MethodDef {
name: "clone",
generics: LifetimeBounds::empty(),
explicit_self: borrowed_explicit_self(),
args: ~[],
ret_ty: Self,
inline: true,
const_nonmatching: false,
... | additional_bounds: ~[],
generics: LifetimeBounds::empty(), | random_line_split |
clone.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_def.expand(mitem, in_items)
}
pub fn expand_deriving_deep_clone(cx: &ExtCtxt,
span: Span,
mitem: @MetaItem,
in_items: ~[@Item])
-> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,
... | {
let trait_def = TraitDef {
cx: cx, span: span,
path: Path::new(~["std", "clone", "Clone"]),
additional_bounds: ~[],
generics: LifetimeBounds::empty(),
methods: ~[
MethodDef {
name: "clone",
generics: LifetimeBounds::empty(),
... | identifier_body |
clone.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: &ExtCtxt,
span: Span,
mitem: @MetaItem,
in_items: ~[@Item])
-> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,
path: Path::new(~["std", "clone", "DeepClone"]),
additional... | expand_deriving_deep_clone | identifier_name |
clone.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.expr_struct_ident(span, ctor_ident, fields)
} | conditional_block |
cross-borrow-trait.rs | // Copyright 2012-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
// <LICEN... | () {
let x: Box<Trait> = box Foo;
let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box<Trait>`
}
| main | identifier_name |
cross-borrow-trait.rs | // Copyright 2012-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
// <LICEN... | // Test that cross-borrowing (implicitly converting from `Box<T>` to `&T`) is
// forbidden when `T` is a trait.
struct Foo;
trait Trait {}
impl Trait for Foo {}
pub fn main() {
let x: Box<Trait> = box Foo;
let _y: &Trait = x; //~ ERROR mismatched types: expected `&Trait`, found `Box<Trait>`
} | // except according to those terms.
| random_line_split |
nats_message_stream.rs | use crate::event::{Error,
EventStreamConfig,
Result};
use futures::{channel::{mpsc as futures_mpsc,
mpsc::UnboundedSender},
stream::StreamExt};
use rants::{error::Error as RantsError,
native_tls::TlsConnector,
Client,
... | if let RantsError::NotConnected = e {
trace!("Failed to publish message to subject '{}' because the client is \
not connected",
packet.subject);
} else {
error!("Failed ... | while let Some(packet) = rx.next().await {
if let Err(e) = client.publish(packet.subject, packet.payload()).await {
// We do not retry any messages. If we are not connected when the message is
// processed or there is an error in publishing the message... | random_line_split |
nats_message_stream.rs | use crate::event::{Error,
EventStreamConfig,
Result};
use futures::{channel::{mpsc as futures_mpsc,
mpsc::UnboundedSender},
stream::StreamExt};
use rants::{error::Error as RantsError,
native_tls::TlsConnector,
Client,
... | (&self) -> &[u8] { self.payload.as_slice() }
}
/// A lightweight handle for the NATS message stream. All events are converted into a NatsMessage
/// and sent into this stream to be published.
///
/// An UnboundedSender should be ok here. Messages are continously processed even if the client is
/// not currently connec... | payload | identifier_name |
nats_message_stream.rs | use crate::event::{Error,
EventStreamConfig,
Result};
use futures::{channel::{mpsc as futures_mpsc,
mpsc::UnboundedSender},
stream::StreamExt};
use rants::{error::Error as RantsError,
native_tls::TlsConnector,
Client,
... |
let tls_connector = tls_connector.build()?;
client.set_tls_config(tls_connector).await;
// Connect to the server. If a timeout was set, we want to ensure we establish a connection
// before exiting the function. If we do not connect within the timeout we return an error.
// If ... | {
tls_connector.add_root_certificate(certificate.into());
} | conditional_block |
test.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 visit_trait_item(&mut self, _: &'tcx hir::TraitItem) { }
fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { }
}
| {
let variances_of = self.tcx.variances_of(item_def_id);
span_err!(self.tcx.sess,
item.span,
E0208,
"{:?}",
variances_of);
} | conditional_block |
test.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 ... | tcx: TyCtxt<'a, 'tcx, 'tcx>
}
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for VarianceTest<'a, 'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item) {
let item_def_id = self.tcx.hir().local_def_id(item.id);
// For unit testing: check for a special "rustc_variance"
// attribute and report an... | }
struct VarianceTest<'a, 'tcx: 'a> { | random_line_split |
test.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 ... | (&mut self, _: &'tcx hir::TraitItem) { }
fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { }
}
| visit_trait_item | identifier_name |
test.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 visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { }
}
| { } | identifier_body |
scli.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use std::{
fs::{self, File},
io::{Error, ErrorKind, Result},
path::Path,
};
use external_storage_export::{
create_storage, make_cloud_backend, make_gcs_backend, make_local_backend, make_noop_backend,
make_s3_backend, ExternalStorag... | attrs.insert("credential_file".to_owned(), credential_file.clone());
}
config.set_attrs(attrs);
if let Some(cloud_name) = &opt.cloud_name {
config.provider_name = cloud_name.clone();
}
Ok(make_cloud_backend(config))
}
fn create_s3_storage(opt: &Opt) -> Result<StorageBackend> {
... | {
let mut bucket = Bucket::default();
if let Some(endpoint) = &opt.endpoint {
bucket.endpoint = endpoint.to_string();
}
if let Some(region) = &opt.region {
bucket.region = region.to_string();
}
if let Some(bucket_name) = &opt.bucket {
bucket.bucket = bucket_name.to_string... | identifier_body |
scli.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use std::{
fs::{self, File},
io::{Error, ErrorKind, Result},
path::Path,
};
use external_storage_export::{
create_storage, make_cloud_backend, make_gcs_backend, make_local_backend, make_noop_backend,
make_s3_backend, ExternalStorag... | (opt: &Opt) -> Result<StorageBackend> {
let mut bucket = Bucket::default();
if let Some(endpoint) = &opt.endpoint {
bucket.endpoint = endpoint.to_string();
}
if let Some(region) = &opt.region {
bucket.region = region.to_string();
}
if let Some(bucket_name) = &opt.bucket {
... | create_cloud_storage | identifier_name |
scli.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use std::{
fs::{self, File},
io::{Error, ErrorKind, Result},
path::Path,
};
use external_storage_export::{
create_storage, make_cloud_backend, make_gcs_backend, make_local_backend, make_noop_backend,
make_s3_backend, ExternalStorag... | .section(Some("default"))
.ok_or_else(|| Error::new(ErrorKind::Other, "fail to parse section"))?;
config.access_key = props
.get("aws_access_key_id")
.ok_or_else(|| Error::new(ErrorKind::Other, "fail to parse credential"))?
.clone();
config.secret_a... | })?;
let props = ini | random_line_split |
disassemble.rs | #![crate_id="disassemble#0.1"]
#![crate_type="bin"]
extern crate bancnova;
use std::os;
use bancnova::syntax::bscode;
use bancnova::syntax::assembly;
use bancnova::syntax::tokenize;
use bancnova::syntax::tokenize::Tokenizer;
use bancnova::syntax::tree::Tree;
use std::io::IoResult;
mod util;
fn main() {
let args ... | {
let (infile, mut outfile) =
match util::open_io_files(infilename, outfilename) {
Ok(p) => p,
Err(e) => { return Err(e); },
};
let mut tokenizer = tokenize::from_file(infile);
disassemble(&mut tokenizer, &mut outfile)
} | identifier_body | |
disassemble.rs | #![crate_id="disassemble#0.1"]
#![crate_type="bin"]
extern crate bancnova;
use std::os;
use bancnova::syntax::bscode;
use bancnova::syntax::assembly;
use bancnova::syntax::tokenize;
use bancnova::syntax::tokenize::Tokenizer;
use bancnova::syntax::tree::Tree;
use std::io::IoResult;
mod util;
fn main() {
let args ... | <R: Reader>(tokenizer: &mut Tokenizer<R>, writer: &mut Writer) -> IoResult<()> {
let bstree = Tree::parse(tokenizer);
let bstree: Tree<bscode::Instruction> =
match bstree {
Ok(tree) => tree,
Err(s) => { return util::make_ioerr(s, tokenizer); },
};
for bsinst in bstree.iter() {
... | disassemble | identifier_name |
disassemble.rs | #![crate_id="disassemble#0.1"]
#![crate_type="bin"]
| use bancnova::syntax::assembly;
use bancnova::syntax::tokenize;
use bancnova::syntax::tokenize::Tokenizer;
use bancnova::syntax::tree::Tree;
use std::io::IoResult;
mod util;
fn main() {
let args = os::args();
match disassemble_file(args.get(1).as_slice(), args.get(2).as_slice()) {
Err(err) => {
... | extern crate bancnova;
use std::os;
use bancnova::syntax::bscode; | random_line_split |
main.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | to: bob.public_key(),
amount: 5,
seed: 0,
},
);
let next_tx_a_to_b = alice.transfer(
SERVICE_ID,
Transfer {
to: bob.public_key(),
amount: 6,
seed: 1,
},
);
// Put transactions from A to B in separat... | {
let mut testkit = init_testkit();
let api = testkit.api();
// Create 2 wallets
let alice = KeyPair::random();
let tx_alice = alice.create_wallet(SERVICE_ID, CreateWallet::new("alice"));
let bob = KeyPair::random();
let tx_bob = bob.create_wallet(SERVICE_ID, CreateWallet::new("Bob"));
... | identifier_body |
main.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | (api: &TestKitApi, pubkey: &PublicKey) -> u64 {
api.public(ApiKind::Service("cryptocurrency"))
.get(&format!("v1/balance?pub_key={}", pubkey.to_hex()))
.await
.unwrap()
}
#[tokio::test]
async fn test_inflation() {
let mut testkit = init_testkit();
let alice = create_wallet(&mut testkit... | get_balance | identifier_name |
main.rs | // Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | }
/// Test randomly generated transfers among users without blockchain rollbacks.
#[tokio::test]
async fn test_fuzz_transfers() {
const USERS: usize = 10;
let mut rng = rand::thread_rng();
let mut testkit = init_testkit();
let api = testkit.api();
// First, create users
let keys_and_txs: Vec<... | random_line_split | |
parity.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | fn net_chain(&self) -> Result<String, Error>;
/// Returns peers details
#[rpc(name = "parity_netPeers")]
fn net_peers(&self) -> Result<Peers, Error>;
/// Returns network port
#[rpc(name = "parity_netPort")]
fn net_port(&self) -> Result<u16, Error>;
/// Returns rpc settings
#[rpc(name = "parity_rpcS... | #[rpc(name = "parity_devLogsLevels")]
fn dev_logs_levels(&self) -> Result<String, Error>;
/// Returns chain name
#[rpc(name = "parity_netChain")] | random_line_split |
handler_storage.rs | #[macro_use]
extern crate rustful;
use std::io::{self, Read};
use std::fs::File;
use std::path::Path;
use std::sync::{Arc, RwLock};
use std::error::Error;
#[macro_use]
extern crate log;
extern crate env_logger;
use rustful::{
Server,
Context,
Response,
Handler,
TreeRouter,
StatusCode
};
use r... | Api::File => {
if let Some(file) = context.variables.get("file") {
let file_path = Path::new(file.as_ref());
//Check if the path is valid
if check_path(file_path).is_ok() {
//Make a full path from the file n... | }, | random_line_split |
handler_storage.rs | #[macro_use]
extern crate rustful;
use std::io::{self, Read};
use std::fs::File;
use std::path::Path;
use std::sync::{Arc, RwLock};
use std::error::Error;
#[macro_use]
extern crate log;
extern crate env_logger;
use rustful::{
Server,
Context,
Response,
Handler,
TreeRouter,
StatusCode
};
use r... | }
}
else {
//No file name was specified
response.set_status(StatusCode::Forbidden);
}
}
}
}
}
| {
let file_path = Path::new(file.as_ref());
//Check if the path is valid
if check_path(file_path).is_ok() {
//Make a full path from the file name and send it
let path = Path::new("examples/handler_storage").join... | conditional_block |
handler_storage.rs | #[macro_use]
extern crate rustful;
use std::io::{self, Read};
use std::fs::File;
use std::path::Path;
use std::sync::{Arc, RwLock};
use std::error::Error;
#[macro_use]
extern crate log;
extern crate env_logger;
use rustful::{
Server,
Context,
Response,
Handler,
TreeRouter,
StatusCode
};
use r... | (value: i32) -> i32 {
value - 1
}
fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
//Read file into a string
let mut string = String::new();
File::open(path).and_then(|mut f| f.read_to_string(&mut string)).map(|_| string)
}
enum Api {
Counter {
//We are using the handler to... | sub | identifier_name |
describe-clusters.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_ecs::{Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS Region.
#[struct... | show_clusters(&client).await
} | random_line_split | |
describe-clusters.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_ecs::{Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS Region.
#[struct... |
// snippet-end:[ecs.rust.describe-clusters]
/// Lists your Amazon Elastic Container Service clusters in the Region.
/// # Arguments
///
/// * `[-r REGION]` - The Region in which the client is created.
/// If not supplied, uses the value of the **AWS_REGION** environment variable.
/// If the environment variable i... | {
let resp = client.describe_clusters().send().await?;
let clusters = resp.clusters().unwrap_or_default();
println!("Found {} clusters:", clusters.len());
for cluster in clusters {
println!(" ARN: {}", cluster.cluster_arn().unwrap());
println!(" Name: {}", cluster.cluster_name().unw... | identifier_body |
describe-clusters.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_ecs::{Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS Region.
#[struct... | () -> Result<(), Error> {
let Opt { region, verbose } = Opt::from_args();
if verbose {
tracing_subscriber::fmt::init();
}
let region_provider = RegionProviderChain::first_try(region.map(Region::new))
.or_default_provider()
.or_else(Region::new("us-west-2"));
if verbose {
... | main | identifier_name |
describe-clusters.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_ecs::{Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS Region.
#[struct... |
let shared_config = aws_config::from_env().region(region_provider).load().await;
let client = aws_sdk_ecs::Client::new(&shared_config);
show_clusters(&client).await
}
| {
println!();
println!("ECS client version: {}", PKG_VERSION);
println!(
"Region: {}",
region_provider.region().await.unwrap().as_ref()
);
println!();
} | conditional_block |
project_euler_1.rs | // Project Euler #1: Multiples of 3 and 5
// https://www.hackerrank.com/contests/projecteuler/challenges/euler001
use std::iter::range_step;
use std::collections::BTreeSet;
use std::collections::BTreeMap;
fn | () {
let mut stdin = std::io::stdio::stdin();
let count = stdin.read_line().ok().unwrap().trim().parse().unwrap();
let mut numbers: Vec<i64> = Vec::new();
let mut results: Vec<i64> = Vec::new();
let mut numMap: BTreeMap<i64, Vec<uint>> = BTreeMap::new();
for i in range(0, count) {
let n:... | main | identifier_name |
project_euler_1.rs | // Project Euler #1: Multiples of 3 and 5
// https://www.hackerrank.com/contests/projecteuler/challenges/euler001
use std::iter::range_step;
use std::collections::BTreeSet;
use std::collections::BTreeMap;
fn main() | let mut sum = 0i64;
let mut prev = 0i64;
for &n in num_set.iter() {
for i in range_step(((prev + 2) / 3) * 3, n, 3) {
sum += i;
}
for i in range_step(((prev + 4) / 5) * 5, n, 5) {
if i % 3!= 0 {
sum += i;
}
}
prev = ... | {
let mut stdin = std::io::stdio::stdin();
let count = stdin.read_line().ok().unwrap().trim().parse().unwrap();
let mut numbers: Vec<i64> = Vec::new();
let mut results: Vec<i64> = Vec::new();
let mut numMap: BTreeMap<i64, Vec<uint>> = BTreeMap::new();
for i in range(0, count) {
let n: i6... | identifier_body |
project_euler_1.rs | // Project Euler #1: Multiples of 3 and 5
// https://www.hackerrank.com/contests/projecteuler/challenges/euler001
use std::iter::range_step;
use std::collections::BTreeSet;
use std::collections::BTreeMap;
fn main() {
let mut stdin = std::io::stdio::stdin();
let count = stdin.read_line().ok().unwrap().trim().pa... | ord_numbers.sort();
let num_set: BTreeSet<i64> = ord_numbers.iter().map(|&x| x).collect();
let mut sum = 0i64;
let mut prev = 0i64;
for &n in num_set.iter() {
for i in range_step(((prev + 2) / 3) * 3, n, 3) {
sum += i;
}
for i in range_step(((prev + 4) / 5) * 5, ... |
let mut ord_numbers = numbers.clone(); | random_line_split |
project_euler_1.rs | // Project Euler #1: Multiples of 3 and 5
// https://www.hackerrank.com/contests/projecteuler/challenges/euler001
use std::iter::range_step;
use std::collections::BTreeSet;
use std::collections::BTreeMap;
fn main() {
let mut stdin = std::io::stdio::stdin();
let count = stdin.read_line().ok().unwrap().trim().pa... |
}
prev = n;
let vec: &Vec<uint> = numMap.get(&n).unwrap();
for &j in vec.iter() {
results[j] = sum;
}
}
for r in results.iter() {
println!("{}", r);
}
}
| {
sum += i;
} | conditional_block |
cci_class_cast.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 ... |
priv impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
pub impl cat {
fn speak(&mut self) { self.meow(); }
fn eat(&mut self) -> bool {
... | fn to_str(&self) -> ~str { copy self.name }
} | random_line_split |
cci_class_cast.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 ... |
}
}
pub impl cat {
fn speak(&mut self) { self.meow(); }
fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
error!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
error!("N... | {
self.how_hungry += 1;
} | conditional_block |
cci_class_cast.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) -> ~str { copy self.name }
}
priv impl cat {
fn meow(&mut self) {
error!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
pub impl cat {
fn speak(&mut self) { self.meow(); ... | to_str | identifier_name |
resolve.rs | // Copyright 2015 The Delix Project Authors. See the AUTHORS file at the top level directory.
//
// 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
// | //
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the Licen... | // http://www.apache.org/licenses/LICENSE-2.0 | random_line_split |
resolve.rs | // Copyright 2015 The Delix Project Authors. See the AUTHORS file at the top level directory.
//
// 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-... | {
let mut result = Vec::new();
for address in addresses {
result.append(&mut try!(address.to_socket_addrs()).collect::<Vec<SocketAddr>>());
}
Ok(result)
} | identifier_body | |
resolve.rs | // Copyright 2015 The Delix Project Authors. See the AUTHORS file at the top level directory.
//
// 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-... | (address: &str) -> io::Result<SocketAddr> {
Ok(try!(try!(address.to_socket_addrs())
.next()
.ok_or(io::Error::new(io::ErrorKind::Other,
format!("could not resolve address [{}]", address)))))
}
pub fn socket_addresses(addresses: &[String]) -> io::R... | socket_address | 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 ... |
fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<Bytes> {
unsafe {
let mut outsz : size_t = 0;
let res = tinfl_decompress_mem_to_heap(bytes.as_ptr() as *const _,
bytes.len() as size_t,
&mut... | {
deflate_bytes_internal(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER)
} | identifier_body |
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
}
}
}
/// Decompress a buffer, without parsing any sort of header on the input.
pub fn inflate_bytes(bytes: &[u8]) -> Option<Bytes> {
inflate_bytes_internal(bytes, 0)
}
/// Decompress a buffer that starts with a zlib header.
pub fn inflate_bytes_zlib(bytes: &[u8]) -> Option<By... | {
let res = Unique(res as *mut u8);
Some(Bytes { ptr: res, len: outsz as uint })
} | 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 ... | (&self) -> &[u8] {
unsafe { slice::from_raw_mut_buf(&self.ptr.0, self.len) }
}
}
impl Drop for Bytes {
fn drop(&mut self) {
unsafe { libc::free(self.ptr.0 as *mut _); }
}
}
#[link(name = "miniz", kind = "static")]
extern {
/// Raw miniz compression function.
fn tdefl_compress_mem_t... | deref | 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 ... | fn test_zlib_flate() {
let bytes = vec!(1, 2, 3, 4, 5);
let deflated = deflate_bytes(bytes.as_slice()).expect("deflation failed");
let inflated = inflate_bytes(deflated.as_slice()).expect("inflation failed");
assert_eq!(inflated.as_slice(), bytes);
}
} | }
}
#[test] | random_line_split |
size_hint.rs | #![feature(core, unboxed_closures)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::SkipWhile;
struct | <T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self::Item> {
if self.begin < self.end {
let result = self.begin;
self.begin = self.begin.wrapping_add(1);
Some::<Self::Item>(result)
} els... | A | identifier_name |
size_hint.rs | #![feature(core, unboxed_closures)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::SkipWhile;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self:... | } |
assert_eq!(lower, 0);
assert_eq!(upper, Some::<usize>(20));
} | random_line_split |
main.rs | use std::env;
use std::fs;
use std::process;
// ANCHOR: here
fn | () {
// --snip--
// ANCHOR_END: here
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err| {
println!("Problem parsing arguments: {}", err);
process::exit(1);
});
// ANCHOR: here
println!("Searching for {}", config.query);
... | main | identifier_name |
main.rs | use std::env;
use std::fs;
use std::process;
// ANCHOR: here
fn main() {
// --snip--
// ANCHOR_END: here
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err| {
println!("Problem parsing arguments: {}", err);
process::exit(1);
});
... |
let query = args[1].clone();
let filename = args[2].clone();
Ok(Config { query, filename })
}
}
| {
return Err("not enough arguments");
} | conditional_block |
main.rs | use std::env;
use std::fs;
use std::process;
// ANCHOR: here
fn main() {
// --snip--
// ANCHOR_END: here
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err| {
println!("Problem parsing arguments: {}", err);
process::exit(1);
});
... |
// --snip--
// ANCHOR_END: here
struct Config {
query: String,
filename: String,
}
impl Config {
fn new(args: &[String]) -> Result<Config, &'static str> {
if args.len() < 3 {
return Err("not enough arguments");
}
let query = args[1].clone();
let filename = ar... | {
let contents = fs::read_to_string(config.filename)
.expect("Something went wrong reading the file");
println!("With text:\n{}", contents);
} | identifier_body |
main.rs | use std::env;
use std::fs;
use std::process;
// ANCHOR: here
fn main() {
// --snip--
// ANCHOR_END: here
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err| {
println!("Problem parsing arguments: {}", err);
process::exit(1);
});
| println!("In file {}", config.filename);
run(config);
}
fn run(config: Config) {
let contents = fs::read_to_string(config.filename)
.expect("Something went wrong reading the file");
println!("With text:\n{}", contents);
}
// --snip--
// ANCHOR_END: here
struct Config {
query: String,
... | // ANCHOR: here
println!("Searching for {}", config.query); | random_line_split |
bool.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 ... |
}
}
/**
* Iterates over all truth values, passing them to the given block.
*
* There are no guarantees about the order values will be given.
*
* # Examples
* ~~~
* do std::bool::all_values |x: bool| {
* println(x.to_str())
* }
* ~~~
*/
pub fn all_values(blk: &fn(v: bool)) {
blk(true);
blk(false);
}
/... | { ~"false" } | conditional_block |
bool.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 ... | () {
assert_eq!(true.cmp(&true), Equal);
assert_eq!(false.cmp(&false), Equal);
assert_eq!(true.cmp(&false), Greater);
assert_eq!(false.cmp(&true), Less);
}
}
| test_bool_totalord | identifier_name |
bool.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 ... |
/**
* Parse a `bool` from a `str`.
*
* Yields an `Option<bool>`, because `str` may or may not actually be parseable.
*
* # Examples
*
* ~~~ {.rust}
* rusti> FromStr::from_str::<bool>("true")
* Some(true)
* ~~~
*
* ~~~ {.rust}
* rusti> FromStr::from_str::<bool>("false")
* Some(false)
* ~~~
*
* ~~~ {.rust}
* rusti> Fro... | { !v } | identifier_body |
bool.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 ... | *
* ~~~ {.rust}
* rusti> std::bool::not(false)
* true
* ~~~
*/
pub fn not(v: bool) -> bool {!v }
/**
* Conjunction of two boolean values.
*
* # Examples
*
* ~~~ {.rust}
* rusti> std::bool::and(true, false)
* false
* ~~~
*
* ~~~ {.rust}
* rusti> std::bool::and(true, true)
* true
* ~~~
*/
pub fn and(a: bool, b: bool) ->... | *
* ~~~ {.rust}
* rusti> std::bool::not(true)
* false
* ~~~ | random_line_split |
text.rs | InlineFragments {
fragments: new_fragments,
}
}
/// A "clump" is a range of inline flow leaves that can be merged together into a single
/// fragment. Adjacent text with the same style can be merged, and nothing else can.
///
/// The flow keeps track of the fragments containe... | }
if text_rendering == TextRendering::Optimizespeed {
flags.insert(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG);
flags.insert(ShapingFlags::DISABLE_KERNING_SHAPING_FLAG)
}
if word_break == WordBreak::KeepAll {
flags.insert(Sha... | flags.insert(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG);
}
| conditional_block |
text.rs | let mut result = Vec::with_capacity(run_info_list.len());
for run_info in run_info_list {
let mut options = options;
options.script = run_info.script;
if run_info.bidi_level.is_rtl() {
options.flags.insert(ShapingFlags::RTL_FLAG);
... | a == b || !is_specific(a) || !is_specific(b)
}
/ | identifier_body | |
text.rs | InlineFragments {
fragments: new_fragments,
}
}
/// A "clump" is a range of inline flow leaves that can be merged together into a single
/// fragment. Adjacent text with the same style can be merged, and nothing else can.
///
/// The flow keeps track of the fragments contain... | result.push((ScannedTextRun {
run: Arc::new(run),
insertion_point: run_info.insertion_point,
}, break_at_zero))
}
result
};
// Make new fragments with the runs and adjusted text indices.
debug!("Text... | let (run, break_at_zero) = TextRun::new(&mut *font,
run_info.text,
&options,
run_info.bidi_level,
... | random_line_split |
text.rs | .is_empty());
match self.clump.front().unwrap().specific {
SpecificFragmentInfo::UnscannedText(_) => {}
_ => {
debug_assert!(self.clump.len() == 1,
"WAT: can't coalesce non-text nodes in flush_clump_to_list()!");
out_fragments... | t_metrics_for_style(fo | identifier_name | |
tests.rs | use super::mmtree;
use super::mixer;
use traits::*;
use params::*;
use synth::Synth;
use efx::Efx;
use efx::volume::{Volume, VolumeParams};
#[test]
fn create_tree() {
let mut t = mmtree::MMTree::new();
// always them root mixer
assert_eq!(t.mixer_count(), 1);
// structure.
t.add_mixer("root", "m... |
}
#[test]
fn transient_mixers() {
// transient mixers are mixers that get removed from the tree
// when silenced.. (think the note of an instrument)
let mut tree = mmtree::MMTree::new();
let transient_mixer_id = tree.add_transient_mixer("root").unwrap();
tree.add_synth(&transient_mixer_id, Box:... | {
if self.tic < self.nb_samples {
self.tic += 1;
SoundSample::Sample(sample)
} else {
SoundSample::Done
}
} | identifier_body |
tests.rs | use super::mmtree;
use super::mixer;
use traits::*;
use params::*;
use synth::Synth;
use efx::Efx;
use efx::volume::{Volume, VolumeParams};
#[test]
fn create_tree() {
let mut t = mmtree::MMTree::new();
// always them root mixer
assert_eq!(t.mixer_count(), 1);
// structure.
t.add_mixer("root", "m... |
assert_eq!(mixer.sample(), mono_value(4.));
}
#[test]
fn mixer_efx() {
let mut mixer = mixer::Mixer::new("test");
mixer.add_synth(Box::new(CstSynth::new(1.0)));
let v = Box::new(Volume::new(VolumeParams::default().volume(0.6)));
mixer.add_efx(v);
assert_eq!(mixer.sample(), mono_value(0.6));
... |
mixer.add_synth(Box::new(CstSynth::new(1.0)));
mixer.add_synth(Box::new(CstSynth::new(3.0))); | random_line_split |
tests.rs | use super::mmtree;
use super::mixer;
use traits::*;
use params::*;
use synth::Synth;
use efx::Efx;
use efx::volume::{Volume, VolumeParams};
#[test]
fn create_tree() {
let mut t = mmtree::MMTree::new();
// always them root mixer
assert_eq!(t.mixer_count(), 1);
// structure.
t.add_mixer("root", "m... |
for _ in 0..2 {
let synth = Box::new(Sine::new(SineParams::default().frequency("f")));
tree.add_synth(&parent_id, synth).unwrap();
}
}
println!("tree is {}", tree.mixer_count());
tree.set_bus_value("f", 0.5).unwrap();
// 10 sam... | {
for j in 0..TREE_WIDTH {
let new_id = format!("{}_{}", parent_id, j);
println!("{} -> {}", parent_id, new_id);
tree.add_mixer(&parent_id, &new_id).unwrap();
stack.push((new_id, level + 1));
}
} | conditional_block |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.