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
trait-inheritance-visibility.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() { f(&0) }
{ assert_eq!(x.f(), 10); }
identifier_body
trait-inheritance-visibility.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 ...
} trait Quux: traits::Foo { } impl<T:traits::Foo> Quux for T { } // Foo is not in scope but because Quux is we can still access // Foo's methods on a Quux bound typaram fn f<T:Quux>(x: &T) { assert_eq!(x.f(), 10); } pub fn main() { f(&0) }
impl Foo for isize { fn f(&self) -> isize { 10 } }
random_line_split
trait-inheritance-visibility.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> isize { 10 } } } trait Quux: traits::Foo { } impl<T:traits::Foo> Quux for T { } // Foo is not in scope but because Quux is we can still access // Foo's methods on a Quux bound typaram fn f<T:Quux>(x: &T) { assert_eq!(x.f(), 10); } pub fn main() { f(&0) }
f
identifier_name
message_queue.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 ...
<T> { inner: Arc<mpsc::Queue<T>>, noshare: marker::NoSync, } pub struct Consumer<T> { inner: Arc<mpsc::Queue<T>>, noshare: marker::NoSync, } impl<T: Send> Consumer<T> { pub fn pop(&self) -> PopResult<T> { match self.inner.pop() { mpsc::Inconsistent => Inconsistent, ...
Producer
identifier_name
message_queue.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
use std::kinds::marker; use std::sync::Arc; use std::sync::mpsc_queue as mpsc; pub use self::PopResult::{Inconsistent, Empty, Data}; pub enum PopResult<T> { Inconsistent, Empty, Data(T), } pub fn queue<T: Send>() -> (Consumer<T>, Producer<T>) { let a = Arc::new(mpsc::Queue::new()); (Consumer { i...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
message_queue.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub struct Producer<T> { inner: Arc<mpsc::Queue<T>>, noshare: marker::NoSync, } pub struct Consumer<T> { inner: Arc<mpsc::Queue<T>>, noshare: marker::NoSync, } impl<T: Send> Consumer<T> { pub fn pop(&self) -> PopResult<T> { match self.inner.pop() { mpsc::Inconsistent => Incon...
{ let a = Arc::new(mpsc::Queue::new()); (Consumer { inner: a.clone(), noshare: marker::NoSync }, Producer { inner: a, noshare: marker::NoSync }) }
identifier_body
client.rs
#![feature(core, io, test)] extern crate hyper; extern crate test; use std::fmt; use std::old_io::net::ip::Ipv4Addr; use hyper::server::{Request, Response, Server}; use hyper::header::Headers; use hyper::Client; fn listen() -> hyper::server::Listening { let server = Server::http(Ipv4Addr(127, 0, 0, 1), 0); s...
(_r: Request, res: Response) { static BODY: &'static [u8] = b"Benchmarking hyper vs others!"; let mut res = try_return!(res.start()); try_return!(res.write_all(BODY)); try_return!(res.end()); } #[derive(Clone)] struct Foo; impl hyper::header::Header for Foo { fn header_name() -> &'static str { ...
handle
identifier_name
client.rs
#![feature(core, io, test)] extern crate hyper; extern crate test; use std::fmt; use std::old_io::net::ip::Ipv4Addr; use hyper::server::{Request, Response, Server}; use hyper::header::Headers; use hyper::Client; fn listen() -> hyper::server::Listening { let server = Server::http(Ipv4Addr(127, 0, 0, 1), 0); s...
{ let mut listening = listen(); let s = format!("http://{}/", listening.socket); let url = s.as_slice(); let mut client = Client::new(); let mut headers = Headers::new(); headers.set(Foo); b.iter(|| { client.get(url).header(Foo).send().unwrap().read_to_string().unwrap(); }); ...
identifier_body
client.rs
#![feature(core, io, test)] extern crate hyper; extern crate test; use std::fmt; use std::old_io::net::ip::Ipv4Addr; use hyper::server::{Request, Response, Server}; use hyper::header::Headers; use hyper::Client; fn listen() -> hyper::server::Listening { let server = Server::http(Ipv4Addr(127, 0, 0, 1), 0); s...
} #[bench] fn bench_hyper(b: &mut test::Bencher) { let mut listening = listen(); let s = format!("http://{}/", listening.socket); let url = s.as_slice(); let mut client = Client::new(); let mut headers = Headers::new(); headers.set(Foo); b.iter(|| { client.get(url).header(Foo).send(...
random_line_split
raw.rs
use std::borrow::Cow; use std::fmt; use http::buf::MemSlice; /// A raw header value. #[derive(Clone, PartialEq, Eq)] pub struct Raw(Lines); impl Raw { /// Returns the amount of lines. #[inline] pub fn len(&self) -> usize { match self.0 { Lines::One(..) => 1, Lines::Many(ref...
(val: Vec<u8>) -> Raw { Raw(Lines::One(Line::from(val))) } } impl From<&'static str> for Raw { fn from(val: &'static str) -> Raw { Raw(Lines::One(Line::Static(val.as_bytes()))) } } impl From<&'static [u8]> for Raw { fn from(val: &'static [u8]) -> Raw { Raw(Lines::One(Line::Stat...
from
identifier_name
raw.rs
use std::borrow::Cow; use std::fmt; use http::buf::MemSlice; /// A raw header value. #[derive(Clone, PartialEq, Eq)] pub struct Raw(Lines); impl Raw { /// Returns the amount of lines. #[inline] pub fn len(&self) -> usize { match self.0 { Lines::One(..) => 1, Lines::Many(ref...
#[derive(Debug, Clone, PartialEq, Eq)] enum Line { Static(&'static [u8]), Owned(Vec<u8>), Shared(MemSlice), } fn eq<A: AsRef<[u8]>, B: AsRef<[u8]>>(a: &[A], b: &[B]) -> bool { if a.len()!= b.len() { false } else { for (a, b) in a.iter().zip(b.iter()) { if a.as_ref()!= b....
enum Lines { One(Line), Many(Vec<Line>), }
random_line_split
raw.rs
use std::borrow::Cow; use std::fmt; use http::buf::MemSlice; /// A raw header value. #[derive(Clone, PartialEq, Eq)] pub struct Raw(Lines); impl Raw { /// Returns the amount of lines. #[inline] pub fn len(&self) -> usize { match self.0 { Lines::One(..) => 1, Lines::Many(ref...
/// Append a line to this `Raw` header value. pub fn push(&mut self, val: &[u8]) { self.push_line(maybe_literal(val.into())); } fn push_line(&mut self, line: Line) { let lines = ::std::mem::replace(&mut self.0, Lines::Many(Vec::new())); match lines { Lines::One(one...
{ RawLines { inner: &self.0, pos: 0, } }
identifier_body
request.rs
#[derive(RustcDecodable, RustcEncodable)]
Ping, } #[derive(RustcDecodable, RustcEncodable)] pub struct UserFlagPair { pub id: usize, pub flag: String, pub user: String, } impl CTFRequest { pub fn verify_flag(id: usize, flag: String, user: String) -> Self { CTFRequest::FlagOffer(UserFlagPair::new(id, flag, user)) } pub fn ...
pub enum CTFRequest { FlagOffer(UserFlagPair), Leaderboard(usize, usize),
random_line_split
request.rs
#[derive(RustcDecodable, RustcEncodable)] pub enum
{ FlagOffer(UserFlagPair), Leaderboard(usize, usize), Ping, } #[derive(RustcDecodable, RustcEncodable)] pub struct UserFlagPair { pub id: usize, pub flag: String, pub user: String, } impl CTFRequest { pub fn verify_flag(id: usize, flag: String, user: String) -> Self { CTFRequest::...
CTFRequest
identifier_name
stream.rs
use std::io::Read; use std::fmt::{self, Debug}; use response::{Response, Responder, DEFAULT_CHUNK_SIZE}; use http::Status; /// Streams a response to a client from an arbitrary `Read`er type. /// /// The client is sent a "chunked" response, where the chunk size is at most /// 4KiB. This means that at most 4KiB are sto...
/// Create a new stream from the given `reader` and sets the chunk size for /// each streamed chunk to `chunk_size` bytes. /// /// # Example /// /// Stream a response from whatever is in `stdin` with a chunk size of 10 /// bytes. Note: you probably shouldn't do this. /// /// ```rus...
{ Stream(reader, DEFAULT_CHUNK_SIZE) }
identifier_body
stream.rs
use std::io::Read; use std::fmt::{self, Debug}; use response::{Response, Responder, DEFAULT_CHUNK_SIZE}; use http::Status; /// Streams a response to a client from an arbitrary `Read`er type. /// /// The client is sent a "chunked" response, where the chunk size is at most /// 4KiB. This means that at most 4KiB are sto...
(reader: T, chunk_size: u64) -> Stream<T> { Stream(reader, chunk_size) } } impl<T: Read + Debug> Debug for Stream<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Stream({:?})", self.0) } } /// Sends a response to the client using the "Chunked" transfer encoding. The ...
chunked
identifier_name
stream.rs
use std::io::Read; use std::fmt::{self, Debug}; use response::{Response, Responder, DEFAULT_CHUNK_SIZE}; use http::Status; /// Streams a response to a client from an arbitrary `Read`er type. /// /// The client is sent a "chunked" response, where the chunk size is at most /// 4KiB. This means that at most 4KiB are sto...
/// response is abandoned, and the response ends abruptly. An error is printed /// to the console with an indication of what went wrong. impl<'r, T: Read + 'r> Responder<'r> for Stream<T> { fn respond(self) -> Result<Response<'r>, Status> { Response::build().chunked_body(self.0, self.1).ok() } }
/// /// # Failure /// /// If reading from the input stream fails at any point during the response, the
random_line_split
match-beginning-vert.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 ...
match *foo { | A => println!("A"), | B | C if 1 < 2 => println!("BC!"), | _ => {}, } } }
fn main() { for foo in &[A, B, C, D, E] {
random_line_split
match-beginning-vert.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 ...
{ A, B, C, D, E, } use Foo::*; fn main() { for foo in &[A, B, C, D, E] { match *foo { | A => println!("A"), | B | C if 1 < 2 => println!("BC!"), | _ => {}, } } }
Foo
identifier_name
feature_collection.rs
// Copyright 2015 The GeoRust Developers // // 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...
pub struct FeatureCollection { pub bbox: Option<Bbox>, pub crs: Option<Crs>, pub features: Vec<Feature>, } impl<'a> From<&'a FeatureCollection> for json::Object { fn from(fc: &'a FeatureCollection) -> json::Object { let mut map = BTreeMap::new(); map.insert(String::from("type"), "Featu...
#[derive(Clone, Debug, PartialEq)]
random_line_split
feature_collection.rs
// Copyright 2015 The GeoRust Developers // // 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...
&self) -> json::Json { return json::Json::Object(self.into()); } }
o_json(
identifier_name
feature_collection.rs
// Copyright 2015 The GeoRust Developers // // 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...
if let Some(ref bbox) = fc.bbox { map.insert(String::from("bbox"), bbox.to_json()); } return map; } } impl FromObject for FeatureCollection { fn from_object(object: &json::Object) -> Result<Self, Error> { return Ok(FeatureCollection{ bbox: try!(util::ge...
map.insert(String::from("crs"), crs.to_json()); }
conditional_block
color.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 azure::AzFloat; use azure::azure::AzColor; #[inline] pub fn new(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloa...
#[inline] pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor { AzColor { r: r, g: g, b: b, a: a } } #[inline] pub fn black() -> AzColor { AzColor { r: 0.0, g: 0.0, b: 0.0, a: 1.0 } } #[inline] pub fn transparent() -> AzColor { AzColor { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } } #[inline] p...
{ AzColor { r: (r as AzFloat) / (255.0 as AzFloat), g: (g as AzFloat) / (255.0 as AzFloat), b: (b as AzFloat) / (255.0 as AzFloat), a: 1.0 as AzFloat } }
identifier_body
color.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 azure::AzFloat; use azure::azure::AzColor; #[inline] pub fn new(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloa...
pub fn black() -> AzColor { AzColor { r: 0.0, g: 0.0, b: 0.0, a: 1.0 } } #[inline] pub fn transparent() -> AzColor { AzColor { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } } #[inline] pub fn white() -> AzColor { AzColor { r: 1.0, g: 1.0, b: 1.0, a: 1.0 } }
AzColor { r: r, g: g, b: b, a: a } } #[inline]
random_line_split
color.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 azure::AzFloat; use azure::azure::AzColor; #[inline] pub fn
(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor { AzColor { r: r, g: g, b: b, a: a } } #[inline] pub fn rgb(r: u8, g: u8, b: u8) -> AzColor { AzColor { r: (r as AzFloat) / (255.0 as AzFloat), g: (g as AzFloat) / (255.0 as AzFloat), b: (b as AzFloat) / (255.0 as AzFloat), ...
new
identifier_name
city.rs
use iron::prelude::*; use hyper::status::StatusCode; use super::request_body; use ::proto::response::*; use ::proto::schema::NewCity; use ::db::schema::*; use ::db::*; pub fn
(_: &mut Request) -> IronResult<Response> { let query = City::select_builder().build(); let conn = get_db_connection(); info!("request GET /city"); let rows = conn.query(&query, &[]).unwrap(); let cities = rows.into_iter() .map(City::from) .collect::<Vec<City>>(); Ok(cities.as_r...
get_cities
identifier_name
city.rs
use iron::prelude::*; use hyper::status::StatusCode; use super::request_body; use ::proto::response::*; use ::proto::schema::NewCity; use ::db::schema::*; use ::db::*; pub fn get_cities(_: &mut Request) -> IronResult<Response> { let query = City::select_builder().build(); let conn = get_db_connection(); ...
Ok(cities.as_response()) } pub fn put_city(req: &mut Request) -> IronResult<Response> { let new_city: NewCity = request_body(req)?; info!("request PUT /city {{ {:?} }}", new_city); let conn = get_db_connection(); let query = City::insert_query(); conn.execute(&query, &[&new_city.Name]).unwr...
let rows = conn.query(&query, &[]).unwrap(); let cities = rows.into_iter() .map(City::from) .collect::<Vec<City>>();
random_line_split
city.rs
use iron::prelude::*; use hyper::status::StatusCode; use super::request_body; use ::proto::response::*; use ::proto::schema::NewCity; use ::db::schema::*; use ::db::*; pub fn get_cities(_: &mut Request) -> IronResult<Response>
pub fn put_city(req: &mut Request) -> IronResult<Response> { let new_city: NewCity = request_body(req)?; info!("request PUT /city {{ {:?} }}", new_city); let conn = get_db_connection(); let query = City::insert_query(); conn.execute(&query, &[&new_city.Name]).unwrap(); Ok(Response::with(St...
{ let query = City::select_builder().build(); let conn = get_db_connection(); info!("request GET /city"); let rows = conn.query(&query, &[]).unwrap(); let cities = rows.into_iter() .map(City::from) .collect::<Vec<City>>(); Ok(cities.as_response()) }
identifier_body
mouse.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, c...
(window: &WindowImpl) -> (i32, i32) { let point = ffi::ve_mouse_get_location(window.window_handler); (point.x as i32, point.y as i32) } pub fn screen_location() -> (i32, i32) { let point = ffi::ve_mouse_get_global_location(); (point.x as i32, point.y as i32) }
location
identifier_name
mouse.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, c...
{ let point = ffi::ve_mouse_get_global_location(); (point.x as i32, point.y as i32) }
identifier_body
mouse.rs
// The MIT License (MIT) // // Copyright (c) 2014 Jeremy Letang // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, c...
(point.x as i32, point.y as i32) }
random_line_split
extshadertexturelod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_d...
fn enable(_ext: &WebGLExtensions) {} fn name() -> &'static str { "EXT_shader_texture_lod" } }
!ext.is_gles() || ext.supports_gl_extension("GL_EXT_shader_texture_lod") }
random_line_split
extshadertexturelod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_d...
}
{ "EXT_shader_texture_lod" }
identifier_body
extshadertexturelod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::reflector::{reflect_d...
(ext: &WebGLExtensions) -> bool { // This extension is always available on desktop GL. !ext.is_gles() || ext.supports_gl_extension("GL_EXT_shader_texture_lod") } fn enable(_ext: &WebGLExtensions) {} fn name() -> &'static str { "EXT_shader_texture_lod" } }
is_supported
identifier_name
structured-compare.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn main() { let a = (1i, 2i, 3i); let b = (1i, 2i, 3i); assert_eq!(a, b); assert!((a!= (1, 2, 4))); assert!((a < (1, 2, 4))); assert!((a <= (1, 2, 4))); assert!(((1i, 2i, 4i) > a)); assert!(((1i, 2i, 4i) >= a)); let x = foo::large; let y = foo::small; assert!((x!= y))...
{ !(*self).eq(other) }
identifier_body
structured-compare.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let a = (1i, 2i, 3i); let b = (1i, 2i, 3i); assert_eq!(a, b); assert!((a!= (1, 2, 4))); assert!((a < (1, 2, 4))); assert!((a <= (1, 2, 4))); assert!(((1i, 2i, 4i) > a)); assert!(((1i, 2i, 4i) >= a)); let x = foo::large; let y = foo::small; assert!((x!= y)); assert_eq...
main
identifier_name
structured-compare.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let a = (1i, 2i, 3i); let b = (1i, 2i, 3i); assert_eq!(a, b); assert!((a!= (1, 2, 4))); assert!((a < (1, 2, 4))); assert!((a <= (1, 2, 4))); assert!(((1i, 2i, 4i) > a)); assert!(((1i, 2i, 4i) >= a)); let x = foo::large; let y = foo::small; assert!((x!= y)); ...
} fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } }
random_line_split
symbol_analysis.rs
use tokens::*; use symbols::*; use support::*; use plp::PLPWriter; use symbols::commons::*; use symbols::symbol_table::*; pub fn get_accessor_namespace(symbol: &Symbol, symbol_table: &StaticSymbolTable) -> Option<String> { match symbol.symbol_class { SymbolClass::Variable(ref variable_type) => { ...
} } /// @return ([arg1] [, arg2] {, arg3..}) pub fn get_arg_signature_of(method_symbol: &Symbol) -> String { let types: &Vec<String> = match method_symbol.symbol_class { SymbolClass::Variable(_) => { panic!("Expected Function found Variable"); }, SymbolClass::Fu...
{ panic!("Expected Function found {}", subtype); }
conditional_block
symbol_analysis.rs
use tokens::*; use symbols::*; use support::*; use plp::PLPWriter; use symbols::commons::*; use symbols::symbol_table::*; pub fn get_accessor_namespace(symbol: &Symbol, symbol_table: &StaticSymbolTable) -> Option<String> { match symbol.symbol_class { SymbolClass::Variable(ref variable_type) => { ...
let namespace = concatenate_namespace(&*type_symbol.namespace, &*type_symbol.name); return Some(namespace); }, SymbolClass::Structure(_, _) => { panic!("get_accessor_namespace: Structure access not currently supported"); }, SymbolClass::Function(_, _, ...
if potential_matches.is_empty() { return None; } let type_symbol = potential_matches[0];
random_line_split
symbol_analysis.rs
use tokens::*; use symbols::*; use support::*; use plp::PLPWriter; use symbols::commons::*; use symbols::symbol_table::*; pub fn get_accessor_namespace(symbol: &Symbol, symbol_table: &StaticSymbolTable) -> Option<String> { match symbol.symbol_class { SymbolClass::Variable(ref variable_type) => { ...
(method_symbol: &Symbol) -> (String, u16) { match method_symbol.symbol_class { SymbolClass::Variable(_) => { panic!("Expected Function found Variable"); }, SymbolClass::Function(_, _, ref label_name, var_count) => (label_name.clone(), var_count as u16), ...
get_static_allocation
identifier_name
symbol_analysis.rs
use tokens::*; use symbols::*; use support::*; use plp::PLPWriter; use symbols::commons::*; use symbols::symbol_table::*; pub fn get_accessor_namespace(symbol: &Symbol, symbol_table: &StaticSymbolTable) -> Option<String> { match symbol.symbol_class { SymbolClass::Variable(ref variable_type) => { ...
/// @return ([arg1] [, arg2] {, arg3..}) pub fn get_arg_signature_of(method_symbol: &Symbol) -> String { let types: &Vec<String> = match method_symbol.symbol_class { SymbolClass::Variable(_) => { panic!("Expected Function found Variable"); }, SymbolClass::Function(_...
{ match method_symbol.symbol_class { SymbolClass::Variable(_) => { panic!("Expected Function found Variable"); }, SymbolClass::Function(ref return_type, _, _, _) => return_type.clone(), SymbolClass::Structure(ref subtype, _) => { panic!("Expect...
identifier_body
config.rs
//! The configuration format for the program container use typedef::*; pub const DEFAULT_SCALE: f64 = 4.0; pub const DEFAULT_SCREEN_WIDTH: usize = 160; pub const DEFAULT_SCREEN_HEIGHT: usize = 100; pub const DEFAULT_WINDOW_TITLE: &str = "bakerVM"; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DisplayC...
}
{ Config { title: DEFAULT_WINDOW_TITLE.into(), display: Default::default(), input_enabled: true, } }
identifier_body
config.rs
//! The configuration format for the program container use typedef::*; pub const DEFAULT_SCALE: f64 = 4.0; pub const DEFAULT_SCREEN_WIDTH: usize = 160; pub const DEFAULT_SCREEN_HEIGHT: usize = 100; pub const DEFAULT_WINDOW_TITLE: &str = "bakerVM"; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DisplayC...
() -> Self { DisplayConfig { resolution: Default::default(), default_scale: DEFAULT_SCALE, hide_cursor: true, } } } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DisplayResolution { pub width: usize, pub height: usize, } impl Default for Dis...
default
identifier_name
config.rs
//! The configuration format for the program container use typedef::*;
pub const DEFAULT_SCREEN_HEIGHT: usize = 100; pub const DEFAULT_WINDOW_TITLE: &str = "bakerVM"; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DisplayConfig { #[serde(default)] pub resolution: DisplayResolution, pub default_scale: Float, #[serde(default)] pub hide_cursor: bool, } impl...
pub const DEFAULT_SCALE: f64 = 4.0; pub const DEFAULT_SCREEN_WIDTH: usize = 160;
random_line_split
svg.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 CSS values in SVG use cssparser::Parser; use parser::{Parse, ParserContext}; use style_trai...
/// The paint source pub kind: SVGPaintKind<ColorType, UrlPaintServer>, /// The fallback color. It would be empty, the `none` keyword or <color>. pub fallback: Option<Either<ColorType, None_>>, } /// An SVG paint value without the fallback /// /// Whereas the spec only allows PaintServer /// to have a ...
random_line_split
svg.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 CSS values in SVG use cssparser::Parser; use parser::{Parse, ParserContext}; use style_trai...
<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if let Ok(num) = input.try(|i| NumberType::parse(context, i)) { return Ok(SvgLengthOrPercentageOrNumber::Number(num)); } if let Ok(lop) = input.try(|i| LengthOrPerc...
parse
identifier_name
issue-14182.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 ...
// ignore-test FIXME(japari) remove test struct Foo { f: for <'b> |&'b isize|: 'b -> &'b isize //~ ERROR use of undeclared lifetime name `'b` } fn main() { let mut x: Vec< for <'a> || :'a //~ ERROR use of undeclared lifetime name `'a` > = Vec::new(); x.push(|| {}); let foo = Foo { ...
// option. This file may not be copied, modified, or distributed // except according to those terms. // compile-flags: -Z parse-only
random_line_split
issue-14182.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut x: Vec< for <'a> || :'a //~ ERROR use of undeclared lifetime name `'a` > = Vec::new(); x.push(|| {}); let foo = Foo { f: |x| x }; }
main
identifier_name
issue-14182.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut x: Vec< for <'a> || :'a //~ ERROR use of undeclared lifetime name `'a` > = Vec::new(); x.push(|| {}); let foo = Foo { f: |x| x }; }
identifier_body
gash.rs
// // gash.rs // // Reference solution for PS2 // Running on Rust 0.8 // // Special thanks to Kiet Tran for porting code from Rust 0.7 to Rust 0.8. // // University of Virginia - cs4414 Fall 2013 // Weilin Xu, Purnam Jantrania, David Evans // Version 0.2 // // Modified use std::{run, os, libc}; use std::task; fn get...
}
{ let mut output_opt = None; for i in range(0, progs.len()) { let prog = progs[i].to_owned(); if i == 0 { let pipe_i = pipes[i]; task::spawn_sched(task::SingleThreaded, ||{handle_cmd(prog, 0, pipe_i.out, 2)}); } else if i =...
conditional_block
gash.rs
// // gash.rs // // Reference solution for PS2 // Running on Rust 0.8 // // Special thanks to Kiet Tran for porting code from Rust 0.7 to Rust 0.8. // // University of Virginia - cs4414 Fall 2013 // Weilin Xu, Purnam Jantrania, David Evans // Version 0.2 // // Modified use std::{run, os, libc}; use std::task; fn get...
fn _handle_cmd(cmd_line: &str, pipe_in: libc::c_int, pipe_out: libc::c_int, pipe_err: libc::c_int, output: bool) -> Option<run::ProcessOutput> { let out_fd = pipe_out; let in_fd = pipe_in; let err_fd = pipe_err; let mut argv: ~[~str] = cmd_line.split_iter(' ').filter_map(|x...
{ #[fixed_stack_segment]; #[inline(never)]; unsafe { libc::exit(status); } }
identifier_body
gash.rs
// // gash.rs // // Reference solution for PS2 // Running on Rust 0.8 // // Special thanks to Kiet Tran for porting code from Rust 0.7 to Rust 0.8. // // University of Virginia - cs4414 Fall 2013 // Weilin Xu, Purnam Jantrania, David Evans // Version 0.2 // // Modified use std::{run, os, libc}; use std::task; fn get...
(cmd_line: &str) -> Option<run::ProcessOutput> { // handle pipes let progs: ~[~str] = cmd_line.split_iter('|').map(|x| x.trim().to_owned()).collect(); let mut pipes = ~[]; for _ in range(0, progs.len()-1) { pipes.push(os::pipe()); } if progs.len() == 1 { return hand...
handle_cmdline
identifier_name
gash.rs
// // gash.rs // // Reference solution for PS2 // Running on Rust 0.8 // // Special thanks to Kiet Tran for porting code from Rust 0.7 to Rust 0.8. // // University of Virginia - cs4414 Fall 2013 // Weilin Xu, Purnam Jantrania, David Evans // Version 0.2 // // Modified use std::{run, os, libc}; use std::task; fn get...
} fn exit(status: libc::c_int) { #[fixed_stack_segment]; #[inline(never)]; unsafe { libc::exit(status); } } fn _handle_cmd(cmd_line: &str, pipe_in: libc::c_int, pipe_out: libc::c_int, pipe_err: libc::c_int, output: bool) -> Option<run::ProcessOutput> { let out_fd = pipe_out; let in_fd =...
let modebuf = mode.to_c_str().unwrap(); return libc::fileno(libc::fopen(fpathbuf, modebuf)); }
random_line_split
lib.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 ...
//! This implementation executes regular expressions **only** on sequences of //! Unicode code points while exposing match locations as byte indices into the //! search string. //! //! Currently, only naive case folding is supported. Namely, when matching //! case insensitively, the characters are first converted to th...
//!
random_line_split
gamepad.rs
//! Gamepad utility functions. //! //! This is going to be a bit of a work-in-progress as gamepad input //! gets fleshed out. The `gilrs` crate needs help to add better //! cross-platform support. Why not give it a hand? use gilrs::ConnectedGamepadsIterator; use std::fmt; pub use gilrs::{self, Event, Gamepad, Gilrs}...
} } impl<'a> Iterator for GamepadsIterator<'a> { type Item = (GamepadId, Gamepad<'a>); fn next(&mut self) -> Option<(GamepadId, Gamepad<'a>)> { self.wrapped.next().map(|(id, gp)| (GamepadId(id), gp)) } } /// A structure that implements [`GamepadContext`](trait.GamepadContext.html) /// but doe...
random_line_split
gamepad.rs
//! Gamepad utility functions. //! //! This is going to be a bit of a work-in-progress as gamepad input //! gets fleshed out. The `gilrs` crate needs help to add better //! cross-platform support. Why not give it a hand? use gilrs::ConnectedGamepadsIterator; use std::fmt; pub use gilrs::{self, Event, Gamepad, Gilrs}...
(&mut self) -> Option<(GamepadId, Gamepad<'a>)> { self.wrapped.next().map(|(id, gp)| (GamepadId(id), gp)) } } /// A structure that implements [`GamepadContext`](trait.GamepadContext.html) /// but does nothing; a stub for when you don't need it or are /// on a platform that `gilrs` doesn't support. #[derive...
next
identifier_name
gamepad.rs
//! Gamepad utility functions. //! //! This is going to be a bit of a work-in-progress as gamepad input //! gets fleshed out. The `gilrs` crate needs help to add better //! cross-platform support. Why not give it a hand? use gilrs::ConnectedGamepadsIterator; use std::fmt; pub use gilrs::{self, Event, Gamepad, Gilrs}...
fn gamepad(&self, _id: GamepadId) -> Gamepad { panic!("Gamepad module disabled") } fn gamepads(&self) -> GamepadsIterator { panic!("Gamepad module disabled") } } /// Returns the `Gamepad` associated with an `id`. pub fn gamepad(ctx: &Context, id: GamepadId) -> Gamepad { ctx.gamep...
{ panic!("Gamepad module disabled") }
identifier_body
mod.rs
#![cfg(target_os = "android")] use crate::api::egl::{ Context as EglContext, NativeDisplay, SurfaceType as EglSurfaceType, }; use crate::CreationError::{self, OsError}; use crate::{ Api, ContextError, GlAttributes, PixelFormat, PixelFormatRequirements, Rect, }; use crate::platform::android::EventLoopExtAndroi...
#[inline] pub fn get_api(&self) -> Api { self.0.egl_context.get_api() } #[inline] pub fn get_pixel_format(&self) -> PixelFormat { self.0.egl_context.get_pixel_format() } #[inline] pub unsafe fn raw_handle(&self) -> ffi::EGLContext { self.0.egl_context.raw_handl...
self.0.egl_context.swap_buffers_with_damage_supported() }
random_line_split
mod.rs
#![cfg(target_os = "android")] use crate::api::egl::{ Context as EglContext, NativeDisplay, SurfaceType as EglSurfaceType, }; use crate::CreationError::{self, OsError}; use crate::{ Api, ContextError, GlAttributes, PixelFormat, PixelFormatRequirements, Rect, }; use crate::platform::android::EventLoopExtAndroi...
(&self) -> ffi::EGLDisplay { self.0.egl_context.get_egl_display() } }
get_egl_display
identifier_name
mod.rs
#![cfg(target_os = "android")] use crate::api::egl::{ Context as EglContext, NativeDisplay, SurfaceType as EglSurfaceType, }; use crate::CreationError::{self, OsError}; use crate::{ Api, ContextError, GlAttributes, PixelFormat, PixelFormatRequirements, Rect, }; use crate::platform::android::EventLoopExtAndroi...
_ => { return; } }; } } impl Context { #[inline] pub fn new_windowed<T>( wb: WindowBuilder, el: &EventLoopWindowTarget<T>, pf_reqs: &PixelFormatRequirements, gl_attr: &GlAttributes<&Self>, ) -> Result<(winit::window::Windo...
{ let mut stopped = self.0.stopped.as_ref().unwrap().lock(); *stopped = true; }
conditional_block
book.rs
use super::Processor; use crate::data::messages::{BookRecord, BookUpdate, RecordUpdate}; use crate::data::trade::TradeBook;
#[derive(Clone)] pub struct Accountant { tb: Arc<Mutex<TradeBook>>, } impl Accountant { pub fn new(tb: Arc<Mutex<TradeBook>>) -> Accountant { Accountant { tb } } } impl Processor for Accountant { fn process_message(&mut self, msg: String) -> Result<(), PoloError> { let err = |title| P...
use crate::error::PoloError; use std::str::FromStr; use std::sync::{Arc, Mutex};
random_line_split
book.rs
use super::Processor; use crate::data::messages::{BookRecord, BookUpdate, RecordUpdate}; use crate::data::trade::TradeBook; use crate::error::PoloError; use std::str::FromStr; use std::sync::{Arc, Mutex}; #[derive(Clone)] pub struct Accountant { tb: Arc<Mutex<TradeBook>>, } impl Accountant { pub fn new(tb: Ar...
() { let tb = Arc::new(Mutex::new(TradeBook::new())); let mut accountant = Accountant::new(tb.clone()); let order = String::from(r#"[189, 5130995, [["i", {"currencyPair": "BTC_BCH", "orderBook": [{"0.13161901": 0.23709568, "0.13164313": "0.17328089"}, {"0.13169621": 0.2331}]}]]]"#); acc...
initial_order
identifier_name
bad_transaction.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_universe::{AUTransactionGen, AccountUniverse}, common_transactions::{empty_txn, EMPTY_SCRIPT}, gas_costs, }; use diem_crypto::{ ed25519::{self, Ed25519PrivateKey, Ed25519PublicKey}, test_utils::K...
( &self, universe: &mut AccountUniverse, ) -> (SignedTransaction, (TransactionStatus, u64)) { let sender = universe.pick(self.sender).1; let seq = if sender.sequence_number == self.seq { self.seq + 1 } else { self.seq }; let txn = emp...
apply
identifier_name
bad_transaction.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_universe::{AUTransactionGen, AccountUniverse}, common_transactions::{empty_txn, EMPTY_SCRIPT}, gas_costs, }; use diem_crypto::{ ed25519::{self, Ed25519PrivateKey, Ed25519PublicKey}, test_utils::K...
; let txn = empty_txn( sender.account(), seq, gas_costs::TXN_RESERVED, 0, XUS_NAME.to_string(), ); ( txn, ( if seq >= sender.sequence_number { TransactionStatus::Discard(Stat...
{ self.seq }
conditional_block
bad_transaction.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_universe::{AUTransactionGen, AccountUniverse}, common_transactions::{empty_txn, EMPTY_SCRIPT}, gas_costs, }; use diem_crypto::{ ed25519::{self, Ed25519PrivateKey, Ed25519PublicKey}, test_utils::K...
{ prop_oneof![ 1 => any_with::<SequenceNumberMismatchGen>((0, 10_000)).prop_map(SequenceNumberMismatchGen::arced), 1 => any_with::<InvalidAuthkeyGen>(()).prop_map(InvalidAuthkeyGen::arced), 1 => any_with::<InsufficientBalanceGen>((1, 20_000)).prop_map(InsufficientBalanceGen::arced), ] }
identifier_body
bad_transaction.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_universe::{AUTransactionGen, AccountUniverse}, common_transactions::{empty_txn, EMPTY_SCRIPT}, gas_costs, }; use diem_crypto::{ ed25519::{self, Ed25519PrivateKey, Ed25519PublicKey}, test_utils::K...
XUS_NAME.to_string(), ); ( txn, ( if seq >= sender.sequence_number { TransactionStatus::Discard(StatusCode::SEQUENCE_NUMBER_TOO_NEW) } else { TransactionStatus::Discard(StatusCode::SEQUENCE_NUMBE...
random_line_split
libc_heap.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...
(ptr: *mut u8, size: uint) -> *mut u8 { // `realloc(ptr, 0)` may allocate, but it may also return a null pointer // http://pubs.opengroup.org/onlinepubs/9699919799/functions/realloc.html if size == 0 { free(ptr as *mut c_void); null_mut() } else { let p = realloc(ptr as *mut c_vo...
realloc_raw
identifier_name
libc_heap.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...
/// A wrapper around libc::realloc, aborting on out-of-memory. #[inline] pub unsafe fn realloc_raw(ptr: *mut u8, size: uint) -> *mut u8 { // `realloc(ptr, 0)` may allocate, but it may also return a null pointer // http://pubs.opengroup.org/onlinepubs/9699919799/functions/realloc.html if size == 0 { ...
{ // `malloc(0)` may allocate, but it may also return a null pointer // http://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html if size == 0 { null_mut() } else { let p = malloc(size as size_t); if p.is_null() { ::oom(); } p as *mut u8 ...
identifier_body
libc_heap.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...
}
}
random_line_split
libc_heap.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...
p as *mut u8 } }
{ ::oom(); }
conditional_block
lib.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/. */ #![feature(int_uint)] extern crate devtools_traits; extern crate geom; extern crate libc; extern crate msg; exter...
{ pub containing_pipeline_id: PipelineId, pub new_pipeline_id: PipelineId, pub subpage_id: SubpageId, pub layout_chan: Box<Any+Send>, // opaque reference to a LayoutChannel pub load_data: LoadData, } /// Messages sent from the constellation to the script task pub enum ConstellationControlMsg { ...
NewLayoutInfo
identifier_name
lib.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/. */ #![feature(int_uint)] extern crate devtools_traits; extern crate geom; extern crate libc; extern crate msg; exter...
/// The address of a node. Layout sends these back. They must be validated via /// `from_untrusted_node_address` before they can be used, because we do not trust layout. #[allow(raw_pointer_derive)] #[derive(Copy, Clone)] pub struct UntrustedNodeAddress(pub *const c_void); unsafe impl Send for UntrustedNodeAddress {} ...
use std::any::Any; use std::sync::mpsc::{Sender, Receiver}; use geom::point::Point2D; use geom::rect::Rect;
random_line_split
std-sync-right-kind-impls.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 ...
() { assert_both::<sync::StaticMutex>(); assert_both::<sync::StaticCondvar>(); assert_both::<sync::StaticRwLock>(); assert_both::<sync::Mutex<()>>(); assert_both::<sync::Condvar>(); assert_both::<sync::RwLock<()>>(); assert_both::<sync::Semaphore>(); assert_both::<sync::Barrier>(); a...
main
identifier_name
std-sync-right-kind-impls.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 ...
{ assert_both::<sync::StaticMutex>(); assert_both::<sync::StaticCondvar>(); assert_both::<sync::StaticRwLock>(); assert_both::<sync::Mutex<()>>(); assert_both::<sync::Condvar>(); assert_both::<sync::RwLock<()>>(); assert_both::<sync::Semaphore>(); assert_both::<sync::Barrier>(); asse...
identifier_body
std-sync-right-kind-impls.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 assert_both<T: Sync + Send>() {} fn main() { assert_both::<sync::StaticMutex>(); assert_both::<sync::StaticCondvar>(); assert_both::<sync::StaticRwLock>(); assert_both::<sync::Mutex<()>>(); assert_both::<sync::Condvar>(); assert_both::<sync::RwLock<()>>(); assert_both::<sync::Semaphore>...
use std::sync;
random_line_split
arena_storage_pool.rs
// Implements http://rosettacode.org/wiki/Arena_storage_pool #![feature(rustc_private)] extern crate arena;
use arena::TypedArena; #[cfg(not(test))] fn main() { // Memory is allocated using the default allocator (currently jemalloc). The memory is // allocated in chunks, and when one chunk is full another is allocated. This ensures that // references to an arena don't become invalid when the original chunk run...
random_line_split
arena_storage_pool.rs
// Implements http://rosettacode.org/wiki/Arena_storage_pool #![feature(rustc_private)] extern crate arena; use arena::TypedArena; #[cfg(not(test))] fn
() { // Memory is allocated using the default allocator (currently jemalloc). The memory is // allocated in chunks, and when one chunk is full another is allocated. This ensures that // references to an arena don't become invalid when the original chunk runs out of space. The // chunk size is configu...
main
identifier_name
arena_storage_pool.rs
// Implements http://rosettacode.org/wiki/Arena_storage_pool #![feature(rustc_private)] extern crate arena; use arena::TypedArena; #[cfg(not(test))] fn main()
{ // Memory is allocated using the default allocator (currently jemalloc). The memory is // allocated in chunks, and when one chunk is full another is allocated. This ensures that // references to an arena don't become invalid when the original chunk runs out of space. The // chunk size is configurab...
identifier_body
common.rs
pub const SYS_DEBUG: usize = 0; // Linux compatible pub const SYS_BRK: usize = 45; pub const SYS_CHDIR: usize = 12; pub const SYS_CLOSE: usize = 6; pub const SYS_CLONE: usize = 120; pub const CLONE_VM: usize = 0x100; pub const CLONE_FS: usize = 0x200; pub const CLONE_FILES: usize = 0x400; pub const SYS_CLO...
{ pub tv_sec: i64, pub tv_nsec: i32, }
TimeSpec
identifier_name
common.rs
pub const SYS_DEBUG: usize = 0; // Linux compatible pub const SYS_BRK: usize = 45; pub const SYS_CHDIR: usize = 12;
pub const SYS_CLOCK_GETTIME: usize = 265; pub const CLOCK_REALTIME: usize = 0; pub const CLOCK_MONOTONIC: usize = 1; pub const SYS_DUP: usize = 41; pub const SYS_EXECVE: usize = 11; pub const SYS_EXIT: usize = 1; pub const SYS_FPATH: usize = 3001; pub const SYS_FSTAT: usize = 28; pub const SYS_FSYNC: usize = 11...
pub const SYS_CLOSE: usize = 6; pub const SYS_CLONE: usize = 120; pub const CLONE_VM: usize = 0x100; pub const CLONE_FS: usize = 0x200; pub const CLONE_FILES: usize = 0x400;
random_line_split
decoder.rs
extern crate jpeg_decoder; use std::io::Read; use color::{self, ColorType}; use image::{DecodingResult, ImageDecoder, ImageError, ImageResult}; /// JPEG decoder pub struct JPEGDecoder<R> { decoder: jpeg_decoder::Decoder<R>, metadata: Option<jpeg_decoder::ImageInfo>, } impl<R: Read> JPEGDecoder<R> { /// ...
Ok(DecodingResult::U8(data)) } } fn cmyk_to_rgb(input: &[u8]) -> Vec<u8> { let size = input.len() - input.len() / 4; let mut output = Vec::with_capacity(size); for pixel in input.chunks(4) { let c = pixel[0] as f32 / 255.0; let m = pixel[1] as f32 / 255.0; let y = pixe...
let mut data = try!(self.decoder.decode()); data = match self.decoder.info().unwrap().pixel_format { jpeg_decoder::PixelFormat::CMYK32 => cmyk_to_rgb(&data), _ => data, };
random_line_split
decoder.rs
extern crate jpeg_decoder; use std::io::Read; use color::{self, ColorType}; use image::{DecodingResult, ImageDecoder, ImageError, ImageResult}; /// JPEG decoder pub struct JPEGDecoder<R> { decoder: jpeg_decoder::Decoder<R>, metadata: Option<jpeg_decoder::ImageInfo>, } impl<R: Read> JPEGDecoder<R> { /// ...
fn read_scanline(&mut self, _buf: &mut [u8]) -> ImageResult<u32> { unimplemented!(); } fn read_image(&mut self) -> ImageResult<DecodingResult> { let mut data = try!(self.decoder.decode()); data = match self.decoder.info().unwrap().pixel_format { jpeg_decoder::PixelForm...
{ let metadata = try!(self.metadata()); Ok(metadata.width as usize * color::num_components(metadata.pixel_format.into())) }
identifier_body
decoder.rs
extern crate jpeg_decoder; use std::io::Read; use color::{self, ColorType}; use image::{DecodingResult, ImageDecoder, ImageError, ImageResult}; /// JPEG decoder pub struct JPEGDecoder<R> { decoder: jpeg_decoder::Decoder<R>, metadata: Option<jpeg_decoder::ImageInfo>, } impl<R: Read> JPEGDecoder<R> { /// ...
(&mut self) -> ImageResult<usize> { let metadata = try!(self.metadata()); Ok(metadata.width as usize * color::num_components(metadata.pixel_format.into())) } fn read_scanline(&mut self, _buf: &mut [u8]) -> ImageResult<u32> { unimplemented!(); } fn read_image(&mut self) -> Image...
row_len
identifier_name
object-safety-generics.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 ...
fn make_quux_explicit<T:Quux>(t: &T) -> &Quux { t as &Quux } fn main() { }
{ t }
identifier_body
object-safety-generics.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 ...
fn main() { }
random_line_split
object-safety-generics.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 ...
<T:Quux>(t: &T) -> &Quux { t } fn make_quux_explicit<T:Quux>(t: &T) -> &Quux { t as &Quux } fn main() { }
make_quux
identifier_name
game.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including wi...
(&self) -> ShapeManagerRef { self.shape_manager.clone() } pub fn shape_metadata(&self) -> ShapeMetadataStoreRef { self.shape_metadata.clone() } pub fn empires_db(&self) -> EmpiresDbRef { self.empires.clone() } pub fn media(&self) -> MediaRef { self.media.clone(...
shape_manager
identifier_name
game.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including wi...
} } fn update(&mut self, time_step: Fixed) -> bool { let mut pop_required = false; let result = if let Some(state) = self.current_state() { if!state.update(time_step) { pop_required = true; false } else { true ...
state.stop(); } if !self.states.is_empty() { self.states.pop();
random_line_split
game.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including wi...
pub fn shape_manager(&self) -> ShapeManagerRef { self.shape_manager.clone() } pub fn shape_metadata(&self) -> ShapeMetadataStoreRef { self.shape_metadata.clone() } pub fn empires_db(&self) -> EmpiresDbRef { self.empires.clone() } pub fn media(&self) -> MediaRef {...
{ self.drs_manager.clone() }
identifier_body
game.rs
// OpenAOE: An open source reimplementation of Age of Empires (1997) // Copyright (c) 2016 Kevin Fuller // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including wi...
} fn update(&mut self, time_step: Fixed) -> bool { let mut pop_required = false; let result = if let Some(state) = self.current_state() { if!state.update(time_step) { pop_required = true; false } else { true } ...
{ self.states.pop(); }
conditional_block
regions-static-closure.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct closure_box<'a> { cl: 'a ||, } fn box_it<'r>(x: 'r ||) -> closure_box<'r> { ...
// 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
random_line_split
regions-static-closure.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let cl_box = box_it(|| println!("Hello, world!")); call_static_closure(cl_box); }
main
identifier_name
lib.rs
#![feature(unboxed_closures)] extern crate libc; macro_rules! assert_enum { (@as_expr $e:expr) => {$e}; (@as_pat $p:pat) => {$p}; ($left:expr, $($right:tt)*) => ( { match &($left) { assert_enum!(@as_pat &$($right)*(..)) => {}, _ => { ...
; #[macro_export] macro_rules! push { ($cxt:expr, $($arg:expr),*) => ( $( $cxt.push($arg); )* ) }
nil
identifier_name
lib.rs
#![feature(unboxed_closures)] extern crate libc; macro_rules! assert_enum { (@as_expr $e:expr) => {$e}; (@as_pat $p:pat) => {$p}; ($left:expr, $($right:tt)*) => ( { match &($left) { assert_enum!(@as_pat &$($right)*(..)) => {}, _ => { ...
pub use context::*; pub use collections::*; pub use value::*; pub use borrow::*; pub use function::*; pub struct nil; #[macro_export] macro_rules! push { ($cxt:expr, $($arg:expr),*) => ( $( $cxt.push($arg); )* ) }
mod borrow; mod function;
random_line_split
issue-50706.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 ...
match stat { Stats::A => Some(Stats::A), _ => None, } } } fn main() {}
random_line_split
issue-50706.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 ...
; #[derive(PartialEq, Eq)] pub struct StatVariant { pub id: u8, _priv: (), } #[derive(PartialEq, Eq)] pub struct Stat { pub variant: StatVariant, pub index: usize, _priv: (), } impl Stats { pub const TEST: StatVariant = StatVariant{id: 0, _priv: (),}; #[allow(non_upper_case_globals)] ...
Stats
identifier_name
main.rs
#![cfg_attr(feature = "nightly-testing", feature(plugin))] #![cfg_attr(feature = "nightly-testing", plugin(clippy))] #[macro_use] extern crate clap; extern crate hoedown; extern crate rayon; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate toml; extern crate inflector; ...
if let Some(matches) = matches.subcommand_matches("generate") { let services_config_path = matches.value_of("services_config").unwrap(); let service_configs = ServiceConfig::load_all(services_config_path).expect("Unable to read services configuration file."); let out_dir = Path::new(match...
{ let services_config_path = matches.value_of("services_config").unwrap(); let service_configs = ServiceConfig::load_all(services_config_path).expect("Unable to read services configuration file."); commands::check::check(service_configs); }
conditional_block
main.rs
#![cfg_attr(feature = "nightly-testing", feature(plugin))] #![cfg_attr(feature = "nightly-testing", plugin(clippy))] #[macro_use] extern crate clap; extern crate hoedown; extern crate rayon; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate toml; extern crate inflector; ...
use clap::{Arg, App, SubCommand}; use service::Service; use config::ServiceConfig; use botocore::ServiceDefinition; fn main() { let matches = App::new("Rusoto Service Crate Generator") .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .subcommand(SubComm...
mod util; mod doco; use std::path::Path;
random_line_split
main.rs
#![cfg_attr(feature = "nightly-testing", feature(plugin))] #![cfg_attr(feature = "nightly-testing", plugin(clippy))] #[macro_use] extern crate clap; extern crate hoedown; extern crate rayon; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate toml; extern crate inflector; ...
.get_matches(); if let Some(matches) = matches.subcommand_matches("check") { let services_config_path = matches.value_of("services_config").unwrap(); let service_configs = ServiceConfig::load_all(services_config_path).expect("Unable to read services configuration file."); commands::...
{ let matches = App::new("Rusoto Service Crate Generator") .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .subcommand(SubCommand::with_name("check") .arg(Arg::with_name("services_config") .long("config") ....
identifier_body
main.rs
#![cfg_attr(feature = "nightly-testing", feature(plugin))] #![cfg_attr(feature = "nightly-testing", plugin(clippy))] #[macro_use] extern crate clap; extern crate hoedown; extern crate rayon; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate toml; extern crate inflector; ...
() { let matches = App::new("Rusoto Service Crate Generator") .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .subcommand(SubCommand::with_name("check") .arg(Arg::with_name("services_config") .long("config") .shor...
main
identifier_name