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
tags.rs
use super::util; use anyhow::{anyhow, Result}; use std::io::{self, Write}; use std::path::Path; use std::time::Instant; use std::{fs, str}; use tree_sitter_loader::Loader; use tree_sitter_tags::TagsContext; pub fn generate_tags( loader: &Loader, scope: Option<&str>, paths: &[String], quiet: bool, t...
None => { eprintln!("No language found for path {:?}", path); continue; } }, }; if let Some(tags_config) = language_config.tags_config(language)? { let indent; if paths.len() > 1 { ...
{ let mut lang = None; if let Some(scope) = scope { lang = loader.language_configuration_for_scope(scope)?; if lang.is_none() { return Err(anyhow!("Unknown scope '{}'", scope)); } } let mut context = TagsContext::new(); let cancellation_flag = util::cancel_on_std...
identifier_body
print_completion_loop.rs
// // use async_std::prelude::*; // use async_std::fs; // use std::sync::Arc; // use eyre::{ // eyre, // Result, // // Context as _, // }; // // use bytes::BufMut; // use futures::stream::{StreamExt}; // use crate::models::VersionedModel; // use crate::print_queue::tasks::{ // Task, // // TaskStat...
// } // _ => {} // } // } // } // async fn handle_print_completion( // ctx: &Arc<crate::Context>, // automatic_printing: bool, // task: &Task, // ) -> Result<()> { // let print = task.print.as_ref().ok_or_else(|| // eyre!("Missing print for task: {}", task.id...
// fs::remove_file(file_path).await?; // }
random_line_split
issue-2631-b.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. //
// 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. #[feature(managed_boxes)]; // ignore-fast // aux-build:issue-2631-a.rs extern crate co...
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
issue-2631-b.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 v = vec!(@~"hi"); let mut m: req::header_map = HashMap::new(); m.insert(~"METHOD", @RefCell::new(v)); request::<int>(&m); }
main
identifier_name
issue-2631-b.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 v = vec!(@~"hi"); let mut m: req::header_map = HashMap::new(); m.insert(~"METHOD", @RefCell::new(v)); request::<int>(&m); }
identifier_body
sgash.rs
/* kernel::sgash.rs */ #[allow(unused_imports)]; use core::*; use core::str::*; use core::option::{Some, Option, None}; use core::iter::Iterator; use kernel::*; use kernel::vec::Vec; use super::super::platform::*; use kernel::memory::Allocator; use kernel::memory::BuddyAlloc; use kernel::memory::Bitv; use kernel::mem...
*(((self.p as uint)+self.p_cstr_i) as *mut u8) = x; self.p_cstr_i += 1; *(((self.p as uint)+self.p_cstr_i) as *mut char) = '\0'; true } unsafe fn delete_char(&mut self) -> bool { if (self.p_cstr_i == 0) { return false; } self.p_cstr_i -= 1; *(((self.p as...
{ putstr("not able to add"); return false; }
conditional_block
sgash.rs
/* kernel::sgash.rs */ #[allow(unused_imports)]; use core::*; use core::str::*; use core::option::{Some, Option, None}; use core::iter::Iterator; use kernel::*; use kernel::vec::Vec; use super::super::platform::*; use kernel::memory::Allocator; use kernel::memory::BuddyAlloc; use kernel::memory::Bitv; use kernel::mem...
_ => { if io::CURSOR_X < io::SCREEN_WIDTH-io::CURSOR_WIDTH && buffer.add_char(x) { putchar(x as char); drawchar(x as char); } } } } unsafe fn parse(){ // cd, rm, mkdir, pwd match buffer.getarg(' ', 0) { Some(a) => { if(a.equals(&"echo")) { match buffer.getar...
{ let x = x as u8; // Set this to false to learn the keycodes of various keys! // Key codes are printed backwards because life is hard match x { 13 => { parse(); putstr(&"\nsgash> "); drawstr(&"\nsgash> "); buffer.reset(); } 127 => { putchar(''); putchar(' '); putch...
identifier_body
sgash.rs
/* kernel::sgash.rs */ #[allow(unused_imports)]; use core::*; use core::str::*; use core::option::{Some, Option, None}; use core::iter::Iterator; use kernel::*; use kernel::vec::Vec; use super::super::platform::*; use kernel::memory::Allocator; use kernel::memory::BuddyAlloc; use kernel::memory::Bitv; use kernel::mem...
(&self, delim: char, mut k: uint) -> Option<cstr> { let mut ind: uint = 0; let mut found = k == 0; let mut selfp: uint = self.p as uint; s.reset(); loop { if (*(selfp as *char) == '\0') { // End of string //return a copy of s (write copy method) // erased from nex...
getarg
identifier_name
sgash.rs
/* kernel::sgash.rs */ #[allow(unused_imports)]; use core::*; use core::str::*; use core::option::{Some, Option, None}; use core::iter::Iterator; use kernel::*; use kernel::vec::Vec; use super::super::platform::*; use kernel::memory::Allocator; use kernel::memory::BuddyAlloc; use kernel::memory::Bitv; use kernel::mem...
putchar(''); backspace(); buffer.delete_char(); } _ => { if io::CURSOR_X < io::SCREEN_WIDTH-io::CURSOR_WIDTH && buffer.add_char(x) { putchar(x as char); drawchar(x as char); } } } } unsafe fn parse(){ // cd, rm, mkdir, pwd match buffer.getarg(' ', 0) { Some(a...
putchar(''); putchar(' ');
random_line_split
matrices.rs
use libc::{c_double}; use cairo::ffi; #[repr(C)] pub struct Matrix{ xx: c_double, yx: c_double, xy: c_double, yy: c_double, x0: c_double, y0: c_double, } impl Matrix{ pub fn null() -> Matrix{ Matrix{ xx: 0.0, yx: 0.0, xy: 0.0, yy: 0.0, x0: 0.0, y0: 0.0 } } pub fn ...
(&mut self){ let result = unsafe{ ffi::cairo_matrix_invert(self) }; result.ensure_valid(); } pub fn transform_distance(&self, _dx: f64, _dy: f64) -> (f64, f64){ let mut dx = _dx; let mut dy = _dy; unsafe{ ffi::cairo_matrix_transform_distance(self, &mut dx, &mut dy); } (dx, dy) } pub fn tran...
invert
identifier_name
matrices.rs
use libc::{c_double}; use cairo::ffi; #[repr(C)] pub struct Matrix{ xx: c_double, yx: c_double, xy: c_double, yy: c_double, x0: c_double, y0: c_double, } impl Matrix{ pub fn null() -> Matrix{ Matrix{ xx: 0.0, yx: 0.0, xy: 0.0, yy: 0.0, x0: 0.0, y0: 0.0 } } pub fn ...
pub fn scale(&mut self, sx: f64, sy: f64){ unsafe{ ffi::cairo_matrix_scale(self, sx, sy) } } pub fn rotate(&mut self, angle: f64){ unsafe{ ffi::cairo_matrix_rotate(self, angle) } } pub fn invert(&mut self){ let result = unsafe{ ffi::cairo_matrix_invert(self) }; result.ensure_valid(); } ...
{ unsafe{ ffi::cairo_matrix_translate(self, tx, ty) } }
identifier_body
coerce-issue-49593-box-never.rs
// revisions: nofallback fallback //[fallback] check-pass //[nofallback] check-fail #![feature(never_type)] #![cfg_attr(fallback, feature(never_type_fallback))] #![allow(unreachable_code)] use std::error::Error; use std::mem;
/* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /*! */>::new(x) //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied } fn foo_raw_ptr(x:!) -> *mut dyn Error { /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /*! */>(x) //[nofallback]~^ ERROR trait bound `(): st...
fn raw_ptr_box<T>(t: T) -> *mut T { panic!() } fn foo(x: !) -> Box<dyn Error> {
random_line_split
coerce-issue-49593-box-never.rs
// revisions: nofallback fallback //[fallback] check-pass //[nofallback] check-fail #![feature(never_type)] #![cfg_attr(fallback, feature(never_type_fallback))] #![allow(unreachable_code)] use std::error::Error; use std::mem; fn raw_ptr_box<T>(t: T) -> *mut T { panic!() } fn foo(x:!) -> Box<dyn Error>
fn foo_raw_ptr(x:!) -> *mut dyn Error { /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /*! */>(x) //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied } fn no_coercion(d: *mut dyn Error) -> *mut dyn Error { /* an unsize coercion won't compile here, and it is indeed not...
{ /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x) //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied }
identifier_body
coerce-issue-49593-box-never.rs
// revisions: nofallback fallback //[fallback] check-pass //[nofallback] check-fail #![feature(never_type)] #![cfg_attr(fallback, feature(never_type_fallback))] #![allow(unreachable_code)] use std::error::Error; use std::mem; fn raw_ptr_box<T>(t: T) -> *mut T { panic!() } fn foo(x:!) -> Box<dyn Error> { /* ...
x = Some(S); first_iter = true; } let mut y : Option<S> = None; // assert types are equal mem::swap(&mut x, &mut y); } fn main() { }
{ let y: Box<dyn Xyz> = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap()); }
conditional_block
coerce-issue-49593-box-never.rs
// revisions: nofallback fallback //[fallback] check-pass //[nofallback] check-fail #![feature(never_type)] #![cfg_attr(fallback, feature(never_type_fallback))] #![allow(unreachable_code)] use std::error::Error; use std::mem; fn raw_ptr_box<T>(t: T) -> *mut T { panic!() } fn foo(x:!) -> Box<dyn Error> { /* ...
(d: *mut dyn Error) -> *mut dyn Error { /* an unsize coercion won't compile here, and it is indeed not used because there is nothing requiring the _ to be Sized */ d as *mut _ } trait Xyz {} struct S; struct T; impl Xyz for S {} impl Xyz for T {} fn foo_no_never() { let mut x /* : Option<S> */ = No...
no_coercion
identifier_name
bookitem.rs
extern crate rustc_serialize; use self::rustc_serialize::json::{Json, ToJson}; use std::path::PathBuf; use std::collections::BTreeMap; #[derive(Debug, Clone)] pub enum BookItem { Chapter(String, Chapter), // String = section Affix(Chapter), Spacer, } #[derive(Debug, Clone)] pub struct Chapter { pub n...
Chapter { name: name, path: path, sub_items: vec![], } } } impl ToJson for Chapter { fn to_json(&self) -> Json { let mut m: BTreeMap<String, Json> = BTreeMap::new(); m.insert("name".to_owned(), self.name.to_json()); m.insert("path".t...
pub fn new(name: String, path: PathBuf) -> Self {
random_line_split
bookitem.rs
extern crate rustc_serialize; use self::rustc_serialize::json::{Json, ToJson}; use std::path::PathBuf; use std::collections::BTreeMap; #[derive(Debug, Clone)] pub enum BookItem { Chapter(String, Chapter), // String = section Affix(Chapter), Spacer, } #[derive(Debug, Clone)] pub struct Chapter { pub n...
(&self) -> Json { let mut m: BTreeMap<String, Json> = BTreeMap::new(); m.insert("name".to_owned(), self.name.to_json()); m.insert("path".to_owned(),self.path.to_str() .expect("Json conversion failed for path").to_json() ); m.to_json() } } // Shamelessly copied f...
to_json
identifier_name
bookitem.rs
extern crate rustc_serialize; use self::rustc_serialize::json::{Json, ToJson}; use std::path::PathBuf; use std::collections::BTreeMap; #[derive(Debug, Clone)] pub enum BookItem { Chapter(String, Chapter), // String = section Affix(Chapter), Spacer, } #[derive(Debug, Clone)] pub struct Chapter { pub n...
} return Some(cur) } } } }
{ self.current_index += 1; }
conditional_block
object.rs
use ast::token; use class::{LoxClass,LoxInstance}; use functions::Callable; use std::cmp::Ordering; use std::fmt; use std::cmp; use std::rc::Rc; #[derive(Clone, Debug)] pub enum
{ Literal(token::Literal), Func(Callable), Class(Rc<LoxClass>), Instance(LoxInstance), } impl Object { pub fn is_truthy(&self) -> bool { use ast::token::Literal::*; match *self { Object::Func(_) | Object::Class(_) | Object::Instance(_) => true, Object::Lite...
Object
identifier_name
object.rs
use ast::token; use class::{LoxClass,LoxInstance}; use functions::Callable; use std::cmp::Ordering; use std::fmt; use std::cmp; use std::rc::Rc; #[derive(Clone, Debug)] pub enum Object { Literal(token::Literal), Func(Callable), Class(Rc<LoxClass>), Instance(LoxInstance), } impl Object { pub fn is_...
Object::Func(ref c) => debug_drop!("Object::Func {:?}", c), Object::Class(ref c) => debug_drop!("Object::Class {:?} ({} refs remain)", c, Rc::strong_count(&c)-1), Object::Instance(ref i) => debug_drop!("Object::Instance {:?}", i), ...
debug_drop!("Object::Literal {:?}", lit),
random_line_split
object.rs
use ast::token; use class::{LoxClass,LoxInstance}; use functions::Callable; use std::cmp::Ordering; use std::fmt; use std::cmp; use std::rc::Rc; #[derive(Clone, Debug)] pub enum Object { Literal(token::Literal), Func(Callable), Class(Rc<LoxClass>), Instance(LoxInstance), } impl Object { pub fn is_...
} #[cfg(feature = "debug-destructors")] impl Drop for Object{ fn drop(&mut self) { match *self { Object::Literal(ref lit) => debug_drop!("Object::Literal {:?}", lit), Object::Func(ref c) => debug_drop!("Object::Func {:?}", c), Object::Cla...
{ use ast::token::Literal::*; match *self { Object::Func(_) | Object::Class(_) | Object::Instance(_) => true, Object::Literal(ref lit) => match *lit { Nil => false, Boolean(b) => b, Number(n) => n != 0.0, String(ref...
identifier_body
prompt.rs
use super::super::{Capture, Function, Shell}; use parser::shell_expand::expand_string; use std::{io::Read, process}; use sys; pub(crate) fn prompt(shell: &mut Shell) -> String { if shell.flow_control.level == 0 { match prompt_fn(shell) { Some(prompt) => prompt, None => expand_string...
} // Ensure that the parent retains ownership of the terminal before exiting. let _ = sys::tcsetpgrp(sys::STDIN_FILENO, process::id()); output }
{ let function = shell.functions.get("PROMPT")? as *const Function; let mut output = None; match shell.fork(Capture::StdoutThenIgnoreStderr, |child| unsafe { let _ = function.read().execute(child, &["ion"]); }) { Ok(result) => { let mut string = String::with_capacity(1024);...
identifier_body
prompt.rs
use super::super::{Capture, Function, Shell}; use parser::shell_expand::expand_string; use std::{io::Read, process}; use sys; pub(crate) fn prompt(shell: &mut Shell) -> String { if shell.flow_control.level == 0 { match prompt_fn(shell) { Some(prompt) => prompt, None => expand_string...
}
random_line_split
prompt.rs
use super::super::{Capture, Function, Shell}; use parser::shell_expand::expand_string; use std::{io::Read, process}; use sys; pub(crate) fn
(shell: &mut Shell) -> String { if shell.flow_control.level == 0 { match prompt_fn(shell) { Some(prompt) => prompt, None => expand_string(&shell.get_var_or_empty("PROMPT"), shell, false).join(" "), } } else { " ".repeat(shell.flow_control.level as usize) } ...
prompt
identifier_name
prompt.rs
use super::super::{Capture, Function, Shell}; use parser::shell_expand::expand_string; use std::{io::Read, process}; use sys; pub(crate) fn prompt(shell: &mut Shell) -> String { if shell.flow_control.level == 0 { match prompt_fn(shell) { Some(prompt) => prompt, None => expand_string...
} pub(crate) fn prompt_fn(shell: &mut Shell) -> Option<String> { let function = shell.functions.get("PROMPT")? as *const Function; let mut output = None; match shell.fork(Capture::StdoutThenIgnoreStderr, |child| unsafe { let _ = function.read().execute(child, &["ion"]); }) { Ok(resul...
{ " ".repeat(shell.flow_control.level as usize) }
conditional_block
mod.rs
// Copyright 2015-2017 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 later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Publ...
random_line_split
id_type.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// // By contributing code to the SAFE Network Software, or to this project generally, you agree to be // bound by the terms of the MaidSafe Contributor Agreement, version 1.0. This, along with the // Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR. // // Unless required...
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences").
random_line_split
id_type.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
/// Encrypts and authenticates data. It returns a ciphertext and the Nonce. pub fn seal(&self, data : &[u8], to : &::sodiumoxide::crypto::box_::PublicKey) -> (Vec<u8>, ::sodiumoxide::crypto::box_::Nonce) { let nonce = ::sodiumoxide::crypto::box_::gen_nonce(); let sealed = ::sodiumoxide::crypto...
{ return ::sodiumoxide::crypto::sign::sign(&data, &self.secret_keys.0) }
identifier_body
id_type.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
{ type_tag : u64, public_keys: (::sodiumoxide::crypto::sign::PublicKey, ::sodiumoxide::crypto::box_::PublicKey), secret_keys: (::sodiumoxide::crypto::sign::SecretKey, ::sodiumoxide::crypto::box_::SecretKey), } impl IdType { /// Invoked to create an instance of IdType pub fn new(revocation_id: &:...
IdType
identifier_name
trait-inheritance-static.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 ...
<T:NumExt>() -> T { MyNum::from_int(1) } pub fn main() { let v: S = greater_than_one(); assert!(v.v == 1); }
greater_than_one
identifier_name
trait-inheritance-static.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait MyNum { ...
random_line_split
trait-inheritance-static.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 fn main() { let v: S = greater_than_one(); assert!(v.v == 1); }
{ MyNum::from_int(1) }
identifier_body
outline.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Specified values for outline properties use crate::parser::{Parse, ParserContext}; use crate::values::specif...
<'i, 't>( _context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<OutlineStyle, ParseError<'i>> { if let Ok(border_style) = input.try_parse(BorderStyle::parse) { if let BorderStyle::Hidden = border_style { return Err(input .new_custom_...
parse
identifier_name
outline.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Specified values for outline properties use crate::parser::{Parse, ParserContext}; use crate::values::specif...
} }
random_line_split
restrictions.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 ...
mc::Implicit(bk, lt) | mc::BorrowedPtr(bk, lt) => { // R-Deref-[Mut-]Borrowed if!self.bccx.is_subregion_of(self.loan_region, lt) { self.bccx.report( BckError { ...
{ // R-Deref-Send-Pointer // // When we borrow the interior of a box, we // cannot permit the base to be mutated, because that // would cause the unique pointer to be freed. //...
conditional_block
restrictions.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 ...
Safe } mc::cat_local(local_id) => { // R-Variable, locally declared let lp = new_lp(LpVar(local_id)); SafeIf(lp.clone(), vec![lp]) } mc::cat_upvar(mc::Upvar { id,.. }) => { // R-Variable, ca...
random_line_split
restrictions.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, cmt: mc::cmt<'tcx>) -> RestrictionResult<'tcx> { debug!("restrict(cmt={:?})", cmt); let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty)); match cmt.cat.clone() { mc::cat_rvalue(..) => { // Effectively, rvalues are stored int...
restrict
identifier_name
expr-match-generic-unique2.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...
test_generic::<Box<isize>, _>(box 1, compare_box); } pub fn main() { test_vec(); }
{ return v1 == v2; }
identifier_body
expr-match-generic-unique2.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...
pub fn main() { test_vec(); }
test_generic::<Box<isize>, _>(box 1, compare_box); }
random_line_split
expr-match-generic-unique2.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...
<T: Clone, F>(expected: T, eq: F) where F: FnOnce(T, T) -> bool { let actual: T = match true { true => expected.clone(), _ => panic!("wat") }; assert!(eq(expected, actual)); } fn test_vec() { fn compare_box(v1: Box<isize>, v2: Box<isize>) -> bool { return v1 == v2; } test_generic::<...
test_generic
identifier_name
main.rs
use std::convert::Infallible; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use hyper::service; use hyper::{Body, Method, Request, Response, Server, StatusCode}; #[tokio::main] async fn main() { let listen_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080); Server::bind(&listen_addr) .serve(...
(&Method::GET, "/latest/meta-data/iam/security-credentials/testrole") => { Response::new(Body::from(ROLE_JSON)) } _ => Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from("unsupported")) .unwrap(), } }
{ Response::new(Body::from("testrole")) }
conditional_block
main.rs
use std::convert::Infallible; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use hyper::service; use hyper::{Body, Method, Request, Response, Server, StatusCode}; #[tokio::main] async fn main() { let listen_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080); Server::bind(&listen_addr) .serve(...
"Type" : "AWS-HMAC", "AccessKeyId" : "Access_key_id_value", "SecretAccessKey" : "Secret_access_key_value", "Token" : "AAAAA", "Expiration" : "2015-08-04T06:32:37Z" }"#; async fn handle(req: Request<Body>) -> Response<Body> { match (req.method(), req.uri().path()) { (&Method::GET, "/latest/meta-da...
const ROLE_JSON: &str = r#"{ "Code" : "Success", "LastUpdated" : "2015-08-04T00:09:23Z",
random_line_split
main.rs
use std::convert::Infallible; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use hyper::service; use hyper::{Body, Method, Request, Response, Server, StatusCode}; #[tokio::main] async fn main() { let listen_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080); Server::bind(&listen_addr) .serve(...
{ match (req.method(), req.uri().path()) { (&Method::GET, "/latest/meta-data/iam/security-credentials/") => { Response::new(Body::from("testrole")) } (&Method::GET, "/latest/meta-data/iam/security-credentials/testrole") => { Response::new(Body::from(ROLE_JSON)) ...
identifier_body
main.rs
use std::convert::Infallible; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use hyper::service; use hyper::{Body, Method, Request, Response, Server, StatusCode}; #[tokio::main] async fn main() { let listen_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080); Server::bind(&listen_addr) .serve(...
(req: Request<Body>) -> Response<Body> { match (req.method(), req.uri().path()) { (&Method::GET, "/latest/meta-data/iam/security-credentials/") => { Response::new(Body::from("testrole")) } (&Method::GET, "/latest/meta-data/iam/security-credentials/testrole") => { Resp...
handle
identifier_name
traits.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} // The `<` is pronounced `extends`. Also under consideration is `<:`. // Just using `:` is frowned upon, because (paraphrasing dherman) `:` // is supposed to separate things from different universes. trait Ord < Eq { fn lt(a: self) -> bool; fn lte(a: self) -> bool { self.lt(a) || self.eq(a) }...
{ !self.eq(a) }
identifier_body
traits.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 ...
// methods with no implementation are required; methods with an // implementation are provided. No "req" keyword necessary. trait Eq { fn eq(a: self) -> bool; fn neq(a: self) -> bool { !self.eq(a) } } // The `<` is pronounced `extends`. Also under consideration is `<:`. // Just using `:` is frow...
// Sketching traits.
random_line_split
traits.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 ...
(a: self) -> bool { !self.lt(a) &&!self.eq(a) } fn gte(a: self) -> bool { !self.lt(a) } } // pronounced "impl of Ord for int" -- not sold on this yet impl Ord for int { fn lt(a: &int) -> bool { self < (*a) } // is this the place to put this? fn eq(a: &int) -> bool { ...
gt
identifier_name
block-disambig.rs
// compile-flags: --crate-type=lib // A bunch of tests for syntactic forms involving blocks that were // previously ambiguous (e.g., 'if true { } *val;' gets parsed as a // binop) use std::cell::Cell; fn test1() { let val = &0; { } *val; } fn test2() -> isize { let val = &0; { } *val } #[derive(Copy, Clone)] stru...
() -> Vec<isize> { if true { } vec![1, 2] }
test11
identifier_name
block-disambig.rs
// compile-flags: --crate-type=lib // A bunch of tests for syntactic forms involving blocks that were // previously ambiguous (e.g., 'if true { } *val;' gets parsed as a // binop) use std::cell::Cell; fn test1() { let val = &0; { } *val; } fn test2() -> isize { let val = &0; { } *val } #[derive(Copy, Clone)] stru...
_ => { } } regs.set(S {eax: 1}); } fn test4() -> bool { let regs = &true; if true { } *regs || false } fn test5() -> (isize, isize) { { } (0, 1) } fn test6() -> bool { { } (true || false) && true } fn test7() -> usize { let regs = &0; match true { true => { } _ => { } } (*regs < 2) as usize } fn t...
{ }
conditional_block
block-disambig.rs
// compile-flags: --crate-type=lib // A bunch of tests for syntactic forms involving blocks that were // previously ambiguous (e.g., 'if true { } *val;' gets parsed as a // binop) use std::cell::Cell; fn test1() { let val = &0; { } *val; } fn test2() -> isize { let val = &0; { } *val } #[derive(Copy, Clone)] stru...
fn test6() -> bool { { } (true || false) && true } fn test7() -> usize { let regs = &0; match true { true => { } _ => { } } (*regs < 2) as usize } fn test8() -> isize { let val = &0; match true { true => { } _ => { } } if *val < 1 { 0 } else { 1 }...
fn test4() -> bool { let regs = &true; if true { } *regs || false } fn test5() -> (isize, isize) { { } (0, 1) }
random_line_split
block-disambig.rs
// compile-flags: --crate-type=lib // A bunch of tests for syntactic forms involving blocks that were // previously ambiguous (e.g., 'if true { } *val;' gets parsed as a // binop) use std::cell::Cell; fn test1() { let val = &0; { } *val; } fn test2() -> isize { let val = &0; { } *val } #[derive(Copy, Clone)] stru...
fn test8() -> isize { let val = &0; match true { true => { } _ => { } } if *val < 1 { 0 } else { 1 } } fn test9() { let regs = &Cell::new(0); match true { true => { } _ => { } } regs.set(regs.get() + 1); } fn test10() -> isize { let regs = vec![...
{ let regs = &0; match true { true => { } _ => { } } (*regs < 2) as usize }
identifier_body
lib.rs
// Copyright Cryptape Technologies 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 ...
// See the License for the specific language governing permissions and // limitations under the License. #[macro_use] extern crate libproto; #[macro_use] extern crate cita_logger as logger; #[macro_use] extern crate serde_derive; #[macro_use] extern crate util; #[cfg(test)] extern crate cita_crypto; extern crate cita...
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
random_line_split
mod.rs
/************************************************************************ * * * Copyright 2014 Thomas Poinsot, Urban Hafner * * Copyright 2015 Urban Hafner, Igor Polyakov * * ...
let mut g = Game::new(3, 6.5, KgsChinese); g = g.play(Play(Black, 2, 2)).unwrap(); g = g.play(Play(White, 1, 2)).unwrap(); g = g.play(Play(Black, 2, 1)).unwrap(); g = g.play(Play(White, 3, 2)).unwrap(); g = g.play(Play(Black, 2, 3)).unwrap(); g = g.play(Play(White, 3, 1)).unwrap(); g = g.p...
icide_moves_in_chinese() {
identifier_name
mod.rs
/************************************************************************ * * * Copyright 2014 Thomas Poinsot, Urban Hafner * * Copyright 2015 Urban Hafner, Igor Polyakov * * ...
t g = Game::new(9, 6.5, KgsChinese); let res = g.play(Resign(Black)); assert!(res.is_ok()); }
identifier_body
mod.rs
/************************************************************************ * * * Copyright 2014 Thomas Poinsot, Urban Hafner * * Copyright 2015 Urban Hafner, Igor Polyakov * * ...
Err(e) => assert_eq!(e, IllegalMove::SuicidePlay), Ok(_) => panic!("Expected Err!") } } #[test] fn it_should_handle_resign() { let g = Game::new(9, 6.5, KgsChinese); let res = g.play(Resign(Black)); assert!(res.is_ok()); }
let play = g.play(Play(White, 1, 1)); match play {
random_line_split
mod.rs
pub type c_long = i32; pub type c_ulong = u32; pub type nlink_t = u32; pub type blksize_t = ::c_long; pub type __u64 = ::c_ulonglong; pub type regoff_t = ::c_int; s! { pub struct pthread_attr_t { __size: [u32; 9] } pub struct sigset_t { __val: [::c_ulong; 32], } pub struct msghdr ...
cfg_if! { if #[cfg(any(target_arch = "x86"))] { mod x86; pub use self::x86::*; } else if #[cfg(any(target_arch = "mips"))] { mod mips; pub use self::mips::*; } else if #[cfg(any(target_arch = "arm"))] { mod arm; pub use self::arm::*; } else if #[cfg(any(t...
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; }
random_line_split
lib.rs
extern crate rand; use rand::{Rng, SeedableRng, XorShiftRng}; use std::cmp; use std::collections::{BTreeMap, HashMap, VecDeque}; use std::fs::File; use std::io::{self, Read}; use std::path::Path; pub struct Corpus { seed: [u32; 4], max_context: usize, words: Vec<String>, table: HashMap<Vec<String>, BT...
pub fn words(&self, start: &[&str]) -> Chain { Chain { rng: SeedableRng::from_seed(self.seed), history: start.iter() .map(|&s| s.to_lowercase()) .collect(), corpus: self, } } } impl<'a> Iterator for Chain<'a> { type Item = ...
{ self.seed }
identifier_body
lib.rs
extern crate rand; use rand::{Rng, SeedableRng, XorShiftRng}; use std::cmp; use std::collections::{BTreeMap, HashMap, VecDeque}; use std::fs::File; use std::io::{self, Read}; use std::path::Path; pub struct Corpus { seed: [u32; 4], max_context: usize, words: Vec<String>, table: HashMap<Vec<String>, BT...
(&self, start: &[&str]) -> Chain { Chain { rng: SeedableRng::from_seed(self.seed), history: start.iter() .map(|&s| s.to_lowercase()) .collect(), corpus: self, } } } impl<'a> Iterator for Chain<'a> { type Item = &'a str; fn n...
words
identifier_name
lib.rs
extern crate rand; use rand::{Rng, SeedableRng, XorShiftRng}; use std::cmp; use std::collections::{BTreeMap, HashMap, VecDeque}; use std::fs::File; use std::io::{self, Read}; use std::path::Path; pub struct Corpus { seed: [u32; 4], max_context: usize, words: Vec<String>, table: HashMap<Vec<String>, BT...
None => {} } } } let word = self.rng.choose(&self.corpus.words) .expect("corpus words shouldn't be empty"); self.history.push_back(word.clone()); Some(word) } }
{ let r = self.rng.gen::<f64>(); let mut acc = 0.0; for (word, prob) in word_probs { acc += *prob; if acc > r { self.history.push_back(word.clone()); ...
conditional_block
lib.rs
extern crate rand; use rand::{Rng, SeedableRng, XorShiftRng}; use std::cmp; use std::collections::{BTreeMap, HashMap, VecDeque}; use std::fs::File; use std::io::{self, Read}; use std::path::Path; pub struct Corpus { seed: [u32; 4], max_context: usize,
pub struct Chain<'a> { rng: XorShiftRng, history: VecDeque<String>, corpus: &'a Corpus, } impl Corpus { pub fn new(path: &Path, max_context: usize) -> io::Result<Corpus> { let mut f = try!(File::open(path)); let mut buffer = String::new(); try!(f.read_to_string(&mut buffer)); ...
words: Vec<String>, table: HashMap<Vec<String>, BTreeMap<String, f64>>, }
random_line_split
sound.rs
//! Manages the gameboy sound controller //! This is mostly incomplete, at the moment all this does is manage the sound registers. pub struct SoundController { /// Channel 1 Sweep register pub nr10: u8, /// Channel 1 Sound length/Wave pattern duty pub nr11: u8, /// Channel 1 Volume Envelope (R/W) ...
() -> SoundController { SoundController { nr10: 0, nr11: 0, nr12: 0, nr13: 0, nr14: 0, nr21: 0, nr22: 0, nr23: 0, nr24: 0, nr30: 0, nr31: 0, nr32: 0, nr33...
new
identifier_name
sound.rs
//! Manages the gameboy sound controller //! This is mostly incomplete, at the moment all this does is manage the sound registers.
/// Channel 1 Volume Envelope (R/W) pub nr12: u8, /// Channel 1 Frequency lo pub nr13: u8, /// Channel 1 Frequency hi pub nr14: u8, /// Channel 2 Sound length/Wave pattern duty pub nr21: u8, /// Channel 2 Volume Envelope (R/W) pub nr22: u8, /// Channel 2 Frequency lo pub...
pub struct SoundController { /// Channel 1 Sweep register pub nr10: u8, /// Channel 1 Sound length/Wave pattern duty pub nr11: u8,
random_line_split
fold.rs
#![crate_name = "fold"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::fs::File; use...
else if matches.opt_present("V") { println!("{} {}", NAME, VERSION); } else { let bytes = matches.opt_present("b"); let spaces = matches.opt_present("s"); let poss_width = if matches.opt_present("w") { matches.opt_str("w") } else { ...
{ println!("{} {}", NAME, VERSION); println!(""); println!("Usage:"); println!(" {} [OPTION]... [FILE]...", NAME); println!(""); print!("{}", opts.usage("Writes each file (or standard input if no files are given) to standard output whilst breaking long lines")); }
conditional_block
fold.rs
#![crate_name = "fold"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::fs::File; use...
}; output.push(ch); } if count > 0 { if newline { println!("{}", output); } else { print!("{}", output); } } } } } #[inline] fn rfind_whitespace(slice:...
_ => count += 1
random_line_split
fold.rs
#![crate_name = "fold"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::fs::File; use...
i += slice.len(); } } else { let mut len = line.chars().count(); let newline = line.ends_with("\n"); if newline { if len == 1 { println!(""); continue; } len -=...
{ let mut line = String::new(); while safe_unwrap!(file.read_line(&mut line)) > 0 { if bytes { let len = line.len(); let mut i = 0; while i < len { let width = if len - i >= width { width } else { len - i }; let slice = { ...
identifier_body
fold.rs
#![crate_name = "fold"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; use std::fs::File; use...
(args: &[String]) -> (Vec<String>, Option<String>) { for (i, arg) in args.iter().enumerate() { let slice = &arg; if slice.chars().next().unwrap() == '-' && slice.len() > 1 && slice.chars().nth(1).unwrap().is_digit(10) { let mut v = args.to_vec(); v.remove(i); retu...
handle_obsolete
identifier_name
joiner.rs
use std::os; use std::io::File; fn
() { let args: ~[~str] = os::args(); if args.len()!= 3 { println!("Usage: {:s} <inputfile1> <inputfile2>", args[0]); } else { let current_dir = std::os::getcwd(); let share1fname = args[1].clone(); let share2fname = args[2].clone(); let path1 = Path::new(share1f...
main
identifier_name
joiner.rs
use std::os; use std::io::File; fn main() { let args: ~[~str] = os::args(); if args.len()!= 3 { println!("Usage: {:s} <inputfile1> <inputfile2>", args[0]); } else { let current_dir = std::os::getcwd(); let share1fname = args[1].clone(); let share2fname = args[2].clone(); ...
fn join(share1_bytes: &[u8], share2_bytes: &[u8], mut message: File) { let message_bytes = xor(share1_bytes, share2_bytes); message.write(message_bytes); }
{ let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret }
identifier_body
joiner.rs
use std::os; use std::io::File; fn main() { let args: ~[~str] = os::args(); if args.len()!= 3 { println!("Usage: {:s} <inputfile1> <inputfile2>", args[0]); } else { let current_dir = std::os::getcwd(); let share1fname = args[1].clone(); let share2fname = args[2].clone(); ...
ret } fn join(share1_bytes: &[u8], share2_bytes: &[u8], mut message: File) { let message_bytes = xor(share1_bytes, share2_bytes); message.write(message_bytes); }
let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); }
random_line_split
truetype.rs
use std::libc::*; use std::intrinsics; use std::vec; struct StbttFontinfo { userdata: *c_void, data: *c_uchar, fontstart: c_int, numGlyphs: c_int, loca: c_int, head: c_int, glyf: c_int, hhea: c_int, hmtx: c_int, kern: c_int, index_map: c_int, indexToLocFormat: c_int } #...
(&self, codepoint: uint, height: f32) -> Option<Glyph> { unsafe { let g = stbtt_FindGlyphIndex(&self.info, codepoint as c_int); if g == 0 { return None } let scale = stbtt_ScaleForPixelHeight( &self.info, height as c_float); ...
glyph
identifier_name
truetype.rs
use std::libc::*; use std::intrinsics; use std::vec; struct StbttFontinfo { userdata: *c_void, data: *c_uchar, fontstart: c_int, numGlyphs: c_int, loca: c_int, head: c_int, glyf: c_int, hhea: c_int, hmtx: c_int, kern: c_int, index_map: c_int, indexToLocFormat: c_int } #...
return Some(ret); } } pub fn glyph(&self, codepoint: uint, height: f32) -> Option<Glyph> { unsafe { let g = stbtt_FindGlyphIndex(&self.info, codepoint as c_int); if g == 0 { return None } let scale = stbtt_ScaleForPix...
{ return None }
conditional_block
truetype.rs
use std::libc::*; use std::intrinsics; use std::vec; struct StbttFontinfo { userdata: *c_void, data: *c_uchar, fontstart: c_int, numGlyphs: c_int, loca: c_int, head: c_int, glyf: c_int, hhea: c_int, hmtx: c_int, kern: c_int, index_map: c_int, indexToLocFormat: c_int } #...
} return Some(ret); } } pub fn glyph(&self, codepoint: uint, height: f32) -> Option<Glyph> { unsafe { let g = stbtt_FindGlyphIndex(&self.info, codepoint as c_int); if g == 0 { return None } let scale = stbt...
}; let status = stbtt_InitFont( &ret.info, ret.data.as_ptr(), 0 as c_int); if status == 0 { return None
random_line_split
x86_64_unknown_freebsd.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 ...
base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); Target { llvm_target: "x86_64-unknown-freebsd".to_string(), target_endian: "little".to_string(), target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "freebsd".to_...
let mut base = super::freebsd_base::opts();
random_line_split
x86_64_unknown_freebsd.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 base = super::freebsd_base::opts(); base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); Target { llvm_target: "x86_64-unknown-freebsd".to_string(), target_endian: "little".to_string(), target_pointer_width: "64".to_string(), arch: "x86...
identifier_body
x86_64_unknown_freebsd.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 ...
() -> Target { let mut base = super::freebsd_base::opts(); base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); Target { llvm_target: "x86_64-unknown-freebsd".to_string(), target_endian: "little".to_string(), target_pointer_width: "64".to_string(), ...
target
identifier_name
safe_contract.rs
// Copyright 2015-2017 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 lat...
} mod provider { // Autogenerated from JSON contract definition using Rust contract convertor. #![allow(unused_imports)] use std::string::String; use std::result::Result; use std::fmt; use {util, ethabi}; use util::{FixedHash, Uint}; pub struct Contract { contract: ethabi::Contract, address: util::Addres...
{ if let Some(c) = client.upgrade() { c.add_notify(self.clone()); } { *self.provider.write() = Some(provider::Contract::new(self.address, move |a, d| client.upgrade().ok_or("No client!".into()).and_then(|c| c.call_contract(a, d)))); } self.update(); }
identifier_body
safe_contract.rs
// Copyright 2015-2017 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 lat...
{ *self.provider.write() = Some(provider::Contract::new(self.address, move |a, d| client.upgrade().ok_or("No client!".into()).and_then(|c| c.call_contract(a, d)))); } self.update(); } } mod provider { // Autogenerated from JSON contract definition using Rust contract convertor. #![allow(unused_imports)] ...
{ c.add_notify(self.clone()); }
conditional_block
safe_contract.rs
// Copyright 2015-2017 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 lat...
() { let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_safe_contract, None); let vc = Arc::new(ValidatorSafeContract::new(Address::from_str("0000000000000000000000000000000000000005").unwrap())); vc.register_contract(Arc::downgrade(&client)); assert!(vc.contains(&Address::from_str("7...
fetches_validators
identifier_name
safe_contract.rs
// Copyright 2015-2017 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 lat...
_: Vec<H256>, _: Vec<H256>, _: Vec<Bytes>, _duration: u64) { if!enacted.is_empty() { self.update(); } } } impl ValidatorSet for Arc<ValidatorSafeContract> { fn contains(&self, address: &Address) -> bool { self.validators.read().contains(address) } fn get(&self, nonce: usize) -> Address { self.v...
_: Vec<H256>, _: Vec<H256>, enacted: Vec<H256>,
random_line_split
npm.rs
use super::super::context::{BuildContext}; use super::generic::{run_command, capture_command}; use super::super::packages; use std::path::Path; pub fn scan_features(pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec!(); res.push(packages::BuildEssential); res.push(packages::NodeJs); re...
pub fn list(ctx: &mut BuildContext) -> Result<(), String> { use std::fs::File; // TODO(tailhook) migrate whole module use std::io::Write; // TODO(tailhook) migrate whole module try!(capture_command(ctx, &[ "/usr/bin/npm".to_string(), "ls".to_string(), "--global".to_st...
{ try!(ctx.add_cache_dir(Path::new("/tmp/npm-cache"), "npm-cache".to_string())); try!(ensure_npm(ctx, &scan_features(pkgs)[..])); let mut args = vec!( "/usr/bin/npm".to_string(), "install".to_string(), "--user=root".to_string(), "--cache=/tmp/npm-ca...
identifier_body
npm.rs
use super::super::context::{BuildContext}; use super::generic::{run_command, capture_command}; use super::super::packages; use std::path::Path; pub fn scan_features(pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec!(); res.push(packages::BuildEssential); res.push(packages::NodeJs); re...
"--global".to_string(), ], &[]) .and_then(|out| { File::create("/vagga/container/npm-list.txt") .and_then(|mut f| f.write_all(&out)) .map_err(|e| format!("Error dumping package list: {}", e)) })); Ok(()) }
"/usr/bin/npm".to_string(), "ls".to_string(),
random_line_split
npm.rs
use super::super::context::{BuildContext}; use super::generic::{run_command, capture_command}; use super::super::packages; use std::path::Path; pub fn scan_features(pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec!(); res.push(packages::BuildEssential); res.push(packages::NodeJs); re...
// Does npm support mercurial? } return res; } pub fn ensure_npm(ctx: &mut BuildContext, features: &[packages::Package]) -> Result<(), String> { packages::ensure_packages(ctx, features) } pub fn npm_install(ctx: &mut BuildContext, pkgs: &Vec<String>) -> Result<(), String> { try!(ctx.add_cache...
{ res.push(packages::Git); }
conditional_block
npm.rs
use super::super::context::{BuildContext}; use super::generic::{run_command, capture_command}; use super::super::packages; use std::path::Path; pub fn scan_features(pkgs: &Vec<String>) -> Vec<packages::Package> { let mut res = vec!(); res.push(packages::BuildEssential); res.push(packages::NodeJs); re...
(ctx: &mut BuildContext, pkgs: &Vec<String>) -> Result<(), String> { try!(ctx.add_cache_dir(Path::new("/tmp/npm-cache"), "npm-cache".to_string())); try!(ensure_npm(ctx, &scan_features(pkgs)[..])); let mut args = vec!( "/usr/bin/npm".to_string(), "install".to_st...
npm_install
identifier_name
oper.rs
use std::fmt; use protocol::command::CMD_OPER; use protocol::message::{IrcMessage, RawMessage, ParseMessageError, ParseMessageErrorKind}; #[derive(Debug, Clone, Eq, PartialEq)] pub struct OperCommand<'a> { name: &'a str, password: &'a str, } impl<'a> OperCommand<'a> { pub fn new(name: &'a str, password: ...
(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {} {}", CMD_OPER, self.name, self.password) } } impl<'a> IrcMessage<'a> for OperCommand<'a> { fn from_raw(raw: &RawMessage<'a>) -> Result<OperCommand<'a>, ParseMessageError> { let mut param = raw.parameters(); let (name, pw...
fmt
identifier_name
oper.rs
use std::fmt; use protocol::command::CMD_OPER; use protocol::message::{IrcMessage, RawMessage, ParseMessageError, ParseMessageErrorKind}; #[derive(Debug, Clone, Eq, PartialEq)] pub struct OperCommand<'a> { name: &'a str, password: &'a str, } impl<'a> OperCommand<'a> { pub fn new(name: &'a str, password: ...
self.name } pub fn password(&self) -> &'a str { self.password } } impl<'a> fmt::Display for OperCommand<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {} {}", CMD_OPER, self.name, self.password) } } impl<'a> IrcMessage<'a> for OperCommand<'a> { ...
pub fn name(&self) -> &'a str {
random_line_split
oper.rs
use std::fmt; use protocol::command::CMD_OPER; use protocol::message::{IrcMessage, RawMessage, ParseMessageError, ParseMessageErrorKind}; #[derive(Debug, Clone, Eq, PartialEq)] pub struct OperCommand<'a> { name: &'a str, password: &'a str, } impl<'a> OperCommand<'a> { pub fn new(name: &'a str, password: ...
}
{ let mut param = raw.parameters(); let (name, pwd) = match (param.next(), param.next()) { (Some(name), Some(pwd)) => (name, pwd), _ => return Err(ParseMessageError::new(ParseMessageErrorKind::NeedMoreParams, "OPER command requi...
identifier_body
main.rs
extern crate fps_counter; extern crate piston; extern crate tcod; extern crate tcod_window; use std::cell::RefCell; use std::rc::Rc; use fps_counter::FPSCounter; use piston::event_loop::{EventLoop, Events}; use piston::input::Event::{Render, Update}; use piston::window::{Size, WindowSettings}; use tcod::Console; use ...
() { let settings = WindowSettings::new(WINDOW_TITLE, Size { width: WINDOW_SIZE_WIDTH, height: WINDOW_SIZE_HEIGHT, }) .exit_on_esc...
main
identifier_name
main.rs
extern crate fps_counter; extern crate piston; extern crate tcod; extern crate tcod_window; use std::cell::RefCell; use std::rc::Rc; use fps_counter::FPSCounter; use piston::event_loop::{EventLoop, Events}; use piston::input::Event::{Render, Update}; use piston::window::{Size, WindowSettings}; use tcod::Console; use ...
} } }
random_line_split
main.rs
extern crate fps_counter; extern crate piston; extern crate tcod; extern crate tcod_window; use std::cell::RefCell; use std::rc::Rc; use fps_counter::FPSCounter; use piston::event_loop::{EventLoop, Events}; use piston::input::Event::{Render, Update}; use piston::window::{Size, WindowSettings}; use tcod::Console; use ...
let mut fps = fps_counter.tick(); while let Some(e) = events.next(&mut window) { match e { Render(_) => { fps = fps_counter.tick(); }, Update(_) => { let fps_string = format!("FPS: {:?}", fps); window.window.borrow_mut(...
{ let settings = WindowSettings::new(WINDOW_TITLE, Size { width: WINDOW_SIZE_WIDTH, height: WINDOW_SIZE_HEIGHT, }) .exit_on_esc(t...
identifier_body
oneshot.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 ...
//////////////////////////////////////////////////////////////////////////// // select implementation //////////////////////////////////////////////////////////////////////////// // If Ok, the value is whether this port has data, if Err, then the upgraded // port needs to be checked instead of th...
{ match self.state.swap(DISCONNECTED, atomics::SeqCst) { // An empty channel has nothing to do, and a remotely disconnected // channel also has nothing to do b/c we're about to run the drop // glue DISCONNECTED | EMPTY => {} // There's data on the cha...
identifier_body
oneshot.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 ...
None => { match mem::replace(&mut self.upgrade, SendUsed) { SendUsed | NothingSent => Err(Disconnected), GoUp(upgrade) => Err(Upgraded(upgrade)) } } } ...
DISCONNECTED => { match self.data.take() { Some(data) => Ok(data),
random_line_split
oneshot.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, up: Receiver<T>) -> UpgradeResult { let prev = match self.upgrade { NothingSent => NothingSent, SendUsed => SendUsed, _ => fail!("upgrading again"), }; self.upgrade = GoUp(up); match self.state.swap(DISCONNECTED, atomics::SeqCst) { ...
upgrade
identifier_name
clock.rs
#![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Source of time abstraction. //! //! By default, `std::time::Instant::now()` is used. However, when the //! `test-util` feature flag is enabled, the values returned for `now()` are //! configurable.
cfg_not_test_util! { use crate::time::{Instant}; #[derive(Debug, Clone)] pub(crate) struct Clock {} pub(crate) fn now() -> Instant { Instant::from_std(std::time::Instant::now()) } impl Clock { pub(crate) fn new(_enable_pausing: bool, _start_paused: bool) -> Clock { ...
random_line_split
htmlframesetelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding; use dom::bindings::codegen::Bindings::HTMLFrameS...
(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> DomRoot<HTMLFrameSetElement> { Node::reflect_node(Box::new(HTMLFrameSetElement::new_inherited(local_name, prefix, document)), document, HTMLFrameSetElementB...
new
identifier_name
htmlframesetelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding; use dom::bindings::codegen::Bindings::HTMLFrameS...
}
random_line_split
lib.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. #![feature(min_specialization)] #[allow(unused_extern_crates)] extern crate tikv_alloc; #[macro_use] extern crate lazy_static;
$($name:ident => ($suffix:literal, $description:literal, $workaround:literal)),+ ) => { use crate::ErrorCode; $(pub const $name: ErrorCode = ErrorCode { code: concat!($prefix, $suffix), description: $description, workaround: $workaround, };)+ ...
macro_rules! define_error_codes { ($prefix:literal,
random_line_split
lib.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. #![feature(min_specialization)] #[allow(unused_extern_crates)] extern crate tikv_alloc; #[macro_use] extern crate lazy_static; macro_rules! define_error_codes { ($prefix:literal, $($name:ident => ($suffix:literal, $description:literal, $wo...
description: "", workaround: "", } ); } }
{ define_error_codes!( "KV:Raftstore:", ENTRY_TOO_LARGE => ("EntryTooLarge", "", ""), NOT_LEADER => ("NotLeader", "", "") ); assert_eq!( ENTRY_TOO_LARGE, ErrorCode { code: "KV:Raftstore:EntryTooLarge", ...
identifier_body
lib.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. #![feature(min_specialization)] #[allow(unused_extern_crates)] extern crate tikv_alloc; #[macro_use] extern crate lazy_static; macro_rules! define_error_codes { ($prefix:literal, $($name:ident => ($suffix:literal, $description:literal, $wo...
(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{}", self.code) } } pub trait ErrorCodeExt { fn error_code(&self) -> ErrorCode; } #[cfg(test)] mod tests { #[test] fn test_define_error_code() { define_error_codes!( "KV:Raftstore:", ENTRY_TOO_LARGE => ...
fmt
identifier_name
schema.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...
(access: T) -> Self { Self::from_root(access).unwrap() } }
new
identifier_name
schema.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...
crypto::PublicKey, merkledb::{ access::{Access, FromAccess}, MapIndex, }, }; use exonum_derive::{BinaryValue, FromAccess, ObjectHash}; use serde_derive::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq)] #[derive(Serialize, Deserialize)] #[derive(BinaryValue, ObjectHash)] #[binary...
random_line_split