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
compositing.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/. */ #![crate_id = "github.com/mozilla/servo#compositing:0.1"] #![crate_type = "lib"] #![crate_type = "dylib"] #![crate...
#[phase(plugin, link)] extern crate log; extern crate debug; extern crate alert; extern crate azure; extern crate geom; extern crate gfx; #[cfg(not(target_os="android"))] extern crate glfw; #[cfg(target_os="android")] extern crate glut; extern crate layers; extern crate layout; extern crate opengles; extern crate png...
random_line_split
lib.rs
use std::path::Path; use binary::{ async_trait::async_trait, binary_clone_box, eyre::{bail, Result}, }; pub use binary::{Binary, BinaryInstallation, BinaryTrait}; mod versions; pub struct NodeBinary; #[async_trait] impl BinaryTrait for NodeBinary { #[rustfmt::skip] fn spec(&self) -> Binary { ...
(&self, _os: &str) -> Result<Vec<String>> { Ok(self.versions_update_maybe( versions::VERSIONS, self.versions_github_releases("nodejs", "node").await, )) } async fn install_version( &self, version: &str, dest: &Path, os: &str, arch:...
versions
identifier_name
lib.rs
use std::path::Path; use binary::{ async_trait::async_trait, binary_clone_box, eyre::{bail, Result}, }; pub use binary::{Binary, BinaryInstallation, BinaryTrait}; mod versions; pub struct NodeBinary; #[async_trait] impl BinaryTrait for NodeBinary { #[rustfmt::skip] fn spec(&self) -> Binary
binary_clone_box!(); async fn versions(&self, _os: &str) -> Result<Vec<String>> { Ok(self.versions_update_maybe( versions::VERSIONS, self.versions_github_releases("nodejs", "node").await, )) } async fn install_version( &self, version: &str, ...
{ Binary::new( "node", &[], &["C:\\Program Files\\nodejs"] ) }
identifier_body
lib.rs
use std::path::Path; use binary::{ async_trait::async_trait, binary_clone_box, eyre::{bail, Result}, }; pub use binary::{Binary, BinaryInstallation, BinaryTrait}; mod versions; pub struct NodeBinary; #[async_trait] impl BinaryTrait for NodeBinary { #[rustfmt::skip] fn spec(&self) -> Binary { ...
arch: &str, ) -> Result<()> { let url = format!( "https://nodejs.org/dist/v{version}/node-v{version}-", version = version ) + match os { "macos" => match arch { "arm" => "darwin-arm64.tar.gz", _ => "darwin-x64.tar.gz", ...
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 ...
//! details on the API, please see the documentation for the `Regex` type. //! //! # First example: find a date //! //! General use of regular expressions in this package involves compiling an //! expression and then using it to search, split or replace text. For example, //! to confirm that some text resembles a date:...
//! has excellent worst case performance. The specific syntax supported is //! documented further down. //! //! This crate's documentation provides some simple examples, describes Unicode //! support and exhaustively lists the supported syntax. For more specific
random_line_split
ident.rs
// Copyright 2013-2014 The Algebra 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...
use ops::{Op, Additive, Multiplicative}; /// A type that is equipped with identity. pub trait Identity<O: Op> { /// The identity element. fn id() -> Self; } /// The identity element. pub fn id<T: Identity<O>, O: Op>(_: O) -> T { Identity::id() } impl_ident!(Additive; 0; u8, u16, u32, u64, i8, i16, i32, ...
//! Identities for binary operators.
random_line_split
ident.rs
// Copyright 2013-2014 The Algebra 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...
<T: Identity<O>, O: Op>(_: O) -> T { Identity::id() } impl_ident!(Additive; 0; u8, u16, u32, u64, i8, i16, i32, i64); impl_ident!(Additive; 0.; f32, f64); impl_ident!(Multiplicative; 1; u8, u16, u32, u64, i8, i16, i32, i64); impl_ident!(Multiplicative; 1.; f32, f64);
id
identifier_name
ident.rs
// Copyright 2013-2014 The Algebra 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...
impl_ident!(Additive; 0; u8, u16, u32, u64, i8, i16, i32, i64); impl_ident!(Additive; 0.; f32, f64); impl_ident!(Multiplicative; 1; u8, u16, u32, u64, i8, i16, i32, i64); impl_ident!(Multiplicative; 1.; f32, f64);
{ Identity::id() }
identifier_body
dircolors.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // (c) Mitchell Mebane <mitchell.mebane@gmail.com> // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (ToDO) clr...
(&self, pat: &str) -> bool { pat.parse::<glob::Pattern>().unwrap().matches(self) } } #[derive(PartialEq)] enum ParseState { Global, Matched, Continue, Pass, } use std::collections::HashMap; use uucore::{format_usage, InvalidEncodingHandling}; fn parse<T>(lines: T, fmt: &OutputFmt, fp: &str...
fnmatch
identifier_name
dircolors.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // (c) Mitchell Mebane <mitchell.mebane@gmail.com> // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (ToDO) clr...
table.insert("fifo", "pi"); table.insert("pipe", "pi"); table.insert("sock", "so"); table.insert("blk", "bd"); table.insert("block", "bd"); table.insert("chr", "cd"); table.insert("char", "cd"); table.insert("door", "do"); table.insert("exec", "ex"); table.insert("left", "lc"); ...
{ // 1440 > $(dircolors | wc -m) let mut result = String::with_capacity(1440); match fmt { OutputFmt::Shell => result.push_str("LS_COLORS='"), OutputFmt::CShell => result.push_str("setenv LS_COLORS '"), _ => unreachable!(), } let mut table: HashMap<&str, &str> = HashMap::wit...
identifier_body
dircolors.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // (c) Mitchell Mebane <mitchell.mebane@gmail.com> // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (ToDO) clr...
#[derive(PartialEq)] enum ParseState { Global, Matched, Continue, Pass, } use std::collections::HashMap; use uucore::{format_usage, InvalidEncodingHandling}; fn parse<T>(lines: T, fmt: &OutputFmt, fp: &str) -> Result<String, String> where T: IntoIterator, T::Item: Borrow<str>, { // 1440 > ...
fn fnmatch(&self, pat: &str) -> bool { pat.parse::<glob::Pattern>().unwrap().matches(self) } }
random_line_split
dircolors.rs
// This file is part of the uutils coreutils package. // // (c) Jian Zeng <anonymousknight96@gmail.com> // (c) Mitchell Mebane <mitchell.mebane@gmail.com> // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (ToDO) clr...
} else { if state == ParseState::Matched { // prevent subsequent mismatched TERM from // cancelling the input state = ParseState::Continue; } if state!= ParseState::Pass { if key.starts_with('.') { ...
{ state = ParseState::Pass; }
conditional_block
oauth.rs
extern crate rocket; use rocket::request::Form; use rocket::response::Redirect; use rocket_contrib::Json; use url::Url; #[derive(FromForm, Debug)] struct AuthForm { response_type: Option<String>, client_id: Option<String>, redirect_uri: Option<String>, scope: Option<String>, state: Option<String>,...
access_token: String, refresh_token: String, expires_in: i64, } #[post("/token", data = "<data>")] fn token(data: Form<TokenForm>) -> Json<AuthResponse> { debug!("token: {:?}", data.get()); Json(AuthResponse { token_type: "bearer".to_string(), access_token: "xxx".to_string(), ...
struct AuthResponse { token_type: String,
random_line_split
oauth.rs
extern crate rocket; use rocket::request::Form; use rocket::response::Redirect; use rocket_contrib::Json; use url::Url; #[derive(FromForm, Debug)] struct AuthForm { response_type: Option<String>, client_id: Option<String>, redirect_uri: Option<String>, scope: Option<String>, state: Option<String>,...
(data: AuthForm) -> Redirect { debug!("auth data: {:?}", data); let s = match data.state { Some(x) => x, _ => "".to_string(), }; let u = match data.redirect_uri { Some(x) => { let mut url = Url::parse(&x).unwrap(); url.set_query(Some(&format!("code=123&s...
auth
identifier_name
oauth.rs
extern crate rocket; use rocket::request::Form; use rocket::response::Redirect; use rocket_contrib::Json; use url::Url; #[derive(FromForm, Debug)] struct AuthForm { response_type: Option<String>, client_id: Option<String>, redirect_uri: Option<String>, scope: Option<String>, state: Option<String>,...
#[derive(FromForm, Debug)] struct TokenForm { grant_type: String, code: String, redirect_uri: String, client_id: String, client_secret: String, } #[derive(Serialize)] struct AuthResponse { token_type: String, access_token: String, refresh_token: String, expires_in: i64, } #[post(...
{ debug!("auth data: {:?}", data); let s = match data.state { Some(x) => x, _ => "".to_string(), }; let u = match data.redirect_uri { Some(x) => { let mut url = Url::parse(&x).unwrap(); url.set_query(Some(&format!("code=123&state={}", s))); u...
identifier_body
lib.rs
//! This crate provides a library for Halo: Combat Evolved cache file parsing and manipulation. pub mod tag; pub mod map; pub mod resource_map; extern crate encoding; use self::encoding::{Encoding, DecoderTrap, EncoderTrap}; use self::encoding::all::ISO_8859_1; // This function will create an ISO 8859-1 vec from a st...
{ length + (4 - (length % 4)) % 4 }
identifier_body
lib.rs
//! This crate provides a library for Halo: Combat Evolved cache file parsing and manipulation. pub mod tag; pub mod map; pub mod resource_map; extern crate encoding; use self::encoding::{Encoding, DecoderTrap, EncoderTrap}; use self::encoding::all::ISO_8859_1; // This function will create an ISO 8859-1 vec from a st...
(string : &str) -> Result<Vec<u8>,&'static str> { match ISO_8859_1.encode(&string, EncoderTrap::Strict) { Ok(n) => Ok(n), Err(_) => Err("failed to encode string") } } // This function will create a string from an ISO 8859-1 string in a slice. fn string_from_slice(slice : &[u8]) -> Result<String...
encode_latin1_string
identifier_name
lib.rs
//! This crate provides a library for Halo: Combat Evolved cache file parsing and manipulation. pub mod tag; pub mod map; pub mod resource_map; extern crate encoding; use self::encoding::{Encoding, DecoderTrap, EncoderTrap}; use self::encoding::all::ISO_8859_1;
// This function will create an ISO 8859-1 vec from a string fn encode_latin1_string(string : &str) -> Result<Vec<u8>,&'static str> { match ISO_8859_1.encode(&string, EncoderTrap::Strict) { Ok(n) => Ok(n), Err(_) => Err("failed to encode string") } } // This function will create a string from ...
random_line_split
build.rs
use std::borrow::Borrow; use std::env; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use std::process::{self, Command}; fn run_command_or_fail<P, S>(dir: &str, cmd: P, args: &[S]) where P: AsRef<Path>, S: Borrow<str> + AsRef<OsStr>, { let cmd = cmd.as_ref(); let cmd = if cmd.components().count()...
config .define("RDKAFKA_BUILD_STATIC", "1") .define("RDKAFKA_BUILD_TESTS", "0") .define("RDKAFKA_BUILD_EXAMPLES", "0") // CMAKE_INSTALL_LIBDIR is inferred as "lib64" on some platforms, but we // want a stable location that we can add to the linker search path. // Since ...
let mut config = cmake::Config::new("librdkafka");
random_line_split
build.rs
use std::borrow::Borrow; use std::env; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use std::process::{self, Command}; fn run_command_or_fail<P, S>(dir: &str, cmd: P, args: &[S]) where P: AsRef<Path>, S: Borrow<str> + AsRef<OsStr>, { let cmd = cmd.as_ref(); let cmd = if cmd.components().count()...
} else { configure_flags.push("--disable-lz4-ext".into()); } env::set_var("CFLAGS", cflags.join(" ")); env::set_var("LDFLAGS", ldflags.join(" ")); let out_dir = env::var("OUT_DIR").expect("OUT_DIR missing"); if!Path::new(&out_dir).join("LICENSE").exists() { // We're not allow...
{ cflags.push(format!("-I{}/include", lz4_root)); ldflags.push(format!("-L{}", lz4_root)); }
conditional_block
build.rs
use std::borrow::Borrow; use std::env; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use std::process::{self, Command}; fn run_command_or_fail<P, S>(dir: &str, cmd: P, args: &[S]) where P: AsRef<Path>, S: Borrow<str> + AsRef<OsStr>, { let cmd = cmd.as_ref(); let cmd = if cmd.components().count()...
() { let mut configure_flags: Vec<String> = Vec::new(); let mut cflags = Vec::new(); if let Ok(var) = env::var("CFLAGS") { cflags.push(var); } let mut ldflags = Vec::new(); if let Ok(var) = env::var("LDFLAGS") { ldflags.push(var); } if env::var("CARGO_FEATURE_SSL").is_...
build_librdkafka
identifier_name
build.rs
use std::borrow::Borrow; use std::env; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use std::process::{self, Command}; fn run_command_or_fail<P, S>(dir: &str, cmd: P, args: &[S]) where P: AsRef<Path>, S: Borrow<str> + AsRef<OsStr>, { let cmd = cmd.as_ref(); let cmd = if cmd.components().count()...
config.define("WITH_ZLIB", "0"); } if env::var("CARGO_FEATURE_SSL").is_ok() { config.define("WITH_SSL", "1"); config.register_dep("openssl"); } else { config.define("WITH_SSL", "0"); } if env::var("CARGO_FEATURE_GSSAPI").is_ok() { config.define("WITH_SASL", ...
{ let mut config = cmake::Config::new("librdkafka"); config .define("RDKAFKA_BUILD_STATIC", "1") .define("RDKAFKA_BUILD_TESTS", "0") .define("RDKAFKA_BUILD_EXAMPLES", "0") // CMAKE_INSTALL_LIBDIR is inferred as "lib64" on some platforms, but we // want a stable location ...
identifier_body
x86_64.rs
#[repr(C)] #[derive(Copy)] pub struct
{ pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut ::char_t, pub gl_offs: ::size_t, pub gl_flags: ::int_t, pub gl_closedir: ::std::option::Option<extern fn (arg1: *mut ::void_t)>, pub gl_readdir: ::std::option::Option<extern fn(arg1: *mut ::void_t) ...
glob_t
identifier_name
x86_64.rs
#[repr(C)] #[derive(Copy)] pub struct glob_t { pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut ::char_t, pub gl_offs: ::size_t, pub gl_flags: ::int_t, pub gl_closedir: ::std::option::Option<extern fn (arg1: *mut ::void_t)>, pub gl_readdir: ::std::op...
pub const GLOB_ERR: ::int_t = 1; pub const GLOB_MARK: ::int_t = 2; pub const GLOB_NOCHECK: ::int_t = 16; pub const GLOB_NOESCAPE: ::int_t = 64; pub const GLOB_NOSORT: ::int_t = 4; pub const GLOB_ABORTED: ::int_t = 2; pub const GLOB_NOMATCH: ::int_t = 3; pub const GLOB_NOSPACE: ::int_t = 1;
pub const GLOB_DOOFFS: ::int_t = 8;
random_line_split
settings_stack.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::js::{JS, Root}; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use j...
} } /// Returns the ["incumbent"] global object. /// /// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent pub fn incumbent_global() -> Option<Root<GlobalScope>> { // https://html.spec.whatwg.org/multipage/#incumbent-settings-object // Step 1, 3: See what the JS engine has to say. If we've ...
let cx = Runtime::get(); assert!(!cx.is_null()); UnhideScriptedCaller(cx); }
random_line_split
settings_stack.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::js::{JS, Root}; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use j...
(tracer: *mut JSTracer) { STACK.with(|stack| { stack.borrow().trace(tracer); }) } /// RAII struct that pushes and pops entries from the script settings stack. pub struct AutoEntryScript { global: usize, } impl AutoEntryScript { /// https://html.spec.whatwg.org/multipage/#prepare-to-run-script ...
trace
identifier_name
settings_stack.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::js::{JS, Root}; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use j...
/// RAII struct that pushes and pops entries from the script settings stack. pub struct AutoIncumbentScript { global: usize, } impl AutoIncumbentScript { /// https://html.spec.whatwg.org/multipage/#prepare-to-run-a-callback pub fn new(global: &GlobalScope) -> Self { // Step 2-3. unsafe { ...
{ STACK.with(|stack| { stack.borrow() .iter() .rev() .find(|entry| entry.kind == StackEntryKind::Entry) .map(|entry| Root::from_ref(&*entry.global)) }).unwrap() }
identifier_body
settings_stack.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::js::{JS, Root}; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use j...
} // Step 2: nothing from the JS engine. Let's use whatever's on the explicit stack. STACK.with(|stack| { stack.borrow() .last() .map(|entry| Root::from_ref(&*entry.global)) }) }
{ return Some(GlobalScope::from_object(global)); }
conditional_block
thread.rs
/* Waylos, a kernel built in rust Copyright (C) 2015 Waylon Cude This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later ve...
(paddr: u64) -> u64{ unsafe { let page_addr = paddr & 0xFFFFFFFFF000; (*(page_addr as *mut memory::PageTable)).set_entry(511,*(0x100000 as *const u64)); memory::create_page(0xFFFFF00000000000,page_addr); loop{} memory::create_page(0xFFFFF00000003000,page_addr); memory::create_page(0xFFFFF000...
create_thread_memory_area
identifier_name
thread.rs
/* Waylos, a kernel built in rust Copyright (C) 2015 Waylon Cude This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later ve...
(*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id = 0; } else { (*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id += 1; } } //write!(SCREEN,"PID {}\n",(*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id); ...
(*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id += 1; while (*(THREAD_TABLE_ADDR as *mut Thread_Table)).threads[(*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id].enabled != 1 { if (*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id >= (*(THREAD_TABLE_A...
random_line_split
thread.rs
/* Waylos, a kernel built in rust Copyright (C) 2015 Waylon Cude This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later ve...
} //write!(SCREEN,"PID {}\n",(*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id); (*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_page_table = (*(THREAD_TABLE_ADDR as *const Thread_Table)).threads[(*(THREAD_TABLE_ADDR as *const Thread_Table)).current_process_id].page_addr; ...
{ (*(THREAD_TABLE_ADDR as *mut Thread_Table)).current_process_id += 1; }
conditional_block
response.rs
//! Client Responses use std::num::FromPrimitive; use std::io::{BufferedReader, IoResult}; use header; use header::common::{ContentLength, TransferEncoding}; use header::common::transfer_encoding::Encoding::Chunked; use net::{NetworkStream, HttpStream}; use http::{read_status_line, HttpReader, RawStatus}; use http::Ht...
/// Unwraps the Request to return the NetworkStream underneath. pub fn unwrap(self) -> Box<NetworkStream + Send> { self.body.unwrap().unwrap() } } impl Reader for Response { #[inline] fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.body.read(buf) } } #[cfg(test)] ...
{ &self.status_raw }
identifier_body
response.rs
//! Client Responses use std::num::FromPrimitive; use std::io::{BufferedReader, IoResult}; use header; use header::common::{ContentLength, TransferEncoding}; use header::common::transfer_encoding::Encoding::Chunked; use net::{NetworkStream, HttpStream}; use http::{read_status_line, HttpReader, RawStatus}; use http::Ht...
else if headers.has::<ContentLength>() { match headers.get::<ContentLength>() { Some(&ContentLength(len)) => SizedReader(stream, len), None => unreachable!() } } else { debug!("neither Transfer-Encoding nor Content-Length"); EofRea...
{ match headers.get::<TransferEncoding>() { Some(&TransferEncoding(ref codings)) => { if codings.len() > 1 { debug!("TODO: #2 handle other codings: {}", codings); }; if codings.contains(&Chunked) { ...
conditional_block
response.rs
//! Client Responses use std::num::FromPrimitive; use std::io::{BufferedReader, IoResult}; use header; use header::common::{ContentLength, TransferEncoding}; use header::common::transfer_encoding::Encoding::Chunked; use net::{NetworkStream, HttpStream}; use http::{read_status_line, HttpReader, RawStatus}; use http::Ht...
(&self) -> &RawStatus { &self.status_raw } /// Unwraps the Request to return the NetworkStream underneath. pub fn unwrap(self) -> Box<NetworkStream + Send> { self.body.unwrap().unwrap() } } impl Reader for Response { #[inline] fn read(&mut self, buf: &mut [u8]) -> IoResult<uint...
status_raw
identifier_name
response.rs
//! Client Responses use std::num::FromPrimitive; use std::io::{BufferedReader, IoResult}; use header; use header::common::{ContentLength, TransferEncoding}; use header::common::transfer_encoding::Encoding::Chunked; use net::{NetworkStream, HttpStream}; use http::{read_status_line, HttpReader, RawStatus}; use http::Ht...
/// A response for a client request to a remote server. pub struct Response<S = HttpStream> { /// The status from the server. pub status: status::StatusCode, /// The headers from the server. pub headers: header::Headers, /// The HTTP version of this response from the server. pub version: version...
use HttpResult; use HttpError::HttpStatusError;
random_line_split
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(int); #[deriving(Zero)] struct C(int, int); #[deriving(Zero)] struct D { a: int } #[deriving(Zero)] struct E { a: int, b: int } #[deriving(Zero)] struct Lots { d: u8, e: char, f: f64, g: (f32, char), h: @mut (int, int), i: bool, j: (), } pub fn main() { let lots: Lots = Zero::zero(); ...
B
identifier_name
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ let lots: Lots = Zero::zero(); assert!(lots.is_zero()); }
identifier_body
deriving-zero.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
struct B(int); #[deriving(Zero)] struct C(int, int); #[deriving(Zero)] struct D { a: int } #[deriving(Zero)] struct E { a: int, b: int } #[deriving(Zero)] struct Lots { d: u8, e: char, f: f64, g: (f32, char), h: @mut (int, int), i: bool, j: (), } pub fn main() { let lots: Lots = Zero::...
#[deriving(Zero)] struct A; #[deriving(Zero)]
random_line_split
bignum.rs
#[cfg(stage0)] fn full_add(self, other: $ty, carry: bool) -> (bool, $ty) { // this cannot overflow, the output is between 0 and 2*2^nbits - 1 // FIXME will LLVM optimize this into ADC or similar??? let (v, carry1) = unsafe { $addfn(self, othe...
} } retsz } let mut ret = [0; $n]; let retsz = if self.size < other.len() { mul_inner(&mut ret, &self.digits(), other) } else { mul_inner(&mut ret, oth...
retsz = i + sz;
random_line_split
shr.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::num::Wrapping; use core::ops::Shr; // macro_rules! sh_impl { // ($t:ty, $f:ty) => ( // #[stable(feature = "rust1", since = "1.0.0")] // impl Shl<$f> for Wrapping<$t> { // type Output = ...
}
{ shr_test!( u8, 0x80, 8, 0x00 ); // panicked at 'shift operation overflowed' }
identifier_body
shr.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::num::Wrapping; use core::ops::Shr; // macro_rules! sh_impl { // ($t:ty, $f:ty) => ( // #[stable(feature = "rust1", since = "1.0.0")] // impl Shl<$f> for Wrapping<$t> { // type Output = ...
() { shr_test!( u8, 0x80, 8, 0x00 ); // panicked at'shift operation overflowed' } }
shr_test2
identifier_name
shr.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::num::Wrapping; use core::ops::Shr; // macro_rules! sh_impl { // ($t:ty, $f:ty) => ( // #[stable(feature = "rust1", since = "1.0.0")] // impl Shl<$f> for Wrapping<$t> { // type Output = ...
shr_test!( u8, 0x80, 1, 0x40 ); shr_test!( u8, 0x80, 2, 0x20 ); shr_test!( u8, 0x80, 3, 0x10 ); shr_test!( u8, 0x80, 4, 0x08 ); shr_test!( u8, 0x80, 5, 0x04 ); shr_test!( u8, 0x80, 6, 0x02 ); shr_test!( u8, 0x80, 7, 0x01 ); } #[test] #[should_panic] fn shr_test2() { shr_test!( u8, 0x80, 8, 0x00...
#[test] fn shr_test1() { shr_test!( u8, 0x80, 0, 0x80 );
random_line_split
struct-order-of-eval-4.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 ...
() { const VAL: u32 = 0x89AB_CDEF; let w = W { wrapped: VAL }; let s = S { _f1: { event(0x01); 23 }, f0: { event(0x02); w }, }; assert_eq!(s.f0.wrapped, VAL); let actual = event_log(); let expect = 0x01_02; assert!(expect == actual, "expect: 0x{:x} actual: 0x{...
main
identifier_name
struct-order-of-eval-4.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 ...
static LOG: AtomicUsize = AtomicUsize::new(0); fn event_log() -> usize { LOG.load(Ordering::SeqCst) } fn event(tag: u8) { let old_log = LOG.load(Ordering::SeqCst); let new_log = (old_log << 8) + tag as usize; LOG.store(new_log, Ordering::SeqCst); }
{ const VAL: u32 = 0x89AB_CDEF; let w = W { wrapped: VAL }; let s = S { _f1: { event(0x01); 23 }, f0: { event(0x02); w }, }; assert_eq!(s.f0.wrapped, VAL); let actual = event_log(); let expect = 0x01_02; assert!(expect == actual, "expect: 0x{:x} actual: 0x{:x}...
identifier_body
struct-order-of-eval-4.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 ...
// even when no Drop-implementations are involved. #![feature(const_fn)] use std::sync::atomic::{Ordering, AtomicUsize}; struct W { wrapped: u32 } struct S { f0: W, _f1: i32 } pub fn main() { const VAL: u32 = 0x89AB_CDEF; let w = W { wrapped: VAL }; let s = S { _f1: { event(0x01); 23 }, ...
// except according to those terms. // Checks that struct-literal expression order-of-eval is as expected
random_line_split
bad_migration_1.rs
use std::fmt::{self, Display}; use postgres::{self, GenericConnection}; use trek::migration::Migration; // this migration is expected to fail when run #[derive(Debug)] pub struct BadMigration1 { name: String } impl BadMigration1 { pub fn new() -> Self { BadMigration1 { name: "BadMigration1"...
(&self, transaction: &GenericConnection) -> postgres::Result<()> { try!(transaction.execute("rargle blargle", &[])); Ok(()) } } impl Display for BadMigration1 { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "{}", self.name) } }
down
identifier_name
bad_migration_1.rs
use std::fmt::{self, Display}; use postgres::{self, GenericConnection}; use trek::migration::Migration; // this migration is expected to fail when run #[derive(Debug)] pub struct BadMigration1 { name: String } impl BadMigration1 { pub fn new() -> Self { BadMigration1 { name: "BadMigration1"...
} impl Display for BadMigration1 { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "{}", self.name) } }
{ try!(transaction.execute("rargle blargle", &[])); Ok(()) }
identifier_body
bad_migration_1.rs
use std::fmt::{self, Display}; use postgres::{self, GenericConnection};
name: String } impl BadMigration1 { pub fn new() -> Self { BadMigration1 { name: "BadMigration1".to_owned(), } } } impl Migration for BadMigration1 { fn up(&self, transaction: &GenericConnection) -> postgres::Result<()> { try!(transaction.execute("rargle blargle", &[]...
use trek::migration::Migration; // this migration is expected to fail when run #[derive(Debug)] pub struct BadMigration1 {
random_line_split
db.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
/// Writes and removes the values into the database and updates the cache. fn extend_with_option_cache<K, T, R>(&mut self, col: Option<u32>, cache: &mut Cache<K, Option<T>>, values: HashMap<K, Option<T>>, policy: CacheUpdatePolicy) where K: Key<T, Target = R> + Hash + Eq, T: rlp::Encodable, R: Deref<Target = [u8...
{ match policy { CacheUpdatePolicy::Overwrite => { for (key, value) in values.into_iter() { self.write(col, &key, &value); cache.insert(key, value); } }, CacheUpdatePolicy::Remove => { for (key, value) in &values { self.write(col, key, value); cache.remove(key); } }, ...
identifier_body
db.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity.
// Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along w...
// Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
random_line_split
db.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
<T, R>(&mut self, col: Option<u32>, key: &Key<T, Target = R>, value: &T) where T: rlp::Encodable, R: Deref<Target = [u8]> { self.put(col, &key.key(), &rlp::encode(value)); } fn delete<T, R>(&mut self, col: Option<u32>, key: &Key<T, Target = R>) where T: rlp::Encodable, R: Deref<Target = [u8]> { self.delete(col, ...
write
identifier_name
icon_set.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use IconSource; use StyleContext; #[cfg(any(feature = "v3_10", feature = "dox"))] use cairo; use ffi; #[cfg(any(feature = "v3_10", feature = "dox"))] use gdk; use gdk_pixbuf; use gli...
#[cfg_attr(feature = "v3_10", deprecated)] pub fn copy(&self) -> Option<IconSet> { unsafe { from_glib_full(ffi::gtk_icon_set_copy(self.to_glib_none().0)) } } #[cfg_attr(feature = "v3_10", deprecated)] pub fn get_sizes(&self) -> Vec<i32> { unsafe { l...
{ unsafe { ffi::gtk_icon_set_add_source(self.to_glib_none().0, source.to_glib_none().0); } }
identifier_body
icon_set.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use IconSource; use StyleContext; #[cfg(any(feature = "v3_10", feature = "dox"))] use cairo; use ffi; #[cfg(any(feature = "v3_10", feature = "dox"))] use gdk; use gdk_pixbuf; use gli...
(&self) -> Vec<i32> { unsafe { let mut sizes = ptr::null_mut(); let mut n_sizes = mem::uninitialized(); ffi::gtk_icon_set_get_sizes(self.to_glib_none().0, &mut sizes, &mut n_sizes); FromGlibContainer::from_glib_full_num(sizes, n_sizes as usize) } } ...
get_sizes
identifier_name
icon_set.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use IconSource; use StyleContext; #[cfg(any(feature = "v3_10", feature = "dox"))] use cairo; use ffi; #[cfg(any(feature = "v3_10", feature = "dox"))] use gdk; use gdk_pixbuf; use gli...
pub struct IconSet(Shared<ffi::GtkIconSet>); match fn { ref => |ptr| ffi::gtk_icon_set_ref(ptr), unref => |ptr| ffi::gtk_icon_set_unref(ptr), get_type => || ffi::gtk_icon_set_get_type(), } } impl IconSet { #[cfg_attr(feature = "v3_10", deprecated)] pub fn new() -> IconSet {...
random_line_split
lexer.rs
use lex::lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to tokenize given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] im...
else { self.errors += 1; println!("Syntax Error at {} : {}.", self.index, self.code.len()); } } } if self.errors > 0 { println!("Total Errors : {}", self.errors); } else { println!("Build Successful!"); ...
{ lexemes.push(self.identifier()); }
conditional_block
lexer.rs
use lex::lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to tokenize given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] im...
(&mut self) -> Lexeme { let mut varname = String::new(); if self.getc().is_alphabetic() { varname.push(self.getc()); self.index += 1; while self.getc().is_alphanumeric() { varname.push(self.getc()); self.index += 1; } ...
identifier
identifier_name
lexer.rs
use lex::lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to tokenize given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] im...
// returns current character fn getc(&self) -> char { self.code.chars().nth(self.index).unwrap() } // skips whitespaces fn skip(&mut self) { while self.whitespaces.contains(self.getc()) { self.index += 1; } } // returns part of remaining slice fn peek...
{ self.errors }
identifier_body
lexer.rs
use lex::lexeme::Lexeme; /*** * Structure Lexer * -> Lexical Analyzer structure used to tokenize given source code */ #[allow(dead_code)] pub struct Lexer<'a>{ index: usize, errors: u32, code: String, whitespaces: String, terminals: Vec<&'a str>, lexemes: Vec<Lexeme> } #[allow(dead_code)] im...
} else if self.getc() == '\"' { lexemes.push(self.string()); } else if self.getc().is_alphabetic() { lexemes.push(self.identifier()); } else { self.errors += 1; println!("Syntax Error at {} : ...
if !construct { if self.getc().is_numeric() { lexemes.push(self.number());
random_line_split
blob.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::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding; use dom::bindings::codegen...
size: size, }) } } // https://w3c.github.io/FileAPI/#blob #[dom_struct] pub struct Blob { reflector_: Reflector, #[ignore_malloc_size_of = "No clear owner"] blob_impl: DomRefCell<BlobImpl>, /// content-type string type_string: String, } impl Blob { #[allow(unrooted_must...
cache: DomRefCell::new(None),
random_line_split
blob.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::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding; use dom::bindings::codegen...
fn is_ascii_printable(string: &str) -> bool { // Step 5.1 in Sec 5.1 of File API spec // https://w3c.github.io/FileAPI/#constructorBlob string.chars().all(|c| c >= '\x20' && c <= '\x7E') }
{ if is_ascii_printable(s) { let s_lower = s.to_ascii_lowercase(); // match s_lower.parse() as Result<Mime, ()> { // Ok(_) => s_lower, // Err(_) => "".to_string() s_lower } else { "".to_string() } }
identifier_body
blob.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::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding; use dom::bindings::codegen...
( &self, start: Option<i64>, end: Option<i64>, content_type: Option<DOMString>, ) -> DomRoot<Blob> { let rel_pos = RelativePos::from_opts(start, end); Blob::new_sliced(self, rel_pos, content_type.unwrap_or(DOMString::from(""))) } } /// Get the normalized, MIME-pa...
Slice
identifier_name
issue-19190.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 ...
; pub struct Bar; impl Foo { pub fn foo(&self) {} } impl Deref for Bar { type Target = Foo; fn deref(&self) -> &Foo { loop {} } } // @has issue_19190/struct.Bar.html // @has - '//*[@id="method.foo"]' 'fn foo(&self)'
Foo
identifier_name
issue-19190.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 ...
// option. This file may not be copied, modified, or distributed // except according to those terms. use std::ops::Deref; pub struct Foo; pub struct Bar; impl Foo { pub fn foo(&self) {} } impl Deref for Bar { type Target = Foo; fn deref(&self) -> &Foo { loop {} } } // @has issue_19190/struct.Bar.html /...
random_line_split
console.rs
use core; use x86::io::outb; use ::console::{Color, ConsoleCore}; const VGA_TEXT_BASE: *mut u16 = 0xB8000 as *mut u16; // TODO: Read this from BIOS instead const VGA_BASE_PORT: u16 = 0x3d4; pub struct ConsoleCoreImpl { x: usize, y: usize, fg: Color, bg: Color, show_cursor: bool, } impl ConsoleC...
fn advance_cursor(&mut self) { if self.x == self.width() - 1 { self.advance_line(); } else { self.x += 1; self.update_hw_cursor(); } } fn advance_line(&mut self) { let width = self.width(); let height = self.height(); asser...
{ self.show_cursor = v; }
identifier_body
console.rs
use core; use x86::io::outb; use ::console::{Color, ConsoleCore}; const VGA_TEXT_BASE: *mut u16 = 0xB8000 as *mut u16; // TODO: Read this from BIOS instead const VGA_BASE_PORT: u16 = 0x3d4; pub struct ConsoleCoreImpl { x: usize, y: usize, fg: Color, bg: Color, show_cursor: bool, } impl ConsoleC...
(&mut self, ch: u8) { let color = self.fg as u16 | ((self.bg as u16) << 4); unsafe { let addr = VGA_TEXT_BASE.offset((self.y * self.width() + self.x) as isize); core::intrinsics::volatile_store(addr, ch as u16 | (color << 8)); } } fn show_cursor(&mut self, v: bool...
set_char
identifier_name
console.rs
use core; use x86::io::outb; use ::console::{Color, ConsoleCore}; const VGA_TEXT_BASE: *mut u16 = 0xB8000 as *mut u16; // TODO: Read this from BIOS instead const VGA_BASE_PORT: u16 = 0x3d4; pub struct ConsoleCoreImpl { x: usize, y: usize, fg: Color, bg: Color, show_cursor: bool, } impl ConsoleC...
let addr = VGA_TEXT_BASE.offset((width * (height - 1) + x) as isize); core::intrinsics::volatile_store(addr, b''as u16 | (color << 8)); } } } else { self.y += 1; } self.x = 0; self.update_hw_cursor(); } ...
random_line_split
console.rs
use core; use x86::io::outb; use ::console::{Color, ConsoleCore}; const VGA_TEXT_BASE: *mut u16 = 0xB8000 as *mut u16; // TODO: Read this from BIOS instead const VGA_BASE_PORT: u16 = 0x3d4; pub struct ConsoleCoreImpl { x: usize, y: usize, fg: Color, bg: Color, show_cursor: bool, } impl ConsoleC...
else { self.y += 1; } self.x = 0; self.update_hw_cursor(); } fn width(&self) -> usize { 80 } fn height(&self) -> usize { 25 } fn cursor(&self) -> (usize, usize) { (self.x, self.y) } }
{ unsafe { core::intrinsics::volatile_copy_memory(VGA_TEXT_BASE, VGA_TEXT_BASE.offset(width as isize), width * (height - 1)); } let color = (self.bg as u16) << 4; for x in 0..width { unsafe { let addr = VGA_TEXT_BASE.of...
conditional_block
status.rs
#[derive(Debug, Eq, PartialEq)] pub enum StatusCode { OK = 0, OutOfMemory = 1, KeyError = 2, TypeError = 3, Invalid = 4, IOError = 5, UnknownError = 9, NotImplemented = 10, } pub struct
{ code: StatusCode, posix_code: i16, message: String } impl ArrowError { pub fn out_of_memory(message: &'static str) -> ArrowError { ArrowError::new(StatusCode::OutOfMemory, message, -1) } pub fn key_error(message: &'static str) -> ArrowError { ArrowError::new(StatusCode::KeyError, message, -1) ...
ArrowError
identifier_name
status.rs
#[derive(Debug, Eq, PartialEq)] pub enum StatusCode { OK = 0, OutOfMemory = 1, KeyError = 2, TypeError = 3, Invalid = 4, IOError = 5, UnknownError = 9, NotImplemented = 10, } pub struct ArrowError { code: StatusCode, posix_code: i16, message: String } impl ArrowError { pub fn out_of_memory(m...
}
{ &self.message }
identifier_body
status.rs
#[derive(Debug, Eq, PartialEq)] pub enum StatusCode { OK = 0, OutOfMemory = 1, KeyError = 2, TypeError = 3, Invalid = 4, IOError = 5, UnknownError = 9,
pub struct ArrowError { code: StatusCode, posix_code: i16, message: String } impl ArrowError { pub fn out_of_memory(message: &'static str) -> ArrowError { ArrowError::new(StatusCode::OutOfMemory, message, -1) } pub fn key_error(message: &'static str) -> ArrowError { ArrowError::new(StatusCode::Ke...
NotImplemented = 10, }
random_line_split
shuf.rs
#![crate_name = "shuf"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #![feature(macro_rules)] extern crate getopts; extern crate lib...
{ RngFile(rand::reader::ReaderRng<io::File>), RngDefault(rand::TaskRng), } impl WrappedRng { fn next_u32(&mut self) -> u32 { match self { &WrappedRng::RngFile(ref mut r) => r.next_u32(), &WrappedRng::RngDefault(ref mut r) => r.next_u32(), } } } fn shuf_lines(mu...
WrappedRng
identifier_name
shuf.rs
#![crate_name = "shuf"] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ #![feature(macro_rules)] extern crate getopts; extern crate lib...
Ok(range_inclusive(begin, end)) } }
};
random_line_split
topology.rs
//! Types and traits for handling the layers topology. use std::ops::Range; /// Common interface for topology of neuron organizations. /// /// This trait is used to make the mapping between the inputs indexes to /// their location in a topology of layer. pub trait Topology { /// Type of the iterator over neighbor...
) ) } fn radius<I: IntoIterator<Item=usize>>(&self, center: usize, nodes: I) -> f64 { nodes.into_iter() .map(|i| if i > center { i - center } else { center -i }) .fold(0, |m, i| if i > m { i } else { m }) as f64 } fn surface(r: f64) -> f64 { 2.0*r }...
{ i + radius }
conditional_block
topology.rs
//! Types and traits for handling the layers topology. use std::ops::Range; /// Common interface for topology of neuron organizations. /// /// This trait is used to make the mapping between the inputs indexes to /// their location in a topology of layer. pub trait Topology { /// Type of the iterator over neighbor...
let oldx = self.point.0; self.point.0 += 1.0; Some((oldx + self.y_offset) as usize) } } impl TwoDimensions { /// Create a new `TwoDimension` topology. /// /// It represents a line of `width*height` inputs, with indexes /// ranging from `0` to `width*height-1` included. p...
self.point = (self.center.0 - dx, new_y) } self.y_offset += self.width; self.max_x = self.center.0 + dx; }
random_line_split
topology.rs
//! Types and traits for handling the layers topology. use std::ops::Range; /// Common interface for topology of neuron organizations. /// /// This trait is used to make the mapping between the inputs indexes to /// their location in a topology of layer. pub trait Topology { /// Type of the iterator over neighbor...
(b: &mut Bencher) { b.iter(|| { let t = TwoDimensions::new(64, 32); t.neighbors(256, 42.5).count() }); } }
neigh_iter_2d
identifier_name
monitor_device.rs
extern crate portmidi as pm; use std::thread::sleep_ms; use pm::{PortMidiDeviceId, PortMidiResult}; use pm::PortMidiError::InvalidDeviceId; pub mod common; fn
() { // get the device number from the command line, or die() let device_id = match common::get_arg(1) { Some(id) => id, None => { common::die(); return; } }; // run the monitor, print an error if it returns one if let Err(e) = monitor(device_id) { println!("Error: {:?}", e)...
main
identifier_name
monitor_device.rs
extern crate portmidi as pm; use std::thread::sleep_ms; use pm::{PortMidiDeviceId, PortMidiResult}; use pm::PortMidiError::InvalidDeviceId; pub mod common; fn main() { // get the device number from the command line, or die() let device_id = match common::get_arg(1) { Some(id) => id, None => ...
// no more data? wait a little before trying again sleep_ms(50); } // close the input and terminate portmidi try!(input.close()); pm::terminate() }
}
random_line_split
monitor_device.rs
extern crate portmidi as pm; use std::thread::sleep_ms; use pm::{PortMidiDeviceId, PortMidiResult}; use pm::PortMidiError::InvalidDeviceId; pub mod common; fn main() { // get the device number from the command line, or die() let device_id = match common::get_arg(1) { Some(id) => id, None => ...
println!("{} {:?}", event.timestamp, event.message); } } // no more data? wait a little before trying again sleep_ms(50); } // close the input and terminate portmidi try!(input.close()); pm::terminate() }
{ // initialize portmidi try!(pm::initialize()); // get the device and check it exists let device = try!(pm::get_device_info(device_id).ok_or(InvalidDeviceId)); println!("Opening: {}", device.name); // open the input let mut input = pm::InputPort::new(device_id, 1024); try!(input.open(...
identifier_body
mod.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //
// 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. /*! * Collection types. */ #![experimental] pub use core_collections::{Collection, M...
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
timer.rs
// Copyright (c) 2016 Tibor Benke <ihrwein@gmail.com> // // 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. All files in the project carrying such notice may not...
} pub struct Timer; impl Timer { pub fn from_chan(duration: Duration, tx: mpsc::Sender<Request>) { thread::spawn(move || { while let Ok(_) = tx.send(Request::Timer(TimerEvent(duration))) { thread::sleep(duration); } }); } }
{ TimerEvent(Duration::from_millis(ms)) }
identifier_body
timer.rs
// Copyright (c) 2016 Tibor Benke <ihrwein@gmail.com> // // 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. All files in the project carrying such notice may not...
; impl Timer { pub fn from_chan(duration: Duration, tx: mpsc::Sender<Request>) { thread::spawn(move || { while let Ok(_) = tx.send(Request::Timer(TimerEvent(duration))) { thread::sleep(duration); } }); } }
Timer
identifier_name
timer.rs
// Copyright (c) 2016 Tibor Benke <ihrwein@gmail.com> // // 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. All files in the project carrying such notice may not...
}
}); }
random_line_split
tests.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
pub gas: U256, pub sender_address: Option<Address>, pub receive_address: Option<Address>, pub value: Option<U256>, pub data: Bytes, pub code_address: Option<Address>, } /// Fake externalities test structure. /// /// Can't do recursive calls. #[derive(Default)] pub struct FakeExt { pub store: HashMap<H256, H256>...
#[derive(PartialEq, Eq, Hash, Debug)] pub struct FakeCall { pub call_type: FakeCallType,
random_line_split
tests.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
fn ret(self, _gas: &U256, _data: &ReturnData, _apply_state: bool) -> Result<U256> { unimplemented!(); } fn suicide(&mut self, refund_address: &Address) -> Result<()> { self.suicides.insert(refund_address.clone()); Ok(()) } fn schedule(&self) -> &Schedule { &self.schedule } fn env_info(&self) -> &Env...
{ self.logs.push(FakeLogEntry { topics: topics, data: data.to_vec() }); Ok(()) }
identifier_body
tests.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
(&mut self, topics: Vec<H256>, data: &[u8]) -> Result<()> { self.logs.push(FakeLogEntry { topics: topics, data: data.to_vec() }); Ok(()) } fn ret(self, _gas: &U256, _data: &ReturnData, _apply_state: bool) -> Result<U256> { unimplemented!(); } fn suicide(&mut self, refund_address: &Address) -> Result...
log
identifier_name
lib.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 n...
// NOTE: this macro has to be defined before any modules. See: // https://danielkeep.github.io/quick-intro-to-macros.html#some-more-gotchas /// Assert that an expression returning a `Result` is a success. If it is, /// return the value contained in the result, i.e. `expr.unwrap()`. #[cfg(test)] macro_rules! assert_su...
extern crate threadpool; #[macro_use] extern crate log;
random_line_split
panics.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
<S>(&self, child: &S) where S: MayPanic, { let p = self.clone(); child.on_panic(move |t| p.notify_all(t)); } } impl<F> OnPanicListener for F where F: FnMut(String) + Send + Sync +'static, { fn call(&mut self, arg: &str) { self(arg.to_owned()) } } #[test] #[ignore] // panic forwarding doesnt work on th...
forward_from
identifier_name
panics.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
} } /// Structure that allows to catch panics and notify listeners pub struct PanicHandler { listeners: Mutex<Vec<Box<OnPanicListener>>>, } impl Default for PanicHandler { fn default() -> Self { PanicHandler::new() } } impl PanicHandler { /// Creates new `PanicHandler` wrapped in `Arc` pub fn new_in_arc() -...
{ self.handler.notify_all("Panic!".to_owned()); }
conditional_block
panics.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
// when p.catch_panic(|| panic!("Panic: {}", 1)).unwrap_err(); // then assert!(invocations.read().unwrap()[0] == "Panic: 1"); } #[test] fn should_notify_listeners_about_panic_in_other_thread() { use std::thread; use std::sync::RwLock; // given let invocations = Arc::new(RwLock::new(vec![])); let i = invocat...
random_line_split
panics.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
fn notify_all(&self, r: String) { let mut listeners = self.listeners.lock().unwrap(); for listener in listeners.deref_mut() { listener.call(&r); } } } impl MayPanic for PanicHandler { fn on_panic<F>(&self, closure: F) where F: OnPanicListener, { self.listeners.lock().unwrap().push(Box::new(closure))...
{ let _guard = PanicGuard { handler: self }; let result = g(); Ok(result) }
identifier_body
E0597.rs
// Copyright 2017 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 ...
}
{ }
identifier_body
E0597.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
x.x = Some(&y); //~^ `y` does not live long enough [E0597] } impl<'a> Drop for Foo<'a> { fn drop(&mut self) { } }
fn main() { let mut x = Foo { x: None }; let y = 0;
random_line_split
E0597.rs
// Copyright 2017 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> { x: Option<&'a u32>, } fn main() { let mut x = Foo { x: None }; let y = 0; x.x = Some(&y); //~^ `y` does not live long enough [E0597] } impl<'a> Drop for Foo<'a> { fn drop(&mut self) { } }
Foo
identifier_name
unary_expr.rs
///! fff-lang ///! ///! syntax/unary_expr ///! unary_expr = { unary_operator } postfix_expr use std::fmt; use crate::source::Span; use crate::lexical::Token; use crate::lexical::Seperator; use crate::lexical::SeperatorCategory; use super::Expr; use super::PostfixExpr; use super::super::Formatter; use supe...
fn unary_expr_parse() { use crate::lexical::LitValue; use super::LitExpr; use super::super::WithTestInput; assert_eq!{ make_node!("1"), Expr::Lit(LitExpr::new(LitValue::from(1), Span::new(0, 0))) } assert_eq!{ make_node!("!~!1"), Expr::Unary(UnaryExpr::new( ...
#[cfg(test)] #[test]
random_line_split
unary_expr.rs
///! fff-lang ///! ///! syntax/unary_expr ///! unary_expr = { unary_operator } postfix_expr use std::fmt; use crate::source::Span; use crate::lexical::Token; use crate::lexical::Seperator; use crate::lexical::SeperatorCategory; use super::Expr; use super::PostfixExpr; use super::super::Formatter; use supe...
(&self, f: Formatter) -> String { f.indent().header_text_or("unary-expr").space().span(self.all_span).endl() .indent1().lit("\"").debug(&self.operator).lit("\"").space().span(self.operator_span).endl() .apply1(self.base.as_ref()) .finish() } } impl fmt::Debug for Unar...
format
identifier_name
unary_expr.rs
///! fff-lang ///! ///! syntax/unary_expr ///! unary_expr = { unary_operator } postfix_expr use std::fmt; use crate::source::Span; use crate::lexical::Token; use crate::lexical::Seperator; use crate::lexical::SeperatorCategory; use super::Expr; use super::PostfixExpr; use super::super::Formatter; use supe...
} }
{ use crate::lexical::LitValue; use super::LitExpr; use super::super::WithTestInput; assert_eq!{ make_node!("1"), Expr::Lit(LitExpr::new(LitValue::from(1), Span::new(0, 0))) } assert_eq!{ make_node!("!~!1"), Expr::Unary(UnaryExpr::new( Seperator::Lo...
identifier_body
trait-inheritance-overloading-xc-exe.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 (a, b, c) = f(x, y); assert_eq!(a, mi(8)); assert_eq!(b, mi(-2)); assert_eq!(c, mi(15));
random_line_split
trait-inheritance-overloading-xc-exe.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 mi(v: isize) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y) = (mi(3), mi(5)); let (a, b, c) = f(x, y); assert_eq!(a, mi(8)); assert_eq!(b, mi(-2)); assert_eq!(c, mi(15)); }
{ return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); }
identifier_body
trait-inheritance-overloading-xc-exe.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...
(v: isize) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y) = (mi(3), mi(5)); let (a, b, c) = f(x, y); assert_eq!(a, mi(8)); assert_eq!(b, mi(-2)); assert_eq!(c, mi(15)); }
mi
identifier_name
dompoint.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 crate::dom::bindings::codegen::Bindings::DOMPointBinding::{ DOMPointInit, DOMPointMethods, Wrap, }; use c...
(&self, value: f64) { self.point.SetY(value); } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z fn Z(&self) -> f64 { self.point.Z() } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z fn SetZ(&self, value: f64) { self.poin...
SetY
identifier_name