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
test_fmt.rs
#![allow(clippy::from_iter_instead_of_collect)] use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use std::iter::{self, FromIterator}; #[test]
fn test_fmt_group() { let ident = Ident::new("x", Span::call_site()); let inner = TokenStream::from_iter(iter::once(TokenTree::Ident(ident))); let parens_empty = Group::new(Delimiter::Parenthesis, TokenStream::new()); let parens_nonempty = Group::new(Delimiter::Parenthesis, inner.clone()); let brack...
random_line_split
test_fmt.rs
#![allow(clippy::from_iter_instead_of_collect)] use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use std::iter::{self, FromIterator}; #[test] fn
() { let ident = Ident::new("x", Span::call_site()); let inner = TokenStream::from_iter(iter::once(TokenTree::Ident(ident))); let parens_empty = Group::new(Delimiter::Parenthesis, TokenStream::new()); let parens_nonempty = Group::new(Delimiter::Parenthesis, inner.clone()); let brackets_empty = Group...
test_fmt_group
identifier_name
test_fmt.rs
#![allow(clippy::from_iter_instead_of_collect)] use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use std::iter::{self, FromIterator}; #[test] fn test_fmt_group()
assert_eq!("x", none_nonempty.to_string()); }
{ let ident = Ident::new("x", Span::call_site()); let inner = TokenStream::from_iter(iter::once(TokenTree::Ident(ident))); let parens_empty = Group::new(Delimiter::Parenthesis, TokenStream::new()); let parens_nonempty = Group::new(Delimiter::Parenthesis, inner.clone()); let brackets_empty = Group::n...
identifier_body
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
} _ => { // TODO(pcwalton): Take floatedness into account. self & (REPAINT | REPOSITION | REFLOW) } } } /// Servo doesn't implement this optimization. pub fn handled_for_descendants(self) -> Self { Self::empty() } } i...
{ self }
conditional_block
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
} impl ServoRestyleDamage { /// Compute the `StyleDifference` (including the appropriate restyle damage) /// for a given style change between `old` and `new`. pub fn compute_style_difference(_source: &ComputedValues, old: &ComputedValues, ...
{ 0 }
identifier_body
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
() -> Self { Self::empty() } } impl fmt::Display for ServoRestyleDamage { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { let mut first_elem = true; let to_iter = [ (REPAINT, "Repaint") , (REPOSITION, "Reposition") , (STORE_OVERFLOW, ...
default
identifier_name
restyle_damage.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/. */ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incre...
// NB: We need the braces inside the RHS due to Rust #8012. This particular // version of this macro might be safe anyway, but we want to avoid silent // breakage on modifications. macro_rules! add_if_not_equal( ($old:ident, $new:ident, $damage:ident, [ $($effect:ident),* ], [ $($style_struct_getter:ident.$n...
} Ok(()) } }
random_line_split
parser.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// except according to those terms. //! Higher-level Rust constructs for http_parser use std::vec::raw::from_buf_raw; use std::libc::{c_int, c_void, c_char, size_t}; use std::ptr::{null, to_unsafe_ptr}; use std::str; use http_parser; use http_parser::{http_parser_settings, HTTP_REQUEST}; use http_parser::{http_parser...
// 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
random_line_split
parser.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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 ...
let settings = http_parser::struct_http_parser_settings { on_message_begin: on_message_begin as *u8, on_url: on_url as *u8, on_status_complete: on_status_complete as *u8, on_header_field: on_header_field as *u8, on_header_value: on_header_value as *u8, on_headers_com...
{ #[fixed_stack_segment]; let http_parser = http_parser::struct_http_parser { _type_flags: 0, state: 0, header_state: 0, index: 0, nread: 0, content_length: 0, http_major: 0, http_minor: 0, status_code: 0, method: 0, http_er...
identifier_body
parser.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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 ...
() -> Parser { #[fixed_stack_segment]; let http_parser = http_parser::struct_http_parser { _type_flags: 0, state: 0, header_state: 0, index: 0, nread: 0, content_length: 0, http_major: 0, http_minor: 0, status_code: 0, method: 0, ...
Parser
identifier_name
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 lat...
mod manage_network; mod net; mod parity; mod parity_accounts; mod parity_set; mod personal; mod rpc; mod signer; mod signing; mod traces; mod web3;
mod eth;
random_line_split
nodes.rs
use super::prelude::*; use stencila_schema::Node; /// Override of macro to implement `from_value` for all node types macro_rules! patchable_node_variants { ($( $variant:path )*) => { impl Patchable for Node { patchable_variants_is_equal!($( $variant )*); patchable_variants_hash!($( ...
}; } patchable_node_variants!( Node::Array Node::Article Node::AudioObject Node::Boolean Node::Cite Node::CiteGroup Node::Claim Node::CodeBlock Node::CodeChunk Node::CodeExpression Node::CodeFragment Node::Datatable Node::DatatableColumn Node::Delete Node...
random_line_split
settings.rs
use ProtocolEngineBuilder; use Protocol; pub trait OptionSetter<T> { fn set_option(self, T) -> T; } #[derive(Clone,Copy,Debug)] pub struct Bytes(pub usize); #[derive(Clone,Copy,Debug)] pub struct Kilobytes(pub usize); #[derive(Clone,Copy,Debug)] pub struct Megabytes(pub usize); pub trait ToBytes { fn to_bytes(&s...
(pub usize); pub struct MaxBufferPoolSize(pub usize); impl <P, T> OptionSetter<ProtocolEngineBuilder<P>> for InitialBufferSize<T> where P: Protocol, T: ToBytes { fn set_option(self, mut builder: ProtocolEngineBuilder<P>) -> ProtocolEngineBuilder<P> { let InitialBufferSize(size) = self; let number_of_bytes: B...
InitialBufferPoolSize
identifier_name
settings.rs
use ProtocolEngineBuilder; use Protocol; pub trait OptionSetter<T> { fn set_option(self, T) -> T; } #[derive(Clone,Copy,Debug)] pub struct Bytes(pub usize); #[derive(Clone,Copy,Debug)] pub struct Kilobytes(pub usize); #[derive(Clone,Copy,Debug)] pub struct Megabytes(pub usize); pub trait ToBytes { fn to_bytes(&s...
builder } }
random_line_split
lib.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...
#![feature(rustc_diagnostic_macros)] #![allow(unknown_features)] #![feature(int_uint)] #![allow(non_camel_case_types)] #![allow(unstable)] #[macro_use] extern crate log; #[macro_use] extern crate syntax; // for "clarity", rename the graphviz crate to dot; graphviz within `borrowck` // refers to the borrowck-specific ...
#![feature(slicing_syntax, unsafe_destructor)]
random_line_split
main.rs
extern crate coio; use std::io::{Read, Write}; use coio::net::TcpListener; use coio::{spawn, run}; fn
() { // Spawn a coroutine for accepting new connections let mut x: i64 = 11; spawn(move|| { let acceptor = TcpListener::bind("127.0.0.1:4000").unwrap(); println!("Waiting for connection..."); for stream in acceptor.incoming() { let mut stream = stream.unwrap(); ...
main
identifier_name
main.rs
extern crate coio; use std::io::{Read, Write}; use coio::net::TcpListener; use coio::{spawn, run}; fn main() { // Spawn a coroutine for accepting new connections let mut x: i64 = 11; spawn(move|| { let acceptor = TcpListener::bind("127.0.0.1:4000").unwrap(); println!("Waiting for connec...
// Schedule with 4 threads run(4); }
random_line_split
main.rs
extern crate coio; use std::io::{Read, Write}; use coio::net::TcpListener; use coio::{spawn, run}; fn main()
match stream.read(&mut buf) { Ok(0) => { //println!("EOF"); break; }, Ok(len) => { //println!("Read {} bytes, echo back", len); ...
{ // Spawn a coroutine for accepting new connections let mut x: i64 = 11; spawn(move|| { let acceptor = TcpListener::bind("127.0.0.1:4000").unwrap(); println!("Waiting for connection ..."); for stream in acceptor.incoming() { let mut stream = stream.unwrap(); ...
identifier_body
singleton.rs
#![macro_use] /** * Thanks for http://stackoverflow.com/questions/27791532/how-do-i-create-a-global-mutable-singleton */ use std::sync::{Arc, Mutex, MutexGuard, LockResult}; //#[derive(Copy)] pub struct SingletonHolder<T> { // Since we will be used in many threads, we need to protect // concurrent access inner:...
impl <T> Clone for SingletonHolder<T> { fn clone(&self) -> SingletonHolder<T> { SingletonHolder { inner: self.inner.clone(), } } } #[macro_export] macro_rules! declare_singleton { ( $name: ident, // Function name $t: ty, // Embedded type $init: expr // Initial value ) => ( fn $name() -> $crate::si...
self.inner.lock() } }
identifier_body
singleton.rs
#![macro_use] /** * Thanks for http://stackoverflow.com/questions/27791532/how-do-i-create-a-global-mutable-singleton */ use std::sync::{Arc, Mutex, MutexGuard, LockResult}; //#[derive(Copy)] pub struct SingletonHolder<T> { // Since we will be used in many threads, we need to protect // concurrent access inner:...
}; } }
conditional_block
singleton.rs
#![macro_use] /** * Thanks for http://stackoverflow.com/questions/27791532/how-do-i-create-a-global-mutable-singleton */ use std::sync::{Arc, Mutex, MutexGuard, LockResult}; //#[derive(Copy)] pub struct SingletonHolder<T> { // Since we will be used in many threads, we need to protect // concurrent access inner:...
utex: Arc<Mutex<T>>) -> SingletonHolder<T> { SingletonHolder { inner: mutex, } } pub fn lock(&self) -> LockResult<MutexGuard<T>> { self.inner.lock() } } impl <T> Clone for SingletonHolder<T> { fn clone(&self) -> SingletonHolder<T> { SingletonHolder { inner: self.inner.clone(), } } } #[macro_expo...
w(m
identifier_name
singleton.rs
#![macro_use] /**
use std::sync::{Arc, Mutex, MutexGuard, LockResult}; //#[derive(Copy)] pub struct SingletonHolder<T> { // Since we will be used in many threads, we need to protect // concurrent access inner: Arc<Mutex<T>>, } impl<T> SingletonHolder<T> { pub fn new(mutex: Arc<Mutex<T>>) -> SingletonHolder<T> { SingletonHolder {...
* Thanks for http://stackoverflow.com/questions/27791532/how-do-i-create-a-global-mutable-singleton */
random_line_split
maxpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn maxpd_1() { run_test(&Instruction { mnemonic: Mnemonic::MAXPD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM5...
fn maxpd_3() { run_test(&Instruction { mnemonic: Mnemonic::MAXPD, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XMM6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 95, 230], OperandSize::Qword) } fn maxpd_4() { ...
{ run_test(&Instruction { mnemonic: Mnemonic::MAXPD, operand1: Some(Direct(XMM2)), operand2: Some(IndirectScaledIndexedDisplaced(EDX, ESI, Two, 550510135, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }...
identifier_body
maxpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*;
fn maxpd_1() { run_test(&Instruction { mnemonic: Mnemonic::MAXPD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM5)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 95, 245], OperandSize::Dword) } fn maxpd_2() { ...
use ::RegScale::*;
random_line_split
maxpd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn
() { run_test(&Instruction { mnemonic: Mnemonic::MAXPD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM5)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 95, 245], OperandSize::Dword) } fn maxpd_2() { run_test(&...
maxpd_1
identifier_name
tokenstream.rs
: Send + Sync, { } impl TokenTree { /// Checks if this `TokenTree` is equal to the other, regardless of span information. pub fn eq_unspanned(&self, other: &TokenTree) -> bool { match (self, other) { (TokenTree::Token(token), TokenTree::Token(token2)) => token.kind == token2.kind, ...
pub fn from_streams(mut streams: SmallVec<[TokenStream; 2]>) -> TokenStream { match streams.len() { 0 => TokenStream::default(), 1 => streams.pop().unwrap(), _ => { // We are going to extend the first stream in `streams` with // the eleme...
{ self.0.len() }
identifier_body
tokenstream.rs
TokenStream { fn create_token_stream(&self) -> AttrAnnotatedTokenStream { self.clone() } } /// A lazy version of [`TokenStream`], which defers creation /// of an actual `TokenStream` until it is needed. /// `Box` is here only to reduce the structure size. #[derive(Clone)] pub struct LazyTokenStream(Lrc...
self.next_with_spacing().map(|(tree, _)| tree) }
random_line_split
tokenstream.rs
: Send + Sync, { } impl TokenTree { /// Checks if this `TokenTree` is equal to the other, regardless of span information. pub fn eq_unspanned(&self, other: &TokenTree) -> bool { match (self, other) { (TokenTree::Token(token), TokenTree::Token(token2)) => token.kind == token2.kind, ...
(kind: TokenKind, span: Span) -> TokenTree { TokenTree::Token(Token::new(kind, span)) } /// Returns the opening delimiter as a token tree. pub fn open_tt(span: DelimSpan, delim: DelimToken) -> TokenTree { TokenTree::token(token::OpenDelim(delim), span.open) } /// Returns the closin...
token
identifier_name
kind.rs
b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, fk, fd, b, s, n); } fn visit_ty(&mut self, t: &Ty, _: ()) { check_ty(self, t); } fn visit_item(&mut self, i: &Item, _: ()) { check_item(self, i); } } pub fn check_crate(tcx: &ty::ctxt, me...
/// This is rather subtle. When we are casting a value to an instantiated /// trait like `a as trait<'r>`, regionck already ensures that any references /// that appear in the type of `a` are bounded by `'r` (ed.: rem /// FIXME(#5723)). However, it is possible that there are *type parameters* /// in the type of `a`,...
{ if !ty::type_is_static(tcx, ty) { match ty::get(ty).sty { ty::ty_param(..) => { tcx.sess.span_err(sp, format!("value may contain references; \ add `'static` bound to `{}`", ty_to_str(tcx, ty))); } _ => { tcx.ses...
identifier_body
kind.rs
b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, fk, fd, b, s, n); } fn visit_ty(&mut self, t: &Ty, _: ()) { check_ty(self, t); } fn visit_item(&mut self, i: &Item, _: ()) { check_item(self, i); } } pub fn check_crate(tcx: &ty::ctxt, me...
(cx: &Context, sp: Span, ty: ty::t, type_param_def: &ty::TypeParameterDef) { check_builtin_bounds(cx, ty, type_param_def.bounds.builtin_bounds, |missing| { ...
check_typaram_bounds
identifier_name
kind.rs
b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, fk, fd, b, s, n); } fn visit_ty(&mut self, t: &Ty, _: ()) { check_ty(self, t); } fn visit_item(&mut self, i: &Item, _: ()) { check_item(self, i); } } pub fn check_crate(tcx: &ty::ctxt, me...
} } }; if ts.len()!= type_param_defs.len() { // Fail earlier to make debugging easier fail!("internal error: in kind::check_expr, length \ mismatch between actual and declared bounds: actual = \ ...
{ cx.tcx.sess.span_bug(e.span, "non path/method call expr has type substs??"); }
conditional_block
kind.rs
b: &Block, s: Span, n: NodeId, _: ()) { check_fn(self, fk, fd, b, s, n); } fn visit_ty(&mut self, t: &Ty, _: ()) { check_ty(self, t); } fn visit_item(&mut self, i: &Item, _: ()) { check_item(self, i); } } pub fn check_crate(tcx: &ty::ctxt, m...
} // Calls "any_missing" if any bounds were missing. pub fn check_builtin_bounds(cx: &Context, ty: ty::t, bounds: ty::BuiltinBounds, any_missing: |ty::BuiltinBounds|) { let kind = ty::type_contents(cx.tcx, ty); let mut missing ...
} } _ => {} } visit::walk_ty(cx, aty, ());
random_line_split
datum.rs
.fcx.schedule_drop_mem(scope, scratch, ty); DatumBlock(bcx, Datum(scratch, ty, Lvalue)) } pub fn rvalue_scratch_datum(bcx: &Block, ty: ty::t, name: &str) -> Datum<Rvalue> { /*! * Allocates temporary space on the stack usi...
}
random_line_split
datum.rs
Datum<K> { Datum { val: val, ty: ty, kind: kind } } pub fn DatumBlock<'a, K>(bcx: &'a Block<'a>, datum: Datum<K>) -> DatumBlock<'a, K> { DatumBlock { bcx: bcx, datum: datum } } pub fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum<Rvalue> { return Da...
(self) -> ValueRef { /*! * Converts a datum into a by-ref value. The datum type must * be one which is always passed by reference. */ self.val } pub fn get_element(&self, ty: ty::t, gep: |ValueRef| -> ValueRef) ...
to_llref
identifier_name
datum.rs
Datum<K> { Datum { val: val, ty: ty, kind: kind } } pub fn DatumBlock<'a, K>(bcx: &'a Block<'a>, datum: Datum<K>) -> DatumBlock<'a, K> { DatumBlock { bcx: bcx, datum: datum } } pub fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum<Rvalue> { return Da...
pub fn to_rvalue_datum<'a>(self, bcx: &'a Block<'a>, name: &'static str) -> DatumBlock<'a, Rvalue> { /*! * Ensures that we have an rvalue datum (that is, a datum with * no cleanup scheduled). ...
{ self.match_kind( |l| DatumBlock(bcx, l), |r| { let scope = cleanup::temporary_scope(bcx.tcx(), expr_id); r.to_lvalue_datum_in_scope(bcx, name, scope) }) }
identifier_body
utils.rs
pub fn char_width(c: char, is_cjk: bool, tab_width: usize, position: usize) -> Option<usize> { use unicode_width::UnicodeWidthChar; if c == '\t' { Some(tab_width - position%tab_width) } else if c == '\n' { Some(1) } else if is_cjk { UnicodeWidthChar::width_cjk(c) } else { ...
#[cfg(test)] mod tests { use super::*; #[test] fn test_is_alpha_or_() { assert!(is_alpha_or_('a')); assert!(is_alpha_or_('5')); assert!(is_alpha_or_('_')); } }
{ c.is_alphanumeric() || c == '_' }
identifier_body
utils.rs
pub fn char_width(c: char, is_cjk: bool, tab_width: usize, position: usize) -> Option<usize> { use unicode_width::UnicodeWidthChar; if c == '\t' { Some(tab_width - position%tab_width) } else if c == '\n' { Some(1)
UnicodeWidthChar::width(c) } } pub fn str_width(s: &str, is_cjk: bool, tab_width: usize) -> usize { s.chars().fold(0, |acc, c| acc + char_width(c, is_cjk, tab_width, acc).unwrap_or(0) ) } /// Determine if a given char is alphanumeric or an underscore pub fn is_alpha_or_(c: char) -> bool { ...
} else if is_cjk { UnicodeWidthChar::width_cjk(c) } else {
random_line_split
utils.rs
pub fn
(c: char, is_cjk: bool, tab_width: usize, position: usize) -> Option<usize> { use unicode_width::UnicodeWidthChar; if c == '\t' { Some(tab_width - position%tab_width) } else if c == '\n' { Some(1) } else if is_cjk { UnicodeWidthChar::width_cjk(c) } else { UnicodeWidt...
char_width
identifier_name
mir_codegen_switch.rs
// Copyright 2015 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 ...
(x: Abc) -> bool { match x { Abc::D => true, _ => false } } fn main() { assert_eq!(1, foo(Abc::A(42))); assert_eq!(2, foo(Abc::B(-100))); assert_eq!(3, foo(Abc::C)); assert_eq!(4, foo(Abc::D)); assert_eq!(false, foo2(Abc::A(1))); assert_eq!(false, foo2(Abc::B(2))); ...
foo2
identifier_name
mir_codegen_switch.rs
// Copyright 2015 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 main() { assert_eq!(1, foo(Abc::A(42))); assert_eq!(2, foo(Abc::B(-100))); assert_eq!(3, foo(Abc::C)); assert_eq!(4, foo(Abc::D)); assert_eq!(false, foo2(Abc::A(1))); assert_eq!(false, foo2(Abc::B(2))); assert_eq!(false, foo2(Abc::C)); assert_eq!(true, foo2(Abc::D)); }
{ match x { Abc::D => true, _ => false } }
identifier_body
mir_codegen_switch.rs
// Copyright 2015 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 ...
match x { Abc::D => true, _ => false } } fn main() { assert_eq!(1, foo(Abc::A(42))); assert_eq!(2, foo(Abc::B(-100))); assert_eq!(3, foo(Abc::C)); assert_eq!(4, foo(Abc::D)); assert_eq!(false, foo2(Abc::A(1))); assert_eq!(false, foo2(Abc::B(2))); assert_eq!(false, f...
Abc::A(_) => 1, } } fn foo2(x: Abc) -> bool {
random_line_split
reader.rs
use std::io::Read; use byteorder::{BigEndian, LittleEndian}; use crate::errors::PcapError; use crate::pcapng::blocks::{ParsedBlock, EnhancedPacketBlock, InterfaceDescriptionBlock}; use crate::Endianness; use crate::peek_reader::PeekReader; use crate::pcapng::{Block, SectionHeaderBlock, BlockType}; /// Wraps another re...
(&self, packet: &EnhancedPacketBlock) -> Option<&InterfaceDescriptionBlock> { self.interfaces.get(packet.interface_id as usize) } fn next_impl(&mut self) -> Result<Block<'static>, PcapError> { // Read next Block let endianess = self.section.endianness(); let block = match endia...
packet_interface
identifier_name
reader.rs
use std::io::Read; use byteorder::{BigEndian, LittleEndian}; use crate::errors::PcapError; use crate::pcapng::blocks::{ParsedBlock, EnhancedPacketBlock, InterfaceDescriptionBlock}; use crate::Endianness; use crate::peek_reader::PeekReader; use crate::pcapng::{Block, SectionHeaderBlock, BlockType}; /// Wraps another re...
/// Returns the current SectionHeaderBlock pub fn section(&self) -> &SectionHeaderBlock<'static> { &self.section } /// Returns the current interfaces pub fn interfaces(&self) -> &[InterfaceDescriptionBlock<'static>] { &self.interfaces[..] } /// Returns the InterfaceDescri...
{ let current_block = Block::from_reader::<_, BigEndian>(&mut reader)?; let section = current_block.parsed()?; let section = match section { ParsedBlock::SectionHeader(section) => section.into_owned(), _ => return Err(PcapError::InvalidField("SectionHeader missing")) ...
identifier_body
reader.rs
use std::io::Read; use byteorder::{BigEndian, LittleEndian}; use crate::errors::PcapError; use crate::pcapng::blocks::{ParsedBlock, EnhancedPacketBlock, InterfaceDescriptionBlock}; use crate::Endianness; use crate::peek_reader::PeekReader; use crate::pcapng::{Block, SectionHeaderBlock, BlockType}; /// Wraps another re...
} }
random_line_split
insert_statement_does_not_support_returning_methods_on_sqlite.rs
#[macro_use] extern crate diesel; use diesel::*; use diesel::sqlite::{Sqlite, SqliteQueryBuilder, SqliteConnection}; use diesel::backend::Backend; use diesel::types::{Integer, VarChar}; table! { users { id -> Integer, name -> VarChar, } } pub struct User { id: i32, name: String, } us...
(String); Insertable! { (users) pub struct NewUser(#[column_name(name)] String,); } fn main() { let connection = SqliteConnection::establish(":memory:").unwrap(); insert(&NewUser("Hello".into())) .into(users::table) .get_result::<User>(&connection); //~^ ERROR: SupportsReturningClau...
NewUser
identifier_name
insert_statement_does_not_support_returning_methods_on_sqlite.rs
#[macro_use] extern crate diesel; use diesel::*; use diesel::sqlite::{Sqlite, SqliteQueryBuilder, SqliteConnection};
table! { users { id -> Integer, name -> VarChar, } } pub struct User { id: i32, name: String, } use diesel::types::FromSqlRow; impl<DB: Backend> Queryable<(Integer, VarChar), DB> for User where (i32, String): FromSqlRow<(Integer, VarChar), DB>, { type Row = (i32, String); ...
use diesel::backend::Backend; use diesel::types::{Integer, VarChar};
random_line_split
asm.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...
debug!("Asm Constraints: {:?}", constraints.as_slice()); let num_outputs = outputs.len(); // Depending on how many outputs we have, the return type is different let output_type = if num_outputs == 0 { Type::void(bcx.ccx()) } else if num_outputs == 1 { *output_types.get(0) } e...
{ constraints.push_str(clobbers.as_slice()); }
conditional_block
asm.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 in_datum = unpack_datum!(bcx, expr::trans(bcx, &**input)); unpack_result!(bcx, { callee::trans_arg_datum(bcx, expr_ty(bcx, &**input), in_datum, cleanup::CustomScope(temp_scope), ...
constraints.push((*c).clone());
random_line_split
asm.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...
() -> String { "".to_string() } #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] fn get_clobbers() -> String { "~{dirflag},~{fpsr},~{flags}".to_string() }
get_clobbers
identifier_name
asm.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...
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] fn get_clobbers() -> String { "~{dirflag},~{fpsr},~{flags}".to_string() }
{ "".to_string() }
identifier_body
ethernet.rs
use common::slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct EthernetIIHeader { pub dst: MacAddr, pub src: MacAddr, pub ethertype: n16, } pub struct EthernetII { pub header: EthernetIIHeader,...
None } } impl ToBytes for EthernetII { fn to_bytes(&self) -> Vec<u8> { unsafe { let header_ptr: *const EthernetIIHeader = &self.header; let mut ret = Vec::from(slice::from_raw_parts(header_ptr as *const u8, mem::...
{ unsafe { return Some(EthernetII { header: *(bytes.as_ptr() as *const EthernetIIHeader), data: bytes.get_slice(mem::size_of::<EthernetIIHeader>() ..).to_vec(), }); } }
conditional_block
ethernet.rs
use common::slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct EthernetIIHeader { pub dst: MacAddr, pub src: MacAddr, pub ethertype: n16, } pub struct EthernetII { pub header: EthernetIIHeader,...
} impl ToBytes for EthernetII { fn to_bytes(&self) -> Vec<u8> { unsafe { let header_ptr: *const EthernetIIHeader = &self.header; let mut ret = Vec::from(slice::from_raw_parts(header_ptr as *const u8, mem::size_of::<EthernetI...
{ if bytes.len() >= mem::size_of::<EthernetIIHeader>() { unsafe { return Some(EthernetII { header: *(bytes.as_ptr() as *const EthernetIIHeader), data: bytes.get_slice(mem::size_of::<EthernetIIHeader>() ..).to_vec(), }); ...
identifier_body
ethernet.rs
use common::slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct
{ pub dst: MacAddr, pub src: MacAddr, pub ethertype: n16, } pub struct EthernetII { pub header: EthernetIIHeader, pub data: Vec<u8>, } impl FromBytes for EthernetII { fn from_bytes(bytes: Vec<u8>) -> Option<Self> { if bytes.len() >= mem::size_of::<EthernetIIHeader>() { uns...
EthernetIIHeader
identifier_name
ethernet.rs
use common::slice::GetSlice; use collections::slice; use collections::vec::Vec; use core::mem; use network::common::*; #[derive(Copy, Clone)] #[repr(packed)] pub struct EthernetIIHeader { pub dst: MacAddr, pub src: MacAddr, pub ethertype: n16, } pub struct EthernetII { pub header: EthernetIIHeader,...
None } } impl ToBytes for EthernetII { fn to_bytes(&self) -> Vec<u8> { unsafe { let header_ptr: *const EthernetIIHeader = &self.header; let mut ret = Vec::from(slice::from_raw_parts(header_ptr as *const u8, mem::s...
} }
random_line_split
main.rs
//#![deny(warnings)] // please excuse my poor rust, this is my first time extern crate toml; extern crate rustc_serialize; use std::fs::File; use std::env; use std::io; use std::io::prelude::*; use toml::Value; use rustc_serialize::json::Json; extern crate hyper; extern crate env_logger; use hyper::Client; use hy...
// http test //env_logger::init().unwrap(); let url = "http://gsl.pow7.com/announce/".to_string(); let url = url + "?game_name=" + game_name; let url = url + "&game_version=" + game_version; //let table = Value::Table(parser.parse()); //let server_name = table.lookup("server.name"); ...
let json = convert(Value::Table(toml)); println!("{}", json.pretty());
random_line_split
main.rs
//#![deny(warnings)] // please excuse my poor rust, this is my first time extern crate toml; extern crate rustc_serialize; use std::fs::File; use std::env; use std::io; use std::io::prelude::*; use toml::Value; use rustc_serialize::json::Json; extern crate hyper; extern crate env_logger; use hyper::Client; use hy...
(toml: Value) -> Json { match toml { Value::String(s) => Json::String(s), Value::Integer(i) => Json::I64(i), Value::Float(f) => Json::F64(f), Value::Boolean(b) => Json::Boolean(b), Value::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()), Value::Table(...
convert
identifier_name
main.rs
//#![deny(warnings)] // please excuse my poor rust, this is my first time extern crate toml; extern crate rustc_serialize; use std::fs::File; use std::env; use std::io; use std::io::prelude::*; use toml::Value; use rustc_serialize::json::Json; extern crate hyper; extern crate env_logger; use hyper::Client; use hy...
{ match toml { Value::String(s) => Json::String(s), Value::Integer(i) => Json::I64(i), Value::Float(f) => Json::F64(f), Value::Boolean(b) => Json::Boolean(b), Value::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()), Value::Table(table) => Json::Object...
identifier_body
twitter_client.rs
use std::io::Read; use oauthcli::SignatureMethod::HmacSha1; use oauthcli::OAuthAuthorizationHeaderBuilder; use serde_json; use serde_json::Value; use reqwest::{Client, Url, StatusCode, Response}; use reqwest::header::{HeaderValue, AUTHORIZATION}; const API_URL: &'static str = "https://api.twitter.com/1.1/statuses/upd...
match id { Some(186) => Err(TwitterError::InvalidTweet), Some(187) => Err(TwitterError::Duplicated), _ => Err(TwitterError::Unknown(body)) } }, StatusCode::OK => { let mut body = String::new(); response.read_to_string(&mut body).map_err(|_| TwitterError::Network)?; let json: ...
{ let prev = in_reply_to.map(|i| i.to_string()); let mut args = vec![("status", message)]; if let Some(prev) = prev.as_ref() { args.push(("in_reply_to_status_id", prev)); } let mut response = self.post(API_URL, args).map_err(|_| TwitterError::Network)?; match response.status() { StatusCode::FORBID...
identifier_body
twitter_client.rs
use std::io::Read; use oauthcli::SignatureMethod::HmacSha1; use oauthcli::OAuthAuthorizationHeaderBuilder; use serde_json; use serde_json::Value; use reqwest::{Client, Url, StatusCode, Response}; use reqwest::header::{HeaderValue, AUTHORIZATION}; const API_URL: &'static str = "https://api.twitter.com/1.1/statuses/upd...
&self.consumer_secret, HmacSha1) .token(&self.access_key, &self.access_secret) .request_parameters(args.into_iter()) .finish_for_twitter() .to_string(); req.header(AUTHORIZATION, &oauth_header).send().map_err(|_| ()) } pub fn update_status(&self, message: &str, in_reply_to: Option<u64>) -> Res...
"POST", &Url::parse(url).expect("must be a valid url string"), &self.consumer_key,
random_line_split
twitter_client.rs
use std::io::Read; use oauthcli::SignatureMethod::HmacSha1; use oauthcli::OAuthAuthorizationHeaderBuilder; use serde_json; use serde_json::Value; use reqwest::{Client, Url, StatusCode, Response}; use reqwest::header::{HeaderValue, AUTHORIZATION}; const API_URL: &'static str = "https://api.twitter.com/1.1/statuses/upd...
(consumer_key: String, consumer_secret: String, access_key: String, access_secret: String) -> TwitterClient { TwitterClient { consumer_key: consumer_key, consumer_secret: consumer_secret, access_key: access_key, access_secret: access_secret, client: Client::new(), } } pub fn is_valid(&self) -> bo...
new
identifier_name
common.rs
//! Contains several types used throughout the library. use std::fmt; use std::error; use name::OwnedName as Name; /// Represents a thing which has a position inside some textual document. /// /// This trait is implemented by parsers, lexers and errors. It is used primarily to create /// error objects. pu...
/// Checks whether the given character is a name character (`NameChar`) /// as is defined by XML 1.1 specification, [section 2.3][1]. /// /// [1]: http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-common-syn pub fn is_name_char(c: char) -> bool { match c { _ if is_name_start_char(c) => true, ...
{ match c { ':' | 'A'...'Z' | '_' | 'a'...'z' | '\u{C0}'...'\u{D6}' | '\u{D8}'...'\u{F6}' | '\u{F8}'...'\u{2FF}' | '\u{370}'...'\u{37D}' | '\u{37F}'...'\u{1FFF}' | '\u{200C}'...'\u{200D}' | '\u{2070}'...'\u{218F}' | '\u{2C00}'...'\u{2FEF}' | '\u{3001}'...'\u{D7FF}' | ...
identifier_body
common.rs
//! Contains several types used throughout the library. use std::fmt; use std::error; use name::OwnedName as Name; /// Represents a thing which has a position inside some textual document. /// /// This trait is implemented by parsers, lexers and errors. It is used primarily to create /// error objects. pu...
<O: HasPosition>(o: &O, msg: String) -> Error { Error { row: o.row(), col: o.col(), msg: msg } } /// Creates a new error using provided position information and a message. #[inline] pub fn new_full(row: usize, col: usize, msg: String) -> Error { Error { row: row, col: col, msg: m...
new
identifier_name
common.rs
//! Contains several types used throughout the library. use std::fmt; use std::error; use name::OwnedName as Name; /// Represents a thing which has a position inside some textual document. /// /// This trait is implemented by parsers, lexers and errors. It is used primarily to create /// error objects. pu...
} } impl HasPosition for Error { #[inline] fn row(&self) -> usize { self.row } #[inline] fn col(&self) -> usize { self.col } } impl Error { /// Creates a new error using position information from the provided /// `HasPosition` object and a message. #[inline] pub fn ...
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}:{:?}: {:?}", self.row + 1, self.col + 1, self.msg)
random_line_split
lib.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 struct ForbidSwitch { msg: &'static str, io: uint, } impl ForbidSwitch { fn new(s: &'static str) -> ForbidSwitch { ForbidSwitch { msg: s, io: homing::local_id(), } } } impl Drop for ForbidSwitch { fn drop(&mut self) { ...
{ let mut slot = None; unsafe { uvll::uv_close(self.uv_handle() as *mut uvll::uv_handle_t, close_cb); uvll::set_data_for_uv_handle(self.uv_handle(), ptr::mut_null::<()>()); wait_until_woken_after(&mut slot, &self.uv_loop(), |...
identifier_body
lib.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) { let mut slot = None; unsafe { uvll::uv_close(self.uv_handle() as *mut uvll::uv_handle_t, close_cb); uvll::set_data_for_uv_handle(self.uv_handle(), ptr::mut_null::<()>()); wait_until_woken_after(&mut slot, &self....
close
identifier_name
lib.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 ...
loop_.modify_blockers(1); task.deschedule(1, |task| { *slot = Some(task); f(); Ok(()) }); loop_.modify_blockers(-1); } } fn wakeup(slot: &mut Option<BlockedTask>) { assert!(slot.is_some()); let _ = slot.take_unwrap().wake().map(|t| t.reawa...
assert!((*slot).is_none()); let task: Box<Task> = Local::take();
random_line_split
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
pub fn new_uninitialized(window: JSRef<Window>) -> Temporary<UIEvent> { reflect_dom_object(box UIEvent::new_inherited(EventTypeId::UIEvent), GlobalRef::Window(window), UIEventBinding::Wrap) } pub fn new(window: JSRef<Window>, ty...
{ UIEvent { event: Event::new_inherited(type_id), view: Default::default(), detail: Cell::new(0), } }
identifier_body
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
(self) -> i32 { self.detail.get() } fn InitUIEvent(self, type_: DOMString, can_bubble: bool, cancelable: bool, view: Option<JSRef<Window>>, detail: i32) { let event: JSRef<Event> = EventCast::from_ref...
Detail
identifier_name
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
; let event = UIEvent::new(global.as_window(), type_, bubbles, cancelable, init.view.r(), init.detail); Ok(event) } } impl<'a> UIEventMethods for JSRef<'a, UIEvent> { // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Ev...
{ EventCancelable::NotCancelable }
conditional_block
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
event.InitEvent(type_, can_bubble, cancelable); self.view.assign(view); self.detail.set(detail); } }
let event: JSRef<Event> = EventCast::from_ref(self); if event.dispatching() { return; }
random_line_split
crud.rs
#![cfg_attr(all(feature = "unstable", test), feature(test))] #[macro_use] extern crate serde_derive; #[macro_use] extern crate arthas_derive; extern crate rand; extern crate arthas; extern crate env_logger; #[path = "../tests/common/mod.rs"] pub mod common; #[path = "../tests/model/mod.rs"] pub mod model; #[cfg(all(...
(b: &mut test::Bencher) { setup(); b.iter(|| { Article::session() .field("title") .eq("Hello world!") .limit(100) .find() .unwrap() }) } }
bench_find
identifier_name
crud.rs
#![cfg_attr(all(feature = "unstable", test), feature(test))] #[macro_use] extern crate serde_derive; #[macro_use] extern crate arthas_derive; extern crate rand; extern crate arthas; extern crate env_logger; #[path = "../tests/common/mod.rs"] pub mod common; #[path = "../tests/model/mod.rs"] pub mod model; #[cfg(all(...
}
{ setup(); b.iter(|| { Article::session() .field("title") .eq("Hello world!") .limit(100) .find() .unwrap() }) }
identifier_body
crud.rs
#![cfg_attr(all(feature = "unstable", test), feature(test))] #[macro_use] extern crate serde_derive; #[macro_use] extern crate arthas_derive; extern crate rand; extern crate arthas; extern crate env_logger; #[path = "../tests/common/mod.rs"] pub mod common; #[path = "../tests/model/mod.rs"] pub mod model; #[cfg(all(...
#[bench] fn bench_a_insert(b: &mut test::Bencher) { setup(); b.iter(|| { Article::session() .insert(Article::new("Hello world!")) .unwrap() }) } #[bench] fn bench_find(b: &mut test::Bencher) { setup(); b.iter(|| { ...
use model::*; use super::common::setup;
random_line_split
expr-block-generic-box2.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-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::gc::{GC, Gc}; type compare<'a, T> = |T, T|: 'a -> bool; fn test_generic<T:Cl...
random_line_split
expr-block-generic-box2.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_vec(); }
main
identifier_name
expr-block-generic-box2.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::<Gc<int>>(box(GC) 1, compare_vec); } pub fn main() { test_vec(); }
{ return v1 == v2; }
identifier_body
tests.rs
extern crate word2vec; use word2vec::wordvectors::WordVector; const PATH: &'static str = "vectors.bin"; #[test] fn
() { let model = WordVector::load_from_binary(PATH).unwrap(); let res = model.cosine("winter", 10).expect("word not found in vocabulary"); assert_eq!(res.len(), 10); let only_words: Vec<&str> = res.iter().map(|x| x.0.as_ref()).collect(); assert!(!only_words.contains(&"winter")) } #[test] fn test_u...
test_word_cosine
identifier_name
tests.rs
extern crate word2vec; use word2vec::wordvectors::WordVector; const PATH: &'static str = "vectors.bin"; #[test] fn test_word_cosine() { let model = WordVector::load_from_binary(PATH).unwrap(); let res = model.cosine("winter", 10).expect("word not found in vocabulary"); assert_eq!(res.len(), 10); let...
#[test] fn test_word_count_is_correctly_returned() { let v = WordVector::load_from_binary(PATH).unwrap(); assert_eq!(v.word_count(), 71291); }
{ let model = WordVector::load_from_binary(PATH).unwrap(); let result = model.analogy(Vec::new(), Vec::new(), 10); match result { Some(_) => assert!(false), None => assert!(true), } }
identifier_body
tests.rs
extern crate word2vec; use word2vec::wordvectors::WordVector; const PATH: &'static str = "vectors.bin"; #[test] fn test_word_cosine() { let model = WordVector::load_from_binary(PATH).unwrap(); let res = model.cosine("winter", 10).expect("word not found in vocabulary"); assert_eq!(res.len(), 10); let...
let model = WordVector::load_from_binary(PATH).unwrap(); let mut pos = Vec::new(); pos.push("woman"); pos.push("king"); let mut neg = Vec::new(); neg.push("man"); let res = model.analogy(pos, neg, 10).expect("couldn't find all of the given words"); assert_eq!(res.len(), 10); let only...
#[test] fn test_word_analogy() {
random_line_split
unix.rs
use std::io::Result; use std::os::unix::io::RawFd; use std::path::PathBuf; pub fn before_exec() -> Result<()> { use libc; unsafe { libc::setsid(); libc::ioctl(0, libc::TIOCSCTTY, 1); } Ok(()) } pub fn fork() -> usize { use libc; unsafe { libc::fork() as usize } } pub fn set_wi...
if grantpt(master_fd) < 0 { panic!("grantpt: {:?}", Error::last_os_error()); } if unlockpt(master_fd) < 0 { panic!("unlockpt: {:?}", Error::last_os_error()); } } let tty_path = unsafe { PathBuf::from( CStr::from_ptr(ptsname(master_fd)...
{ panic!("ioctl: {:?}", Error::last_os_error()); }
conditional_block
unix.rs
use std::io::Result; use std::os::unix::io::RawFd; use std::path::PathBuf; pub fn before_exec() -> Result<()> { use libc; unsafe { libc::setsid(); libc::ioctl(0, libc::TIOCSCTTY, 1); } Ok(()) } pub fn fork() -> usize { use libc; unsafe { libc::fork() as usize } } pub fn
(fd: RawFd, row: u16, col: u16, xpixel: u16, ypixel: u16) { use libc; unsafe { let size = libc::winsize { ws_row: row, ws_col: col, ws_xpixel: xpixel, ws_ypixel: ypixel, }; libc::ioctl(fd, libc::TIOCSWINSZ, &size as *const libc::winsize); ...
set_winsize
identifier_name
unix.rs
use std::io::Result; use std::os::unix::io::RawFd; use std::path::PathBuf; pub fn before_exec() -> Result<()> { use libc; unsafe { libc::setsid(); libc::ioctl(0, libc::TIOCSCTTY, 1); } Ok(()) } pub fn fork() -> usize { use libc; unsafe { libc::fork() as usize } } pub fn set_wi...
if unlockpt(master_fd) < 0 { panic!("unlockpt: {:?}", Error::last_os_error()); } } let tty_path = unsafe { PathBuf::from( CStr::from_ptr(ptsname(master_fd)) .to_string_lossy() .into_owned(), ) }; (master_fd, tty_path)...
} if grantpt(master_fd) < 0 { panic!("grantpt: {:?}", Error::last_os_error()); }
random_line_split
unix.rs
use std::io::Result; use std::os::unix::io::RawFd; use std::path::PathBuf; pub fn before_exec() -> Result<()> { use libc; unsafe { libc::setsid(); libc::ioctl(0, libc::TIOCSCTTY, 1); } Ok(()) } pub fn fork() -> usize { use libc; unsafe { libc::fork() as usize } } pub fn set_wi...
pub fn getpty() -> (RawFd, PathBuf) { use libc; use std::ffi::CStr; use std::fs::OpenOptions; use std::io::Error; use std::os::unix::io::IntoRawFd; const TIOCPKT: libc::c_ulong = 0x5420; extern "C" { fn ptsname(fd: libc::c_int) -> *const libc::c_char; fn grantpt(fd: libc::...
{ use libc; unsafe { let size = libc::winsize { ws_row: row, ws_col: col, ws_xpixel: xpixel, ws_ypixel: ypixel, }; libc::ioctl(fd, libc::TIOCSWINSZ, &size as *const libc::winsize); } }
identifier_body
main.rs
fn test1() { let mut v = vec![100, 32, 57]; //vec! is a macro for i in &mut v { *i += 50; } println!("iterate v"); for i in &v { println!("{}", i); } let mut v1 = Vec::new(); // v1.push(5.01); //type infer according to first value inserted v1.push(1); v1.push(3)...
let str_hello_russia_slice1 = &str_hello_russia[0..4]; //string index? println!( "str_hello_russia={}, str_hello_russia_slice1={}", str_hello_russia, str_hello_russia_slice1 ); let str_hello = "hello"; let str_hello_idx1 = &str_hello[0..1]; //[0, 1), it is [0], string can only acces...
let str_hello_russia = "Здравствуйте"; // let str_hello_russia_idx1 = &str_hello_russia[0]; //compile error // println!("str_hello_russia_idx1={}", str_hello_russia_idx1);
random_line_split
main.rs
fn test1() { let mut v = vec![100, 32, 57]; //vec! is a macro for i in &mut v { *i += 50; } println!("iterate v"); for i in &v { println!("{}", i); } let mut v1 = Vec::new(); // v1.push(5.01); //type infer according to first value inserted v1.push(1); v1.push(3)...
println!("s6={}", s6); // println!("s3={}", s3); //s3 has been move before here, so s3 is invalid here; compile error // let str_hello_russia = "Здравствуйте"; // let str_hello_russia_idx1 = &str_hello_russia[0]; //compile error // println!("str_hello_russia_idx1={}", str_hello_russia_idx1); ...
{ let s1 = String::from("tic"); let s2 = String::from("tac"); let s1_2 = process_string1(&s1); println!("s1_2={}", s1_2); println!("s1={}", s1); let s2_2 = process_string2(s2); println!("s2_2={}", s2_2); // println!("s2={}", s2); //s2 has been moved, s2 is invalid here; value borrowed ...
identifier_body
main.rs
fn test1() { let mut v = vec![100, 32, 57]; //vec! is a macro for i in &mut v { *i += 50; } println!("iterate v"); for i in &v { println!("{}", i); } let mut v1 = Vec::new(); // v1.push(5.01); //type infer according to first value inserted v1.push(1); v1.push(3)...
-> String { let mut snew = String::new(); snew.push_str(&s); //push_str only accept reference as its param snew.push_str("_ending"); return snew; } fn main() { println!("main; -begin"); test2(); println!("main; -end"); }
ng2(s: String)
identifier_name
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use std::str; use git2; use hex::ToHex; use serde_json; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig, INDEX_LOCK}; use util::netwo...
let mut dst = self.cache_path.open_rw(path, self.config, &filename)?; let meta = dst.file().metadata()?; if meta.len() > 0 { return Ok(dst) } self.config.shell().status("Downloading", pkg)?; let config = self.config()?.unwrap(); let mut url = config....
{ let meta = dst.file().metadata()?; if meta.len() > 0 { return Ok(dst) } }
conditional_block
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use std::str; use git2; use hex::ToHex; use serde_json; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig, INDEX_LOCK}; use util::netwo...
<'cfg> { index_path: Filesystem, cache_path: Filesystem, source_id: SourceId, config: &'cfg Config, tree: RefCell<Option<git2::Tree<'static>>>, repo: LazyCell<git2::Repository>, head: Cell<Option<git2::Oid>>, } impl<'cfg> RemoteRegistry<'cfg> { pub fn new(source_id: &SourceId, config: &...
RemoteRegistry
identifier_name
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use std::str; use git2; use hex::ToHex; use serde_json; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig, INDEX_LOCK}; use util::netwo...
} self.config.shell().status("Downloading", pkg)?; let config = self.config()?.unwrap(); let mut url = config.dl.to_url()?; url.path_segments_mut().unwrap() .push(pkg.name()) .push(&pkg.version().to_string()) .push("download"); // TODO: ...
{ let filename = format!("{}-{}.crate", pkg.name(), pkg.version()); let path = Path::new(&filename); // Attempt to open an read-only copy first to avoid an exclusive write // lock and also work with read-only filesystems. Note that we check the // length of the file like below t...
identifier_body
remote.rs
use std::cell::{RefCell, Ref, Cell}; use std::io::SeekFrom; use std::io::prelude::*; use std::mem; use std::path::Path; use std::str; use git2; use hex::ToHex; use serde_json; use core::{PackageId, SourceId}; use ops; use sources::git; use sources::registry::{RegistryData, RegistryConfig, INDEX_LOCK}; use util::netwo...
let entry = tree.get_path(path)?; let object = entry.to_object(repo)?; let blob = match object.as_blob() { Some(blob) => blob, None => bail!("path `{}` is not a blob in the git repo", path.display()), }; data(blob.content()) } fn config(&mut self)...
random_line_split
aesenc.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn aesenc_1() { run_test(&Instruction { mnemonic: Mnemonic::AESENC, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XM...
() { run_test(&Instruction { mnemonic: Mnemonic::AESENC, operand1: Some(Direct(XMM3)), operand2: Some(IndirectDisplaced(RDI, 478839049, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 22...
aesenc_4
identifier_name
aesenc.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*;
} fn aesenc_2() { run_test(&Instruction { mnemonic: Mnemonic::AESENC, operand1: Some(Direct(XMM0)), operand2: Some(IndirectScaledIndexedDisplaced(EAX, EAX, Four, 939847747, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None...
fn aesenc_1() { run_test(&Instruction { mnemonic: Mnemonic::AESENC, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM2)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 220, 210], OperandSize::Dword)
random_line_split
aesenc.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn aesenc_1() { run_test(&Instruction { mnemonic: Mnemonic::AESENC, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XM...
{ run_test(&Instruction { mnemonic: Mnemonic::AESENC, operand1: Some(Direct(XMM3)), operand2: Some(IndirectDisplaced(RDI, 478839049, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 220, ...
identifier_body
generic-function.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
#![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] #[derive(Clone)] struct Struct { a: isize, b: f64 } fn dup_tup<T0: Clone, T1: Clone>(t0: &T0, t1: &T1) -> ((T0, T1), (T1, T0)) { let ret = ((t0.clone(), t1.clone()), (t1.clone(), t0.clone())); zzz(); // #break ret } ...
// lldbr-check:(((i32, generic_function::Struct), (generic_function::Struct, i32))) ret = { = { = 5 = Struct { a: 6, b: 7.5 } } = { = Struct { a: 6, b: 7.5 } = 5 } } // lldb-command:continue
random_line_split
generic-function.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let _ = dup_tup(&1, &2.5f64); let _ = dup_tup(&3.5f64, &4_u16); let _ = dup_tup(&5, &Struct { a: 6, b: 7.5 }); } fn zzz() {()}
main
identifier_name
debug.rs
// Copyright 2019 Jeremy Wall // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
(&self, w: &mut fmt::Formatter) -> fmt::Result { match self { P(Bool(v)) => write!(w, "Bool({})", v), P(Int(v)) => write!(w, "Int({})", v), P(Float(v)) => write!(w, "Float({})", v), P(Str(v)) => write!(w, "String({})", v), P(Empty) => write!(w, "NULL")...
fmt
identifier_name
debug.rs
// Copyright 2019 Jeremy Wall // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
use Primitive::{Bool, Empty, Float, Int, Str}; use Value::{C, F, M, P, S, T}; impl fmt::Debug for Value { fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { match self { P(Bool(v)) => write!(w, "Bool({})", v), P(Int(v)) => write!(w, "Int({})", v), P(Float(v)) => writ...
use super::Value; use Composite::{List, Tuple};
random_line_split
debug.rs
// Copyright 2019 Jeremy Wall // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
} F(_) => write!(w, "<Func>"), M(_) => write!(w, "<Module>"), T(_) => write!(w, "<Expression>"), S(v) => write!(w, "Symbol({})", v), } } }
{ match self { P(Bool(v)) => write!(w, "Bool({})", v), P(Int(v)) => write!(w, "Int({})", v), P(Float(v)) => write!(w, "Float({})", v), P(Str(v)) => write!(w, "String({})", v), P(Empty) => write!(w, "NULL"), C(List(ref els, _)) => { ...
identifier_body
nl.rs
impl_trait!( /// Trait marking constants valid for use in `Nlmsghdr.nl_type` NlType, u16 ); impl_var_trait!( /// Values for `nl_type` in `Nlmsghdr` Nlmsg, u16, NlType, Noop => libc::NLMSG_NOOP as u16, Error => libc::NLMSG_ERROR as u16, Done => libc::NLMSG_DONE as u16, Overrun => lib...
Getrule => libc::RTM_GETRULE, Newqdisc=> libc::RTM_NEWQDISC, Delqdisc=> libc::RTM_DELQDISC, Getqdisc=> libc::RTM_GETQDISC, Newtclass => libc::RTM_NEWTCLASS, Deltclass => libc::RTM_DELTCLASS, Gettclass => libc::RTM_GETTCLASS, Newtfilter => libc::RTM_NEWTFILTER, Deltfilter => libc::RTM...
Getneigh => libc::RTM_GETNEIGH, Newrule => libc::RTM_NEWRULE, Delrule => libc::RTM_DELRULE,
random_line_split
moves.rs
only the outermost expression that is needed. The borrow checker and trans, for example, only care about the outermost expressions that are moved. It is more efficient therefore just to store those entries. Sometimes though we want to know the variables that are moved (in particular in the borrow checker). For thes...
} } expr_tup(ref exprs) => { self.consume_exprs(*exprs, visitor); } expr_if(cond_expr, ref then_blk, opt_else_expr) => { self.consume_expr(cond_expr, visitor); self.consume_block(then_blk, visitor); ...
{ self.use_expr(*with_expr, Read, visitor); }
conditional_block