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
parse.rs
use diagnostic::Pos; use nom::{ErrorKind, IResult, Needed}; use std::cell::RefCell; use std::vec::Drain; use syntax::Expr::*; use syntax::{Expr, Ty}; use typed_arena::Arena; pub mod lex { use super::*; fn space(i: &str) -> IResult<&str, ()> { let mut chars = i.chars(); match chars.next() { Some(c) i...
call!(lex::punc::left_paren) >> ty: call!(level_1, a) >> call!(lex::punc::right_paren) >> (ty) ) | call!(var, a) | call!(forall, a) ) } pub fn var<'s, 't>(i: I<'s>, a: A<'t>) -> IResult<I<'s>, O<'t>> { map!(i, call!(lex::ident), |x| &*a.alloc(Ty::Var(x))...
pub fn level_2<'s, 't>(i: I<'s>, a: A<'t>) -> IResult<I<'s>, O<'t>> { alt!(i, do_parse!(
random_line_split
parse.rs
use diagnostic::Pos; use nom::{ErrorKind, IResult, Needed}; use std::cell::RefCell; use std::vec::Drain; use syntax::Expr::*; use syntax::{Expr, Ty}; use typed_arena::Arena; pub mod lex { use super::*; fn space(i: &str) -> IResult<&str, ()> { let mut chars = i.chars(); match chars.next() { Some(c) i...
body: call!(level_1, a) >> call!(lex::keyw::end) >> (make_let(body, vals)) ) } fn drain_all<T>(vec: &mut Vec<T>) -> Drain<T> { let range = 0.. vec.len(); vec.drain(range) } } pub mod ty { use super::*; type A<'t> = &'t Arena<Ty<'t>>; type I<'s> = &'s str; type O<'t> = &'t ...
let make_let = |acc, mut vals| drain_all(&mut vals) .rev() .fold(acc, |acc, (name, ty, value)| a.0.alloc(Let(POS, name, ty, value, acc))); do_parse!(i, call!(lex::keyw::let_) >> vals: many0!(do_parse!( call!(lex::keyw::val) >> name: call!(lex::ident) >> ...
identifier_body
parse.rs
use diagnostic::Pos; use nom::{ErrorKind, IResult, Needed}; use std::cell::RefCell; use std::vec::Drain; use syntax::Expr::*; use syntax::{Expr, Ty}; use typed_arena::Arena; pub mod lex { use super::*; fn space(i: &str) -> IResult<&str, ()> { let mut chars = i.chars(); match chars.next() { Some(c) i...
s, 'e, 't>(i: I<'s>, a: A<'e, 't>) -> IResult<I<'s>, O<'e, 't>> { let make_let = |acc, mut vals| drain_all(&mut vals) .rev() .fold(acc, |acc, (name, ty, value)| a.0.alloc(Let(POS, name, ty, value, acc))); do_parse!(i, call!(lex::keyw::let_) >> vals: many0!(do_parse!( ...
t_<'
identifier_name
htmlselectelement.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::attr::{Attr, AttrValue}; use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElemen...
(&self, local_name: &Atom, value: DOMString) -> AttrValue { match *local_name { atom!("size") => AttrValue::from_u32(value, DEFAULT_SELECT_SIZE), _ => self.super_type().unwrap().parse_plain_attribute(local_name, value), } } } impl FormControl for HTMLSelectElement {}
parse_plain_attribute
identifier_name
htmlselectelement.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::attr::{Attr, AttrValue}; use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElemen...
// Note: this function currently only exists for union.html. // https://html.spec.whatwg.org/multipage/#dom-select-add fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) { } // https://html.spec.whatwg.org/multipage/#dom-fe-disabled make_bool_g...
{ let window = window_from_node(self); ValidityState::new(window.r()) }
identifier_body
htmlselectelement.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::attr::{Attr, AttrValue}; use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElemen...
return; } let mut first_enabled: Option<Root<HTMLOptionElement>> = None; let mut last_selected: Option<Root<HTMLOptionElement>> = None; let node = self.upcast::<Node>(); for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) { ...
// https://html.spec.whatwg.org/multipage/#ask-for-a-reset pub fn ask_for_reset(&self) { if self.Multiple() {
random_line_split
math_query_sql.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
(ctx: Arc<Mutex<ExecutionContext>>, sql: &str) { let rt = Runtime::new().unwrap(); // execute the query let df = ctx.lock().unwrap().sql(&sql).unwrap(); rt.block_on(df.collect()).unwrap(); } fn create_context( array_len: usize, batch_size: usize, ) -> Result<Arc<Mutex<ExecutionContext>>> { ...
query
identifier_name
math_query_sql.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
use datafusion::datasource::MemTable; use datafusion::execution::context::ExecutionContext; fn query(ctx: Arc<Mutex<ExecutionContext>>, sql: &str) { let rt = Runtime::new().unwrap(); // execute the query let df = ctx.lock().unwrap().sql(&sql).unwrap(); rt.block_on(df.collect()).unwrap(); } fn create_...
random_line_split
math_query_sql.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
let mut ctx = ExecutionContext::new(); // declare a table in memory. In spark API, this corresponds to createDataFrame(...). let provider = MemTable::new(schema, vec![batches])?; ctx.register_table("t", Box::new(provider)); Ok(Arc::new(Mutex::new(ctx))) } fn criterion_benchmark(c: &mut Criterio...
{ // define a schema. let schema = Arc::new(Schema::new(vec![ Field::new("f32", DataType::Float32, false), Field::new("f64", DataType::Float64, false), ])); // define data. let batches = (0..array_len / batch_size) .map(|i| { RecordBatch::try_new( ...
identifier_body
webgluniformlocation.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use dom::bindings::codegen::Bindings::WebGLUn...
WebGLUniformLocation { reflector_: Reflector::new(), id: id, program_id: program_id, } } pub fn new(global: GlobalRef, id: i32, program_id: u32) -> Root<WebGLUniformLocation> { reflect_dom_object( box WebGLUniformLocation::new_inherited(id...
random_line_split
webgluniformlocation.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use dom::bindings::codegen::Bindings::WebGLUn...
(global: GlobalRef, id: i32, program_id: u32) -> Root<WebGLUniformLocation> { reflect_dom_object( box WebGLUniformLocation::new_inherited(id, program_id), global, WebGLUniformLocationBinding::Wrap) } } impl WebGLUniformLocation { pub fn id(&self) -> i32 { self.id } pub fn ...
new
identifier_name
webgluniformlocation.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use dom::bindings::codegen::Bindings::WebGLUn...
pub fn program_id(&self) -> u32 { self.program_id } }
{ self.id }
identifier_body
issue-47715.rs
// Copyright 2018 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() { }
type Type<T: Iterable<Item = impl Foo>> = T; //~^ ERROR `impl Trait` not allowed
random_line_split
issue-47715.rs
// Copyright 2018 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: Iterable<Item = impl Foo>> { //~^ ERROR `impl Trait` not allowed A(T), } union Union<T: Iterable<Item = impl Foo> + Copy> { //~^ ERROR `impl Trait` not allowed x: T, } type Type<T: Iterable<Item = impl Foo>> = T; //~^ ERROR `impl Trait` not allowed fn main() { }
Enum
identifier_name
shader.rs
use gfx; use gfx::traits::FactoryExt; use vecmath::{self, Matrix4}; static VERTEX: &[u8] = b" #version 150 core uniform mat4 u_projection, u_view; in vec2 at_tex_coord; in vec3 at_color, at_position; out vec2 v_tex_coord; out vec3 v_color; void main() { v_tex_coord = at_tex_coord...
pub fn clear(&mut self) { self.encoder.clear(&self.data.out_color, self.clear_color); self.encoder .clear_depth(&self.data.out_depth, self.clear_depth); self.encoder .clear_stencil(&self.data.out_depth, self.clear_stencil); } pub fn flush<D: gfx::Device<Resou...
{ self.data.view = view_mat; }
identifier_body
shader.rs
use gfx; use gfx::traits::FactoryExt; use vecmath::{self, Matrix4}; static VERTEX: &[u8] = b" #version 150 core uniform mat4 u_projection, u_view; in vec2 at_tex_coord; in vec3 at_color, at_position; out vec2 v_tex_coord; out vec3 v_color; void main() { v_tex_coord = at_tex_coord...
self.data.vbuf = buffer.clone(); self.slice.end = buffer.len() as u32; self.encoder.draw(&self.slice, &self.pipe, &self.data); } }
pub fn render(&mut self, buffer: &mut gfx::handle::Buffer<R, Vertex>) {
random_line_split
shader.rs
use gfx; use gfx::traits::FactoryExt; use vecmath::{self, Matrix4}; static VERTEX: &[u8] = b" #version 150 core uniform mat4 u_projection, u_view; in vec2 at_tex_coord; in vec3 at_color, at_position; out vec2 v_tex_coord; out vec3 v_color; void main() { v_tex_coord = at_tex_coord...
(&mut self, buffer: &mut gfx::handle::Buffer<R, Vertex>) { self.data.vbuf = buffer.clone(); self.slice.end = buffer.len() as u32; self.encoder.draw(&self.slice, &self.pipe, &self.data); } }
render
identifier_name
chardetect.rs
use chardet::detect; use rayon::prelude::*; use super::consts::space_fix; use std::fs::File; use std::io::{self, BufReader, Read}; use std::path::Path; #[derive(Debug, Default)] pub struct CharDet { pub files: Vec<String>, } impl CharDet { pub fn call(self) { debug!("{:?}", self); let max_len...
} if!path.is_file() { return Err(format!("Args(File): {:?} is not a file", path)); } } Ok(()) } } fn chardet(f: &str) -> io::Result<(String, f32, String)> { let mut file = BufReader::new(File::open(f)?); let mut bytes = Vec::default(); ...
pub fn check(&self) -> Result<(), String> { for path in &self.files { let path = Path::new(path); if !path.exists() { return Err(format!("Args(File): {:?} is not exists", path));
random_line_split
chardetect.rs
use chardet::detect; use rayon::prelude::*; use super::consts::space_fix; use std::fs::File; use std::io::{self, BufReader, Read}; use std::path::Path; #[derive(Debug, Default)] pub struct CharDet { pub files: Vec<String>, } impl CharDet { pub fn call(self) { debug!("{:?}", self); let max_len...
{ let mut file = BufReader::new(File::open(f)?); let mut bytes = Vec::default(); file.read_to_end(&mut bytes)?; Ok(detect(bytes.as_slice())) }
identifier_body
chardetect.rs
use chardet::detect; use rayon::prelude::*; use super::consts::space_fix; use std::fs::File; use std::io::{self, BufReader, Read}; use std::path::Path; #[derive(Debug, Default)] pub struct CharDet { pub files: Vec<String>, } impl CharDet { pub fn
(self) { debug!("{:?}", self); let max_len = self.files.as_slice().iter().max_by_key(|p| p.len()).unwrap().len(); // println!("{}{:3}CharSet{:13}Rate{:8}Info", space_fix("File",max_len), "", "", ""); self.files.par_iter().for_each(|file| match chardet(file) { Ok(o) => { ...
call
identifier_name
chardetect.rs
use chardet::detect; use rayon::prelude::*; use super::consts::space_fix; use std::fs::File; use std::io::{self, BufReader, Read}; use std::path::Path; #[derive(Debug, Default)] pub struct CharDet { pub files: Vec<String>, } impl CharDet { pub fn call(self) { debug!("{:?}", self); let max_len...
println!( "{}: {} {:.4}{:6}{}", space_fix(file, max_len), space_fix(&charset, 18), rate, "", info ); } Err(e) => eprintln!("{}: {:?}", space_f...
{ charset = "Binary".to_owned(); }
conditional_block
shootout-k-nucleotide-pipes.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
let mut line: Vec<u8>; loop { line = from_parent.recv().unwrap(); if line == Vec::new() { break; } carry.push_all(line.as_slice()); carry = windows_with_carry(carry.as_slice(), sz, |window| { update_freq(&mut freqs, window); total += 1u; }); } let...
let mut freqs: HashMap<Vec<u8>, uint> = HashMap::new(); let mut carry = Vec::new(); let mut total: uint = 0u;
random_line_split
shootout-k-nucleotide-pipes.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn make_sequence_processor(sz: uint, from_parent: &Receiver<Vec<u8>>, to_parent: &Sender<String>) { let mut freqs: HashMap<Vec<u8>, uint> = HashMap::new(); let mut carry = Vec::new(); let mut total: uint = 0u; let mut line: Vec<u8>; loop { ...
{ let mut ii = 0u; let len = bb.len(); while ii < len - (nn - 1u) { it(&bb[ii..ii+nn]); ii += 1u; } return bb[len - (nn - 1u)..len].to_vec(); }
identifier_body
shootout-k-nucleotide-pipes.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(mm: &mut HashMap<Vec<u8>, uint>, key: &[u8]) { let key = key.to_vec(); let newval = match mm.remove(&key) { Some(v) => v + 1, None => 1 }; mm.insert(key, newval); } // given a Vec<u8>, for each window call a function // i.e., for "hello" and windows of size four, // run it("hell") and ...
update_freq
identifier_name
ntr_sender.rs
use byteorder::{ByteOrder, LittleEndian}; use std::io; use std::io::prelude::*; use std::net::TcpStream; #[derive(Debug)] pub struct NtrSender { tcp_stream: TcpStream, current_seq: u32, is_heartbeat_sendable: bool, } impl NtrSender { pub fn new(tcp_stream: TcpStream) -> Self { NtrSender { ...
(&mut self, cmd: u32, arg0: u32, arg1: u32, arg2: u32) -> io::Result<usize> { let mut args = [0u32; 16]; args[0] = arg0; args[1] = arg1; args[2] = arg2; se...
send_empty_packet
identifier_name
ntr_sender.rs
use byteorder::{ByteOrder, LittleEndian}; use std::io; use std::io::prelude::*; use std::net::TcpStream; #[derive(Debug)] pub struct NtrSender { tcp_stream: TcpStream, current_seq: u32, is_heartbeat_sendable: bool, } impl NtrSender { pub fn new(tcp_stream: TcpStream) -> Self { NtrSender { ...
pub fn set_is_heartbeat_sendable(&mut self, b: bool) { self.is_heartbeat_sendable = b; } pub fn send_mem_read_packet(&mut self, addr: u32, size: u32, pid: u32) -> io::Result<usize> { self.send_empty_packet(9, pid, addr, size) } pub fn send_mem_write_packet(&mut self, addr: u32, p...
{ self.is_heartbeat_sendable }
identifier_body
ntr_sender.rs
use byteorder::{ByteOrder, LittleEndian}; use std::io; use std::io::prelude::*; use std::net::TcpStream; #[derive(Debug)] pub struct NtrSender { tcp_stream: TcpStream, current_seq: u32, is_heartbeat_sendable: bool, } impl NtrSender { pub fn new(tcp_stream: TcpStream) -> Self { NtrSender { ...
} }
args[0] = arg0; args[1] = arg1; args[2] = arg2; self.send_packet(0, cmd, &args, 0)
random_line_split
recu.rs
/* recu.rs demonstrates enums, recursive datatypes, and methdos vanilla */ fn main() { let list = ~Node(1, ~Node(2, ~Node(3, ~Empty))); let list2 = ~Node(2, ~Node(3, ~Node(5, ~Empty))); println!("Sum of all values in the list: {:i}.", list.sum()); println!("Product of all values in the list...
} } }
Empty => 1
random_line_split
recu.rs
/* recu.rs demonstrates enums, recursive datatypes, and methdos vanilla */ fn main() { let list = ~Node(1, ~Node(2, ~Node(3, ~Empty))); let list2 = ~Node(2, ~Node(3, ~Node(5, ~Empty))); println!("Sum of all values in the list: {:i}.", list.sum()); println!("Product of all values in the list...
{ Node(int, ~IntList), Empty } impl IntList { fn sum(~self) -> int { // As in C and C++, pointers are dereferenced with the asterisk `*` operator. match *self { Node(value, next) => value + next.sum(), Empty => 0 } } fn prod(~self) -> int { m...
IntList
identifier_name
clock.rs
use std::fmt; /// This represents the 90kHz, 33-bit [System Time Clock][STC] (STC) and /// the 9-bit STC extension value, which represents 1/300th of a tick. /// /// [STC]: http://www.bretl.com/mpeghtml/STC.HTM #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Clock { value: u64, } impl Clo...
/// Return a new `Clock` value, setting the 9-bit extension to the /// specified value. pub fn with_ext(&self, ext: u16) -> Clock { Clock { value: self.value &!0x1f | u64::from(ext) } } /// Convert a `Clock` value to seconds. pub fn to_seconds(&self) -> f64 { let base = (self....
{ Clock { value: stc << 9 } }
identifier_body
clock.rs
use std::fmt; /// This represents the 90kHz, 33-bit [System Time Clock][STC] (STC) and /// the 9-bit STC extension value, which represents 1/300th of a tick. /// /// [STC]: http://www.bretl.com/mpeghtml/STC.HTM #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Clock { value: u64, } impl Clo...
); #[test] fn parse_clock() { use nom::IResult; assert_eq!(clock((&[0x44, 0x02, 0xc4, 0x82, 0x04][..], 2)), IResult::Done((&[0x04][..], 6), Clock::base(0b_000_000000001011000_001000001000000))); assert_eq!(clock_and_ext((&[0x44, 0x02, 0xc4, 0x82, 0x04, 0xa9][..],...
tag_bits!(u8, 1, 0b1) >> (clock.with_ext(ext)) )
random_line_split
clock.rs
use std::fmt; /// This represents the 90kHz, 33-bit [System Time Clock][STC] (STC) and /// the 9-bit STC extension value, which represents 1/300th of a tick. /// /// [STC]: http://www.bretl.com/mpeghtml/STC.HTM #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Clock { value: u64, } impl Clo...
(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut s = self.to_seconds(); let h = (s / 3600.0).trunc(); s = s % 3600.0; let m = (s / 60.0).trunc(); s = s % 60.0; write!(f, "{}:{:02}:{:1.3}", h, m, s) } } /// Parse a 33-bit `Clock` value with 3 marker bits, cons...
fmt
identifier_name
unsized.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } }; let a: &Foo<[u8]> = &foo.value; let b: &Foo<Foo<[u8]>> = &foo; zzz(); // #break } fn zzz() { () }
main
identifier_name
unsized.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn zzz() { () }
{ let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } }; let a: &Foo<[u8]> = &foo.value; let b: &Foo<Foo<[u8]>> = &foo; zzz(); // #break }
identifier_body
unsized.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// === GDB TESTS =================================================================================== // gdb-command:run // gdb-command:print *a // gdbg-check:$1 = {value = [...] "abc"} // gdbr-check:$1 = unsized::Foo<[u8]> {value: [...]} // gdb-command:print *b // gdbg-check:$2 = {value = {value = [...] "abc"}} // g...
// except according to those terms. // compile-flags:-g
random_line_split
trait-default-method-bound-subst4.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert!(f::<float, int>(0, 2u) == 2u); assert!(f::<uint, int>(0, 2u) == 2u); }
main
identifier_name
trait-default-method-bound-subst4.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 () { assert!(f::<float, int>(0, 2u) == 2u); assert!(f::<uint, int>(0, 2u) == 2u); }
{ i.g(j) }
identifier_body
trait-default-method-bound-subst4.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. #[allow(default_met...
random_line_split
consensus.rs
use lib::blockchain::{Chain,Blockchain}; use serde_json; use reqwest::{Client, StatusCode}; use std::io::{Read}; #[derive(Deserialize)] struct ChainResponse { chain: Chain } pub struct Consensus; impl Consensus { pub fn resolve_conflicts(blockchain: &mut Blockchain) -> bool { let nodes: Vec...
} if let Some(longest_chain) = new_chain { blockchain.replace(longest_chain); is_replaced = true; } is_replaced } fn get(nodes: &[String]) -> Vec<Chain> { let chains_raw = Self::get_neighbour_chains(nodes); Self::deserialize(c...
{ max_length = chain.len(); new_chain = Some(chain); }
conditional_block
consensus.rs
use lib::blockchain::{Chain,Blockchain}; use serde_json; use reqwest::{Client, StatusCode}; use std::io::{Read}; #[derive(Deserialize)] struct ChainResponse { chain: Chain } pub struct Consensus; impl Consensus { pub fn resolve_conflicts(blockchain: &mut Blockchain) -> bool { let nodes: Vec...
#[test] fn take_authoritive() { //Same or less blocks we keep our own. Longer we replace let mut blockchain_1 = Blockchain::new_with(1); let mut blockchain_2 = Blockchain::new_with(1); blockchain_1.mine().unwrap(); assert!(!Consensus::take_authoritive(&mut blockchain_1...
{ //env_logger::init().unwrap(); let url = "http://localhost:8000"; let urls = vec![String::from(url)]; let chains = Consensus::get(urls.as_slice()); assert!(chains.len() > 0, format!("expected a populated chain. do you have a node running at {} ?", url)); }
identifier_body
consensus.rs
use lib::blockchain::{Chain,Blockchain}; use serde_json; use reqwest::{Client, StatusCode}; use std::io::{Read}; #[derive(Deserialize)] struct ChainResponse { chain: Chain } pub struct Consensus; impl Consensus { pub fn resolve_conflicts(blockchain: &mut Blockchain) -> bool { let nodes: Vec...
(blockchain: &mut Blockchain, chains: Vec<Chain>) -> bool { let mut is_replaced = false; let mut new_chain: Option<Chain> = None; let mut max_length = blockchain.len(); for chain in chains { if chain.len() > max_length && blockchain.valid_chain(&chain) { ...
take_authoritive
identifier_name
consensus.rs
use lib::blockchain::{Chain,Blockchain}; use serde_json; use reqwest::{Client, StatusCode}; use std::io::{Read}; #[derive(Deserialize)] struct ChainResponse { chain: Chain } pub struct Consensus; impl Consensus { pub fn resolve_conflicts(blockchain: &mut Blockchain) -> bool { let nodes: Vec<...
blockchain_1 = Blockchain::new_with(1); blockchain_2 = Blockchain::new_with(1); blockchain_1.mine().unwrap(); blockchain_2.mine().unwrap(); blockchain_2.mine().unwrap(); assert!(Consensus::take_authoritive(&mut blockchain_1, vec![blockchain_2.into_chain()]...
assert!(!Consensus::take_authoritive(&mut blockchain_1, vec![blockchain_2.into_chain()]), "1 block vs 1 blocks (don't replace)");
random_line_split
cache_test.rs
use super::*; use envmnt; use std::env; use std::path::PathBuf; #[test] fn load_from_path_exists() { let cwd = env::current_dir().unwrap(); let path = cwd.join("examples/cargo-make"); let cache_data = load_from_path(path); assert_eq!(cache_data.last_update_check.unwrap(), 1000u64);
#[test] fn load_from_path_not_exists() { let path = PathBuf::from("examples2/.cargo-make"); let cache_data = load_from_path(path); assert!(cache_data.last_update_check.is_none()); } #[test] #[ignore] fn load_with_cargo_home() { let path = env::current_dir().unwrap(); let directory = path.join("exa...
}
random_line_split
cache_test.rs
use super::*; use envmnt; use std::env; use std::path::PathBuf; #[test] fn load_from_path_exists() { let cwd = env::current_dir().unwrap(); let path = cwd.join("examples/cargo-make"); let cache_data = load_from_path(path); assert_eq!(cache_data.last_update_check.unwrap(), 1000u64); } #[test] fn load_...
#[test] #[ignore] fn load_without_cargo_home() { envmnt::remove("CARGO_MAKE_HOME"); load(); }
{ let path = env::current_dir().unwrap(); let directory = path.join("examples/cargo-make"); envmnt::set("CARGO_MAKE_HOME", directory.to_str().unwrap()); let cache_data = load(); envmnt::remove("CARGO_MAKE_HOME"); assert_eq!(cache_data.last_update_check.unwrap(), 1000u64); }
identifier_body
cache_test.rs
use super::*; use envmnt; use std::env; use std::path::PathBuf; #[test] fn
() { let cwd = env::current_dir().unwrap(); let path = cwd.join("examples/cargo-make"); let cache_data = load_from_path(path); assert_eq!(cache_data.last_update_check.unwrap(), 1000u64); } #[test] fn load_from_path_not_exists() { let path = PathBuf::from("examples2/.cargo-make"); let cache_dat...
load_from_path_exists
identifier_name
utils.rs
use url::percent_encoding::percent_decode; use context::Parameters; pub fn parse_parameters(source: &[u8]) -> Parameters { let mut parameters = Parameters::new(); let source: Vec<u8> = source.iter() .map(|&e| if e == '+' as u8 {'' as u8 } else { e }) ...
, _ => {} } } parameters } #[cfg(test)] mod test { use std::borrow::ToOwned; use super::parse_parameters; #[test] fn parsing_parameters() { let parameters = parse_parameters(b"a=1&aa=2&ab=202"); let a = "1".to_owned().into(); let aa = "2".to_owned()...
{ let name = percent_decode(name); parameters.insert(name, String::new()); }
conditional_block
utils.rs
use url::percent_encoding::percent_decode; use context::Parameters; pub fn parse_parameters(source: &[u8]) -> Parameters { let mut parameters = Parameters::new(); let source: Vec<u8> = source.iter() .map(|&e| if e == '+' as u8 {'' as u8 } else { e }) ...
#[test] fn parsing_parameters_with_plus() { let parameters = parse_parameters(b"a=1&aa=2+%2B+extra+meat&ab=202+fifth+avenue"); let a = "1".to_owned().into(); let aa = "2 + extra meat".to_owned().into(); let ab = "202 fifth avenue".to_owned().into(); assert_eq!(parameter...
{ let parameters = parse_parameters(b"a=1&aa=2&ab=202"); let a = "1".to_owned().into(); let aa = "2".to_owned().into(); let ab = "202".to_owned().into(); assert_eq!(parameters.get_raw("a"), Some(&a)); assert_eq!(parameters.get_raw("aa"), Some(&aa)); assert_eq!(par...
identifier_body
utils.rs
use url::percent_encoding::percent_decode; use context::Parameters; pub fn parse_parameters(source: &[u8]) -> Parameters { let mut parameters = Parameters::new(); let source: Vec<u8> = source.iter() .map(|&e| if e == '+' as u8 {'' as u8 } else { e }) ...
() { let parameters = parse_parameters(b"a=1=2&=2&ab="); let a = "1".to_owned().into(); let aa = "2".to_owned().into(); let ab = "".to_owned().into(); assert_eq!(parameters.get_raw("a"), Some(&a)); assert_eq!(parameters.get_raw(""), Some(&aa)); assert_eq!(paramete...
parsing_strange_parameters
identifier_name
utils.rs
use url::percent_encoding::percent_decode; use context::Parameters; pub fn parse_parameters(source: &[u8]) -> Parameters { let mut parameters = Parameters::new(); let source: Vec<u8> = source.iter() .map(|&e| if e == '+' as u8 {'' as u8 } else { e }) ...
}
assert_eq!(parameters.get_raw(""), Some(&aa)); assert_eq!(parameters.get_raw("ab"), Some(&ab)); }
random_line_split
types.rs
// This module implements a number of types.. // Copyright (c) 2015 by Shipeng Feng. // Licensed under the BSD License, see LICENSE for more details. use getopts; /// Command params type. pub type Params = Vec<String>; /// Command callback func type. pub type CommandCallback = fn(Params); /// Options are usually...
name: name, required: required, default: default, } } pub fn add_to_parser(&self, parser: &mut getopts::Options) { } pub fn get_usage_piece(&self) -> String { match self.required { true => format!("{}", self.name), false => fo...
Argument {
random_line_split
types.rs
// This module implements a number of types.. // Copyright (c) 2015 by Shipeng Feng. // Licensed under the BSD License, see LICENSE for more details. use getopts; /// Command params type. pub type Params = Vec<String>; /// Command callback func type. pub type CommandCallback = fn(Params); /// Options are usually...
(name: &'static str, required: bool, default: Option<&'static str>) -> Argument { Argument { name: name, required: required, default: default, } } pub fn add_to_parser(&self, parser: &mut getopts::Options) { } pub fn get_usage_piece(&self) -> String ...
new
identifier_name
types.rs
// This module implements a number of types.. // Copyright (c) 2015 by Shipeng Feng. // Licensed under the BSD License, see LICENSE for more details. use getopts; /// Command params type. pub type Params = Vec<String>; /// Command callback func type. pub type CommandCallback = fn(Params); /// Options are usually...
pub fn add_to_parser(&self, parser: &mut getopts::Options) { if self.is_flag { if!self.is_bool_flag { parser.optflagopt(self.short_name, self.long_name, self.help, self.long_name); } else if self.multiple { parser.optflagmulti(self.short_name, self.l...
{ Options { short_name: s_name, long_name: l_name, help: help, is_flag: is_flag, is_bool_flag: is_bool_flag, multiple: multiple, required: required, default: default, } }
identifier_body
types.rs
// This module implements a number of types.. // Copyright (c) 2015 by Shipeng Feng. // Licensed under the BSD License, see LICENSE for more details. use getopts; /// Command params type. pub type Params = Vec<String>; /// Command callback func type. pub type CommandCallback = fn(Params); /// Options are usually...
else if self.multiple { parser.optflagmulti(self.short_name, self.long_name, self.help); } else { parser.optflag(self.short_name, self.long_name, self.help); } } else { if self.required { parser.reqopt(self.short_name, self.lon...
{ parser.optflagopt(self.short_name, self.long_name, self.help, self.long_name); }
conditional_block
message_service.rs
use libc::c_char; use std::ffi::CString; #[repr(C)] pub struct CMessageFuncs1 { info: extern "C" fn(title: *const c_char, message: *const c_char), error: extern "C" fn(title: *const c_char, message: *const c_char), warning: extern "C" fn(title: *const c_char, message: *const c_char), } pub struct Messages...
unsafe { ((*self.api).$name)(ts.as_ptr(), ms.as_ptr()); } } } } impl Messages { message_fun!(info); message_fun!(error); message_fun!(warning); }
($name:ident) => { pub fn $name(&mut self, title: &str, message: &str) { let ts = CString::new(title).unwrap(); let ms = CString::new(message).unwrap();
random_line_split
message_service.rs
use libc::c_char; use std::ffi::CString; #[repr(C)] pub struct
{ info: extern "C" fn(title: *const c_char, message: *const c_char), error: extern "C" fn(title: *const c_char, message: *const c_char), warning: extern "C" fn(title: *const c_char, message: *const c_char), } pub struct Messages { pub api: *mut CMessageFuncs1, } macro_rules! message_fun { ($name:...
CMessageFuncs1
identifier_name
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{Reader, Writer, Stream}; use std::cmp::min; use std::vec; // 64KB chunks (moderately arbitrary) static READ_BUF_SIZE: uint = 0x10000; static WRITE_BUF_SIZE: uint = 0x10000; // TODO: consider removing constants and giving a b...
self.wrapped.flush(); } }
{ if self.writing_chunked_body { let s = format!("{}\r\n", self.write_len.to_str_radix(16)); self.wrapped.write(s.as_bytes()); } self.wrapped.write(self.write_buffer.slice_to(self.write_len)); if self.writing_chunked_body { ...
conditional_block
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{Reader, Writer, Stream}; use std::cmp::min; use std::vec; // 64KB chunks (moderately arbitrary) static READ_BUF_SIZE: uint = 0x10000; static WRITE_BUF_SIZE: uint = 0x10000; // TODO: consider removing constants and giving a b...
read_pos: 0u, read_max: 0u, write_buffer: write_buffer, write_len: 0u, writing_chunked_body: false, } } } impl<T: Reader> BufferedStream<T> { /// Poke a single byte back so it will be read next. For this to make sense, you must have just /...
let mut write_buffer = vec::with_capacity(WRITE_BUF_SIZE); unsafe { write_buffer.set_len(WRITE_BUF_SIZE); } BufferedStream { wrapped: stream, read_buffer: read_buffer,
random_line_split
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{Reader, Writer, Stream}; use std::cmp::min; use std::vec; // 64KB chunks (moderately arbitrary) static READ_BUF_SIZE: uint = 0x10000; static WRITE_BUF_SIZE: uint = 0x10000; // TODO: consider removing constants and giving a b...
(&mut self) -> bool { self.read_pos == self.read_max && self.wrapped.eof() } } impl<T: Writer> Writer for BufferedStream<T> { fn write(&mut self, buf: &[u8]) { if buf.len() + self.write_len > self.write_buffer.len() { // This is the lazy approach which may involve multiple writes wh...
eof
identifier_name
buffer.rs
/// Memory buffers for the benefit of `std::io::net` which has slow read/write. use std::io::{Reader, Writer, Stream}; use std::cmp::min; use std::vec; // 64KB chunks (moderately arbitrary) static READ_BUF_SIZE: uint = 0x10000; static WRITE_BUF_SIZE: uint = 0x10000; // TODO: consider removing constants and giving a b...
} impl<T: Reader> BufferedStream<T> { /// Poke a single byte back so it will be read next. For this to make sense, you must have just /// read that byte. If `self.pos` is 0 and `self.max` is not 0 (i.e. if the buffer is just /// filled /// Very great caution must be used in calling this as it will fai...
{ let mut read_buffer = vec::with_capacity(READ_BUF_SIZE); unsafe { read_buffer.set_len(READ_BUF_SIZE); } let mut write_buffer = vec::with_capacity(WRITE_BUF_SIZE); unsafe { write_buffer.set_len(WRITE_BUF_SIZE); } BufferedStream { wrapped: stream, read_buf...
identifier_body
error.rs
/* Copyright ⓒ 2015 cargo-script contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, modifie...
self) -> &str { use self::MainError::*; match *self { Io(_, ref err) => err.description(), OtherOwned(_, ref err) => err, OtherBorrowed(_, ref err) => err, } } } macro_rules! from_impl { ($src_ty:ty => $dst_ty:ty, $src:ident -> $e:expr) => { i...
scription(&
identifier_name
error.rs
/* Copyright ⓒ 2015 cargo-script contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
files in the project carrying such notice may not be copied, modified, or distributed except according to those terms. */ /*! This module contains the definition of the program's main error type. */ use std::error::Error; use std::fmt; use std::io; use std::result::Result as StdResult; /** Shorthand for the program's...
random_line_split
mod.rs
pub mod controller; pub use controller::{AreaEvent, Controller}; mod dispatcher; pub use dispatcher::Dispatcher; mod waveform_with_overlay; pub use waveform_with_overlay::WaveformWithOverlay; use crate::UIEventChannel; #[derive(Debug)] pub enum Event { Area(AreaEvent), UpdateRenderingCndt(Option<(f64, f64)>...
pub fn update_rendering_cndt(dimensions: Option<(f64, f64)>) { UIEventChannel::send(Event::UpdateRenderingCndt(dimensions)); } pub fn refresh() { UIEventChannel::send(Event::Refresh); } pub fn step_back() { UIEventChannel::send(Event::StepBack); } pub fn step_forward() { UIEventChannel::send(Event:...
{ UIEventChannel::send(Event::Area(event)); }
identifier_body
mod.rs
pub mod controller; pub use controller::{AreaEvent, Controller}; mod dispatcher; pub use dispatcher::Dispatcher; mod waveform_with_overlay; pub use waveform_with_overlay::WaveformWithOverlay; use crate::UIEventChannel; #[derive(Debug)] pub enum Event { Area(AreaEvent), UpdateRenderingCndt(Option<(f64, f64)>...
pub fn update_rendering_cndt(dimensions: Option<(f64, f64)>) { UIEventChannel::send(Event::UpdateRenderingCndt(dimensions)); } pub fn refresh() { UIEventChannel::send(Event::Refresh); } pub fn step_back() { UIEventChannel::send(Event::StepBack); } pub fn step_forward() { UIEventChannel::send(Event::...
fn area_event(event: AreaEvent) { UIEventChannel::send(Event::Area(event)); }
random_line_split
mod.rs
pub mod controller; pub use controller::{AreaEvent, Controller}; mod dispatcher; pub use dispatcher::Dispatcher; mod waveform_with_overlay; pub use waveform_with_overlay::WaveformWithOverlay; use crate::UIEventChannel; #[derive(Debug)] pub enum Event { Area(AreaEvent), UpdateRenderingCndt(Option<(f64, f64)>...
(event: AreaEvent) { UIEventChannel::send(Event::Area(event)); } pub fn update_rendering_cndt(dimensions: Option<(f64, f64)>) { UIEventChannel::send(Event::UpdateRenderingCndt(dimensions)); } pub fn refresh() { UIEventChannel::send(Event::Refresh); } pub fn step_back() { UIEventChannel::send(Event::S...
area_event
identifier_name
mod.rs
/////////////////////////////////////////////////////////////// // Autogenerated by Thrift Compiler (1.0.0-dev) // // DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING /////////////////////////////////////////////////////////////// #![allow(unused_mut, dead_code, non_snake_case, unused_imports)] use ::thrift...
} } service! { trait_name = SharedService, processor_name = SharedServiceProcessor, client_name = SharedServiceClient, service_methods = [ SharedServiceGetStructArgs -> SharedServiceGetStructResult = a.getStruct( key: i32 => 1, ) -> SharedStruct => SharedServiceGetStructError = [ ] (SharedS...
strukt! { name = SharedStruct, fields = { key: i32 => 1, value: String => 2,
random_line_split
def.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 ...
DefTyParam(ParamSpace, ast::DefId, uint), DefUse(ast::DefId), DefUpvar(ast::NodeId, // id of closed over local ast::NodeId, // expr node that creates the closure ast::NodeId), // block node for the closest enclosing proc // or unboxed closure, DUMMY_NOD...
DefTrait(ast::DefId), DefPrimTy(ast::PrimTy),
random_line_split
def.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> ast::DefId { match *self { DefFn(id, _) | DefStaticMethod(id, _, _) | DefMod(id) | DefForeignMod(id) | DefStatic(id, _) | DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(id) | DefTyParam(_, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) | ...
def_id
identifier_name
variadic-ffi.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 ...
() { unsafe { foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied let x: extern "C" unsafe fn(f: int, x: u8) = foo; //~^ ERROR: mismatched types: expected...
main
identifier_name
variadic-ffi.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 ...
foo(1, 2, 3f32); //~ ERROR: can't pass an f32 to variadic function, cast to c_double foo(1, 2, true); //~ ERROR: can't pass bool to variadic function, cast to c_int foo(1, 2, 1i8); //~ ERROR: can't pass i8 to variadic function, cast to c_int foo(1, 2, 1u8); //~ ERROR: can't pass u8 to va...
random_line_split
variadic-ffi.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 ...
{ unsafe { foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied let x: extern "C" unsafe fn(f: int, x: u8) = foo; //~^ ERROR: mismatched types: expected `e...
identifier_body
import-crate-with-invalid-spans.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 ...
{ // The AST of `exported_generic` stored in crate_with_invalid_spans's // metadata should contain an invalid span where span.lo > span.hi. // Let's make sure the compiler doesn't crash when encountering this. let _ = crate_with_invalid_spans::exported_generic(32u32, 7u32); }
identifier_body
import-crate-with-invalid-spans.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 ...
// Let's make sure the compiler doesn't crash when encountering this. let _ = crate_with_invalid_spans::exported_generic(32u32, 7u32); }
extern crate crate_with_invalid_spans; fn main() { // The AST of `exported_generic` stored in crate_with_invalid_spans's // metadata should contain an invalid span where span.lo > span.hi.
random_line_split
import-crate-with-invalid-spans.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 ...
() { // The AST of `exported_generic` stored in crate_with_invalid_spans's // metadata should contain an invalid span where span.lo > span.hi. // Let's make sure the compiler doesn't crash when encountering this. let _ = crate_with_invalid_spans::exported_generic(32u32, 7u32); }
main
identifier_name
bluetoothremotegattservice.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::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::Blu...
self.device.get() } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-isprimary fn IsPrimary(&self) -> bool { self.isPrimary } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-uuid fn Uuid(&self) -> DOMString { ...
fn Device(&self) -> Root<BluetoothDevice> {
random_line_split
bluetoothremotegattservice.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::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::Blu...
(&self) -> DOMString { self.uuid.clone() } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristic fn GetCharacteristic(&self) -> Option<Root<BluetoothRemoteGATTCharacteristic>> { // UNIMPLEMENTED None } }
Uuid
identifier_name
gpu_vector.rs
//! Wrapper for an OpenGL buffer object. use std::mem; use gl; use gl::types::*; use resource::gl_primitive::GLPrimitive; #[path = "../error.rs"] mod error; struct GLHandle { handle: GLuint } impl GLHandle { pub fn new(handle: GLuint) -> GLHandle { GLHandle { handle: handle } ...
pub fn is_on_gpu(&self) -> bool { self.handle.is_some() } /// Returns `true` if the cpu data and gpu data are out of sync. #[inline] pub fn trash(&self) -> bool { self.trash } /// Returns `true` if this vector is available on RAM. /// /// Note that a `GPUVector` may...
random_line_split
gpu_vector.rs
//! Wrapper for an OpenGL buffer object. use std::mem; use gl; use gl::types::*; use resource::gl_primitive::GLPrimitive; #[path = "../error.rs"] mod error; struct GLHandle { handle: GLuint } impl GLHandle { pub fn new(handle: GLuint) -> GLHandle { GLHandle { handle: handle } ...
} /// Allocates and uploads a buffer to the gpu. #[inline] pub fn upload_buffer<T: GLPrimitive>(buf: &[T], buf_type: BufferType, allocation_type: AllocationType) -> GLuint { // Upload ...
{ match *self { AllocationType::StaticDraw => gl::STATIC_DRAW, AllocationType::DynamicDraw => gl::DYNAMIC_DRAW, AllocationType::StreamDraw => gl::STREAM_DRAW } }
identifier_body
gpu_vector.rs
//! Wrapper for an OpenGL buffer object. use std::mem; use gl; use gl::types::*; use resource::gl_primitive::GLPrimitive; #[path = "../error.rs"] mod error; struct
{ handle: GLuint } impl GLHandle { pub fn new(handle: GLuint) -> GLHandle { GLHandle { handle: handle } } pub fn handle(&self) -> GLuint { self.handle } } impl Drop for GLHandle { fn drop(&mut self) { unsafe { verify!(gl::DeleteBuffers(...
GLHandle
identifier_name
gpu_vector.rs
//! Wrapper for an OpenGL buffer object. use std::mem; use gl; use gl::types::*; use resource::gl_primitive::GLPrimitive; #[path = "../error.rs"] mod error; struct GLHandle { handle: GLuint } impl GLHandle { pub fn new(handle: GLuint) -> GLHandle { GLHandle { handle: handle } ...
self.trash = false; } /// Binds this vector to the appropriate gpu array. /// /// This does not associate this buffer with any shader attribute. #[inline] pub fn bind(&mut self) { self.load_to_gpu(); let handle = self.handle.as_ref().map(|&(_, ref h)| h.handle()).expe...
{ for d in self.data.iter() { self.len = d.len(); match self.handle { None => { }, Some((ref mut len, ref handle)) => { let handle = handle.handle(); *len = update_buffer(&d[..], *len, h...
conditional_block
never-value-fallback-issue-66757.rs
// Regression test for #66757 // // Test than when you have a `!` value (e.g., the local variable // never) and an uninferred variable (here the argument to `From`) it // doesn't fallback to `()` but rather `!`. // // revisions: nofallback fallback //[fallback] run-pass //[nofallback] check-fail #![feature(never_type)...
#[allow(unused_must_use)] fn foo(never:!) { <E as From<!>>::from(never); // Ok <E as From<_>>::from(never); //[nofallback]~ ERROR trait bound `E: From<()>` is not satisfied } fn main() { }
} #[allow(unreachable_code)] #[allow(dead_code)]
random_line_split
never-value-fallback-issue-66757.rs
// Regression test for #66757 // // Test than when you have a `!` value (e.g., the local variable // never) and an uninferred variable (here the argument to `From`) it // doesn't fallback to `()` but rather `!`. // // revisions: nofallback fallback //[fallback] run-pass //[nofallback] check-fail #![feature(never_type)...
() { }
main
identifier_name
never-value-fallback-issue-66757.rs
// Regression test for #66757 // // Test than when you have a `!` value (e.g., the local variable // never) and an uninferred variable (here the argument to `From`) it // doesn't fallback to `()` but rather `!`. // // revisions: nofallback fallback //[fallback] run-pass //[nofallback] check-fail #![feature(never_type)...
fn main() { }
{ <E as From<!>>::from(never); // Ok <E as From<_>>::from(never); //[nofallback]~ ERROR trait bound `E: From<()>` is not satisfied }
identifier_body
box.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/. */ //! Generic types for box properties. use values::animated::ToAnimatedZero; /// A generic value for the `vertica...
() -> Self { VerticalAlign::Baseline } } impl<L> ToAnimatedZero for VerticalAlign<L> { fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) } } /// https://drafts.csswg.org/css-animations/#animation-iteration-count #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToC...
baseline
identifier_name
box.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/. */ //! Generic types for box properties. use values::animated::ToAnimatedZero; /// A generic value for the `vertica...
/// The `infinite` keyword. Infinite, } /// A generic value for the `perspective` property. #[derive( Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss, )] pub...
/// A `<number>` value. Number(Number),
random_line_split
sign.rs
use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use eval::divide::divide; use eval::magnitude::magnitude; pub fn sign(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val) => { Ok(if ...
{ eval_monadic(sign, left) }
identifier_body
sign.rs
use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use eval::divide::divide; use eval::magnitude::magnitude; pub fn sign(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val) => { Ok(if ...
else if val > 0.0 { ~AplInteger(1) } else { ~AplInteger(0) }) }, &AplInteger(val) => { Ok(if val < 0 { ~AplInteger(-1) } else if val > 0 { ~AplInteger(1) } else { ...
{ ~AplInteger(-1) }
conditional_block
sign.rs
use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use eval::divide::divide; use eval::magnitude::magnitude; pub fn sign(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val) => { Ok(if ...
divide(first, magnituded) }) }, &AplArray(ref _depth, ref _dimensions, ref _values) => { simple_monadic_array(sign, first) } } } pub fn eval_sign(left: &nodes::Node) -> Result<~Value, ~str> { eval_monadic(sign, left) }
&AplComplex(_c) => { magnitude(first).and_then(|magnituded| {
random_line_split
sign.rs
use nodes; use eval::array_helpers::{simple_monadic_array}; use eval::eval::{AplFloat, AplInteger, AplComplex, AplArray, Value, eval_monadic}; use eval::divide::divide; use eval::magnitude::magnitude; pub fn
(first: &Value) -> Result<~Value, ~str> { match first { &AplFloat(val) => { Ok(if val < 0.0 { ~AplInteger(-1) } else if val > 0.0 { ~AplInteger(1) } else { ~AplInteger(0) }) }, &AplInteger(val) =>...
sign
identifier_name
set_room_account_data.rs
//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type) use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; use serde_json::value::RawValue as RawJsonValue; ruma_api! { ...
pub data: Box<RawJsonValue>, /// The event type of the account_data to set. /// /// Custom types should be namespaced to avoid clashes. #[ruma_api(path)] pub event_type: String, /// The ID of the room to set account_data on. #[ruma_api(path)] pub...
/// /// To create a `Box<RawJsonValue>`, use `serde_json::value::to_raw_value`. #[ruma_api(body)]
random_line_split
csvdump.rs
use std::fs::{self, File}; use std::io::{BufWriter, Write}; use std::path::PathBuf; use clap::{App, Arg, ArgMatches, SubCommand};
use crate::blockchain::parser::types::CoinType; use crate::blockchain::proto::block::Block; use crate::blockchain::proto::tx::{EvaluatedTx, EvaluatedTxOut, TxInput}; use crate::blockchain::proto::Hashed; use crate::callbacks::Callback; use crate::common::utils; use crate::errors::OpResult; /// Dumps the whole blockcha...
random_line_split
csvdump.rs
use std::fs::{self, File}; use std::io::{BufWriter, Write}; use std::path::PathBuf; use clap::{App, Arg, ArgMatches, SubCommand}; use crate::blockchain::parser::types::CoinType; use crate::blockchain::proto::block::Block; use crate::blockchain::proto::tx::{EvaluatedTx, EvaluatedTxOut, TxInput}; use crate::blockchain:...
<'a, 'b>() -> App<'a, 'b> where Self: Sized, { SubCommand::with_name("csvdump") .about("Dumps the whole blockchain into CSV files") .version("0.1") .author("gcarq <egger.m@protonmail.com>") .arg( Arg::with_name("dump-folder") ...
build_subcommand
identifier_name
csvdump.rs
use std::fs::{self, File}; use std::io::{BufWriter, Write}; use std::path::PathBuf; use clap::{App, Arg, ArgMatches, SubCommand}; use crate::blockchain::parser::types::CoinType; use crate::blockchain::proto::block::Block; use crate::blockchain::proto::tx::{EvaluatedTx, EvaluatedTxOut, TxInput}; use crate::blockchain:...
fn new(matches: &ArgMatches) -> OpResult<Self> where Self: Sized, { let dump_folder = &PathBuf::from(matches.value_of("dump-folder").unwrap()); let cap = 4000000; let cb = CsvDump { dump_folder: PathBuf::from(dump_folder), block_writer: CsvDump::crea...
{ SubCommand::with_name("csvdump") .about("Dumps the whole blockchain into CSV files") .version("0.1") .author("gcarq <egger.m@protonmail.com>") .arg( Arg::with_name("dump-folder") .help("Folder to store csv files") ...
identifier_body
line.rs
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // 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 ...
// no intersection let r5 = Ray::new(Point2::new(5.0f32, 5.0), Vector2::new(40.0, 8.0)); let l5 = Line::new(Point2::new(5.0f32, 4.8), Point2::new(10.0, 4.1)); assert_eq!((r5, l5).intersection(), None); // no intersection // non-collinear intersection let r6 = Ray::new(Point2::new(0.0f32, 0.0),...
random_line_split
line.rs
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // 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 ...
() { // collinear, intersection is line dest let r1 = Ray::new(Point2::new(0.0f32, 0.0), Vector2::new(0.25, 0.0)); let l1 = Line::new(Point2::new(1.5f32, 0.0), Point2::new(0.5, 0.0)); assert_eq!((r1, l1).intersection(), Some(Point2::new(0.5, 0.0))); // collinear, intersection is at ray origin l...
test_line_intersection
identifier_name
line.rs
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // 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 ...
// no intersection let r5 = Ray::new(Point2::new(5.0f32, 5.0), Vector2::new(40.0, 8.0)); let l5 = Line::new(Point2::new(5.0f32, 4.8), Point2::new(10.0, 4.1)); assert_eq!((r5, l5).intersection(), None); // no intersection // non-collinear intersection let r6 = Ray::new(Point2::new(0.0f32, 0.0),...
{ // collinear, intersection is line dest let r1 = Ray::new(Point2::new(0.0f32, 0.0), Vector2::new(0.25, 0.0)); let l1 = Line::new(Point2::new(1.5f32, 0.0), Point2::new(0.5, 0.0)); assert_eq!((r1, l1).intersection(), Some(Point2::new(0.5, 0.0))); // collinear, intersection is at ray origin let ...
identifier_body
types.rs
//! Various common types. use std::borrow::Cow; use std::error; use std::fmt; use std::io; use std::result; use bson::{self, oid}; use itertools::Itertools; /// The default result type used in this library. pub type Result<T> = result::Result<T, Error>; /// A partial save error returned by `Collection::save_all()` ...
from(s: &'static str) -> (s.into()) from(s: String) -> (s.into()) } } }
Other(msg: Cow<'static, str>) { description(&*msg) display("{}", msg)
random_line_split
types.rs
//! Various common types. use std::borrow::Cow; use std::error; use std::fmt; use std::io; use std::result; use bson::{self, oid}; use itertools::Itertools; /// The default result type used in this library. pub type Result<T> = result::Result<T, Error>; /// A partial save error returned by `Collection::save_all()` ...
(oid::ObjectId); impl fmt::Display for OidHexDisplay { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { static CHARS: &'static [u8] = b"0123456789abcdef"; for &byte in &self.0.bytes() { try!(write!( f, "{}{}", CHARS[(byte >> 4) as us...
OidHexDisplay
identifier_name
types.rs
//! Various common types. use std::borrow::Cow; use std::error; use std::fmt; use std::io; use std::result; use bson::{self, oid}; use itertools::Itertools; /// The default result type used in this library. pub type Result<T> = result::Result<T, Error>; /// A partial save error returned by `Collection::save_all()` ...
} } quick_error! { /// The main error type used in the library. #[derive(Debug)] pub enum Error { /// I/O error. Io(err: io::Error) { from() description("I/O error") display("I/O error: {}", err) cause(err) } /// BSON enco...
{ write!( f, "only saved objects with ids: [{}] due to an error: {}", self.successful_ids .iter() .cloned() .map(OidHexDisplay) .join(", "), self.cause ...
conditional_block
promote.rs
use crate::{api_client, common::ui::{Status, UIReader, UIWriter, UI}, error::{Error, Result}, hcore::{package::PackageIdent, ChannelIdent}, PRODUCT, ...
}; let group_status = get_group_status(bldr_url, gid).await?; let idents = get_ident_list(ui, &group_status, origin, interactive)?; if idents.is_empty() { ui.warn("No matching packages found")?; return Ok(()); } if verbose { println!("Packages being {}:", promoted_dem...
{ ui.fatal(format!("Failed to parse group id: {}", e))?; return Err(Error::ParseIntError(e)); }
conditional_block
promote.rs
use crate::{api_client, common::ui::{Status, UIReader, UIWriter, UI}, error::{Error, Result}, hcore::{package::PackageIdent, ChannelIdent}, PRODUCT, ...
}
{ let mut ui = UI::with_sinks(); let group_status = SchedulerResponse { id: "12345678".to_string(), state: "Finished".to_string(), projects: sample_project_list(), ...
identifier_body