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
fat_type.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Loaded representation for runtime types. use diem_types::{account_address::AccountAddress, vm_status::StatusCode}; use move_core_types::{ identifier::Identifier, language_storage::{StructTag, TypeTag}, value::{MoveStruct...
}
{ Ok(match self { FatType::Address => MoveTypeLayout::Address, FatType::U8 => MoveTypeLayout::U8, FatType::U64 => MoveTypeLayout::U64, FatType::U128 => MoveTypeLayout::U128, FatType::Bool => MoveTypeLayout::Bool, FatType::Vector(v) => MoveT...
identifier_body
fat_type.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Loaded representation for runtime types. use diem_types::{account_address::AccountAddress, vm_status::StatusCode}; use move_core_types::{ identifier::Identifier, language_storage::{StructTag, TypeTag}, value::{MoveStruct...
(&self, ty_args: &[FatType]) -> PartialVMResult<FatStructType> { Ok(Self { address: self.address, module: self.module.clone(), name: self.name.clone(), abilities: self.abilities, ty_args: self .ty_args .iter() ...
subst
identifier_name
job_queue.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::sync::TaskPool; use std::sync::mpsc::{channel, Sender, Receiver}; use term::color::YELLOW; use core::{Package, PackageId, Resolve, PackageSet}; use util::{Config, DependencyQueue,...
} return Err(e) } } } log!(5, "rustc jobs completed"); Ok(()) } /// Execute a stage of compilation for a package. /// /// The input freshness is from `dequeue()` and indicates the combined /// freshness of...
for _ in self.rx.iter().take(self.active as usize) {}
random_line_split
job_queue.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::sync::TaskPool; use std::sync::mpsc::{channel, Sender, Receiver}; use term::color::YELLOW; use core::{Package, PackageId, Resolve, PackageSet}; use util::{Config, DependencyQueue,...
(&self, &(resolve, packages): &(&'a Resolve, &'a PackageSet)) -> Vec<(&'a PackageId, Stage)> { // This implementation of `Dependency` is the driver for the structure // of the dependency graph of packages to be built. The "key" here is // a pair of the package being built and...
dependencies
identifier_name
job_queue.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::sync::TaskPool; use std::sync::mpsc::{channel, Sender, Receiver}; use term::color::YELLOW; use core::{Package, PackageId, Resolve, PackageSet}; use util::{Config, DependencyQueue,...
/// Execute all jobs necessary to build the dependency graph. /// /// This function will spawn off `config.jobs()` workers to build all of the /// necessary dependencies, in order. Freshness is propagated as far as /// possible along each dependency chain. pub fn execute(&mut self, config: &Co...
{ self.ignored.insert(pkg.get_package_id()); }
identifier_body
job_queue.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::sync::TaskPool; use std::sync::mpsc::{channel, Sender, Receiver}; use term::color::YELLOW; use core::{Package, PackageId, Resolve, PackageSet}; use util::{Config, DependencyQueue,...
}; // Add the package to the dependency graph self.queue.enqueue(&(self.resolve, self.packages), Fresh, (pkg.get_package_id(), stage), (pkg, jobs)); } pub fn ignore(&mut self, pkg: &'a Package) { self.ignored.insert(pkg.get...
{ entry.insert(fresh); }
conditional_block
mem.rs
use std::num::SignedInt; use syntax::{Dir, Left, Right}; // size of allocated memory in bytes const MEM_SIZE: usize = 65_536; // 64kB! pub struct Mem { cells: Box<[u8]>, // address space ptr: usize // pointer in address space } impl Mem { /// Create a new `Mem` stuct. #[inline] pub fn...
/// Return the value of cell at the current pointer. #[inline] pub fn get(&self) -> u8 { self.cells[self.ptr] } /// Set the value at the current pointer. #[inline] pub fn set(&mut self, value: u8) { self.cells[self.ptr] = value; } /// Adds `value` to the current c...
{ Mem { cells: box [0u8; MEM_SIZE], ptr: 0 } }
identifier_body
mem.rs
use std::num::SignedInt; use syntax::{Dir, Left, Right}; // size of allocated memory in bytes const MEM_SIZE: usize = 65_536; // 64kB! pub struct Mem { cells: Box<[u8]>, // address space ptr: usize // pointer in address space } impl Mem { /// Create a new `Mem` stuct. #[inline] pub fn...
}; self.cells[index] += self.cells[self.ptr]; } /// Multiplys the value of the current cell by a factor and inserts the /// product into the cell left or right a number of steps. pub fn multiply(&mut self, dir: Dir, steps: usize, factor: i8) { let index = match dir { ...
pub fn copy(&mut self, dir: Dir, steps: usize) { let index = match dir { Left => self.ptr - steps, Right => self.ptr + steps,
random_line_split
mem.rs
use std::num::SignedInt; use syntax::{Dir, Left, Right}; // size of allocated memory in bytes const MEM_SIZE: usize = 65_536; // 64kB! pub struct Mem { cells: Box<[u8]>, // address space ptr: usize // pointer in address space } impl Mem { /// Create a new `Mem` stuct. #[inline] pub fn...
(&mut self, dir: Dir) { while self.cells[self.ptr]!= 0 { self.shift(dir, 1); } } /// Copys the value of the current cell into the cell left or right a /// number of steps. #[inline] pub fn copy(&mut self, dir: Dir, steps: usize) { let index = match dir { ...
scan
identifier_name
indexedlogauxstore.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::io::Cursor; use std::io::Read; use std::io::Write; use std::path::Path; use anyhow::bail; use anyhow::Result; use byteorder::Read...
Ok(open_options) } pub fn get(&self, hgid: HgId) -> Result<Option<Entry>> { let log = self.0.read(); let mut entries = log.lookup(0, &hgid)?; let slice = match entries.next() { None => return Ok(None), Some(slice) => slice?, }; let bytes...
{ let log_count: u64 = open_options.max_log_count.unwrap_or(1).max(1).into(); open_options = open_options.max_bytes_per_log((max_bytes_per_log.value() / log_count).max(1)); }
conditional_block
indexedlogauxstore.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::io::Cursor; use std::io::Read; use std::io::Write; use std::path::Path; use anyhow::bail; use anyhow::Result; use byteorder::Read...
() -> Result<()> { let tempdir = TempDir::new()?; let store = AuxStore::new(&tempdir, &ConfigSet::new(), StoreType::Shared)?; store.flush()?; Ok(()) } #[test] fn test_add_get() -> Result<()> { let tempdir = TempDir::new().unwrap(); let store = AuxStore::new(&...
test_empty
identifier_name
indexedlogauxstore.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::io::Cursor; use std::io::Read; use std::io::Write; use std::path::Path; use anyhow::bail; use anyhow::Result; use byteorder::Read...
fn deserialize(bytes: Bytes) -> Result<(HgId, Self)> { let data: &[u8] = bytes.as_ref(); let mut cur = Cursor::new(data); let hgid = cur.read_hgid()?; let version = cur.read_u8()?; if version!= 0 { bail!("unsupported auxstore entry version {}", version); ...
{ let mut buf = Vec::new(); buf.write_all(hgid.as_ref())?; buf.write_u8(0)?; // write version buf.write_all(self.content_id.as_ref())?; buf.write_all(self.content_sha1.as_ref())?; buf.write_all(self.content_sha256.as_ref())?; buf.write_vlq(self.total_size)?; ...
identifier_body
indexedlogauxstore.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::io::Cursor; use std::io::Read; use std::io::Write; use std::path::Path; use anyhow::bail; use anyhow::Result; use byteorder::Read...
use types::testutil::*; use super::*; use crate::scmstore::FileAttributes; use crate::scmstore::FileStore; use crate::testutil::*; use crate::ExtStoredPolicy; use crate::HgIdMutableDeltaStore; use crate::IndexedLogHgIdDataStore; fn single_byte_sha1(fst: u8) -> Sha1 { let mu...
random_line_split
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(box_syntax)] #![feature(custom_derive)] #![feature(plugin)] #![feature(mpsc_select)] #![feature(plugin)...
{ Script, Layout, } /// Messages from the compositor to the constellation. #[derive(Deserialize, Serialize)] pub enum CompositorMsg { Exit, FrameSize(PipelineId, Size2D<f32>), /// Request that the constellation send the FrameId corresponding to the document /// with the provided pipeline id ...
AnimationTickType
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(box_syntax)] #![feature(custom_derive)] #![feature(plugin)] #![feature(mpsc_select)] #![feature(plugin)...
extern crate layout_traits; #[macro_use] extern crate log; extern crate msg; extern crate net_traits; extern crate num; extern crate offscreen_gl_context; #[macro_use] extern crate profile_traits; extern crate rand; extern crate script_traits; extern crate serde; extern crate style_traits; extern crate time; extern cra...
extern crate ipc_channel; extern crate layers;
random_line_split
main.rs
/* Full Monkey. Generic preprocessor tool. Copyright 2016 Sam Saint-Pettersen. Released under the MIT/X11 License. */ extern crate clioptions; extern crate regex; use clioptions::CliOptions; use regex::Regex; use std::io::{BufRead, BufReader, Write}; use std::fs::File; use std::process::exit; fn prep...
(program: &str, exit_code: i32) { println!("\nFull Monkey."); println!("Generic preprocessor tool."); println!("\nCopyright 2016 Sam Saint-Pettersen."); println!("Released under the MIT/X11 License."); println!("\n{} -f|--file <input> [-c|--condition <condition(s)>] -o|--out <output>", program); ...
display_usage
identifier_name
main.rs
/* Full Monkey. Generic preprocessor tool. Copyright 2016 Sam Saint-Pettersen. Released under the MIT/X11 License. */ extern crate clioptions; extern crate regex; use clioptions::CliOptions; use regex::Regex; use std::io::{BufRead, BufReader, Write}; use std::fs::File; use std::process::exit; fn prep...
let mut p = Regex::new("#prefix (.*) with (.*)").unwrap(); if p.is_match(&l) { for cap in p.captures_iter(&l) { prefixed.push(cap.at(1).unwrap().to_string()); prefixes.push(cap.at(2).unwrap().to_string()); } continue; } ...
{ let mut loc: Vec<String> = Vec::new(); let mut preprocessed: Vec<String> = Vec::new(); let mut cond = String::new(); let mut set_conds: Vec<String> = Vec::new(); let mut prefixed: Vec<String> = Vec::new(); let mut prefixes: Vec<String> = Vec::new(); let mut in_pp = false; let conditio...
identifier_body
main.rs
/* Full Monkey. Generic preprocessor tool. Copyright 2016 Sam Saint-Pettersen. Released under the MIT/X11 License. */ extern crate clioptions; extern crate regex; use clioptions::CliOptions; use regex::Regex; use std::io::{BufRead, BufReader, Write}; use std::fs::File; use std::process::exit; fn prep...
preprocessed.push(l.to_string()); continue; } } // Do any alterations: for line in preprocessed { let mut fl = line; for (i, p) in prefixed.iter().enumerate() { let r = Regex::new(&regex::quote(&p)).unwrap(); let repl = format!("{}{}", ...
} if !in_pp {
random_line_split
main.rs
/* Full Monkey. Generic preprocessor tool. Copyright 2016 Sam Saint-Pettersen. Released under the MIT/X11 License. */ extern crate clioptions; extern crate regex; use clioptions::CliOptions; use regex::Regex; use std::io::{BufRead, BufReader, Write}; use std::fs::File; use std::process::exit; fn prep...
// Process end block... p = Regex::new("#[fi|endif]").unwrap(); if p.is_match(&l) { in_pp = false; continue; } // Push relevant LoC to vector... for sc in set_conds.clone() { if in_pp && cond == sc { preprocessed.push(...
{ for cap in p.captures_iter(&l) { cond = cap.at(1).unwrap().to_string(); in_pp = true; } continue; }
conditional_block
get_room_information.rs
//! `GET /_matrix/federation/*/query/directory` //! //! Endpoint to query room information with a room alias. pub mod v1 { //! `/v1/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1querydirectory use ruma_common::{api::ruma_api, RoomAliasId, RoomId, Serv...
} }
{ Self { room_id, servers } }
identifier_body
get_room_information.rs
//! `GET /_matrix/federation/*/query/directory` //! //! Endpoint to query room information with a room alias. pub mod v1 { //! `/v1/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1querydirectory use ruma_common::{api::ruma_api, RoomAliasId, RoomId, Serv...
(room_id: Box<RoomId>, servers: Vec<Box<ServerName>>) -> Self { Self { room_id, servers } } } }
new
identifier_name
get_room_information.rs
//! `GET /_matrix/federation/*/query/directory` //! //! Endpoint to query room information with a room alias. pub mod v1 { //! `/v1/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1querydirectory use ruma_common::{api::ruma_api, RoomAliasId, RoomId, Serv...
impl<'a> Request<'a> { /// Creates a new `Request` with the given room alias ID. pub fn new(room_alias: &'a RoomAliasId) -> Self { Self { room_alias } } } impl Response { /// Creates a new `Response` with the given room IDs and servers. pub fn new(room_id...
pub servers: Vec<Box<ServerName>>, } }
random_line_split
device_id.rs
#[cfg(feature = "rand")] use super::generate_localpart; /// A Matrix key ID. /// /// Device identifiers in Matrix are completely opaque character sequences. This type is provided /// simply for its semantic value. /// /// # Example /// /// ``` /// use ruma_common::{device_id, DeviceId}; /// /// let random_id = DeviceI...
opaque_identifier!(DeviceId); impl DeviceId { /// Generates a random `DeviceId`, suitable for assignment to a new device. #[cfg(feature = "rand")] pub fn new() -> Box<Self> { Self::from_owned(generate_localpart(8)) } } #[cfg(all(test, feature = "rand"))] mod tests { use super::DeviceId; ...
random_line_split
device_id.rs
#[cfg(feature = "rand")] use super::generate_localpart; /// A Matrix key ID. /// /// Device identifiers in Matrix are completely opaque character sequences. This type is provided /// simply for its semantic value. /// /// # Example /// /// ``` /// use ruma_common::{device_id, DeviceId}; /// /// let random_id = DeviceI...
() -> Box<Self> { Self::from_owned(generate_localpart(8)) } } #[cfg(all(test, feature = "rand"))] mod tests { use super::DeviceId; #[test] fn generate_device_id() { assert_eq!(DeviceId::new().as_str().len(), 8); } #[test] fn create_device_id_from_str() { let ref_id...
new
identifier_name
hud.rs
use super::wad_system::WadSystem; use engine::{ ControlFlow, DependenciesFrom, Gesture, InfallibleSystem, Input, Scancode, TextId, TextRenderer, Window, }; use math::prelude::*; use math::Pnt2f; pub struct Bindings { pub quit: Gesture, pub next_level: Gesture, pub previous_level: Gesture, pub t...
} } fn teardown(&mut self, deps: Dependencies) { deps.text.remove(self.help_text); deps.text.remove(self.prompt_text); } } enum HelpState { Prompt, Shown, Hidden, } const HELP_PADDING: u32 = 6; const PROMPT_TEXT: &str = "WASD and mouse, 'E' to push/use, LB to shoot or...
{ deps.wad.change_level(index - 1); }
conditional_block
hud.rs
use super::wad_system::WadSystem; use engine::{ ControlFlow, DependenciesFrom, Gesture, InfallibleSystem, Input, Scancode, TextId, TextRenderer, Window, }; use math::prelude::*; use math::Pnt2f; pub struct Bindings { pub quit: Gesture, pub next_level: Gesture, pub previous_level: Gesture, pub t...
(&mut self, deps: Dependencies) { deps.text.remove(self.help_text); deps.text.remove(self.prompt_text); } } enum HelpState { Prompt, Shown, Hidden, } const HELP_PADDING: u32 = 6; const PROMPT_TEXT: &str = "WASD and mouse, 'E' to push/use, LB to shoot or 'h' for help."; const HELP_TEXT:...
teardown
identifier_name
hud.rs
use super::wad_system::WadSystem; use engine::{ ControlFlow, DependenciesFrom, Gesture, InfallibleSystem, Input, Scancode, TextId, TextRenderer, Window, }; use math::prelude::*; use math::Pnt2f; pub struct Bindings { pub quit: Gesture, pub next_level: Gesture, pub previous_level: Gesture, pub t...
text[self.prompt_text].set_visible(false); text[self.help_text].set_visible(true); HelpState::Shown } HelpState::Shown => { text[self.help_text].set_visible(false); HelpState::Hidden ...
random_line_split
custom_tests.rs
extern crate rusoto_mock; use crate::generated::{LexRuntime, LexRuntimeClient, PostTextRequest, PostTextResponse};
#[tokio::test] async fn test_post_text_resposnse_serialization() { let mock_resp_body = r#"{ "dialogState": "ElicitSlot", "intentName": "BookCar", "message": "In what city do you need to rent a car?", "messageFormat": "PlainText", "responseCard": null, "sessionAttributes": {}, ...
use rusoto_core::Region; use std::collections::HashMap; use self::rusoto_mock::*;
random_line_split
custom_tests.rs
extern crate rusoto_mock; use crate::generated::{LexRuntime, LexRuntimeClient, PostTextRequest, PostTextResponse}; use rusoto_core::Region; use std::collections::HashMap; use self::rusoto_mock::*; #[tokio::test] async fn
() { let mock_resp_body = r#"{ "dialogState": "ElicitSlot", "intentName": "BookCar", "message": "In what city do you need to rent a car?", "messageFormat": "PlainText", "responseCard": null, "sessionAttributes": {}, "slotToElicit": "PickUpCity", "slots": { "Ca...
test_post_text_resposnse_serialization
identifier_name
custom_tests.rs
extern crate rusoto_mock; use crate::generated::{LexRuntime, LexRuntimeClient, PostTextRequest, PostTextResponse}; use rusoto_core::Region; use std::collections::HashMap; use self::rusoto_mock::*; #[tokio::test] async fn test_post_text_resposnse_serialization()
input_text: "Book a car".to_owned(), user_id: "rs".to_owned(), ..Default::default() }; let mut slots = HashMap::new(); slots.insert("CarType".to_owned(), None); slots.insert("PickUpCity".to_owned(), Some("Boston".to_owned())); let expected = PostTextResponse { active...
{ let mock_resp_body = r#"{ "dialogState": "ElicitSlot", "intentName": "BookCar", "message": "In what city do you need to rent a car?", "messageFormat": "PlainText", "responseCard": null, "sessionAttributes": {}, "slotToElicit": "PickUpCity", "slots": { "CarTy...
identifier_body
roundsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn roundsd_1() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDSD, operand1: Some(Direct(XMM0)), operand2: Some(Direct(...
fn roundsd_4() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDSD, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledIndexedDisplaced(RDX, RCX, Eight, 1515642711, Some(OperandSize::Qword), None)), operand3: Some(Literal8(102)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: fa...
random_line_split
roundsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn roundsd_1() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDSD, operand1: Some(Direct(XMM0)), operand2: Some(Direct(...
() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDSD, operand1: Some(Direct(XMM6)), operand2: Some(IndirectDisplaced(EAX, 455015242, Some(OperandSize::Qword), None)), operand3: Some(Literal8(66)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[10...
roundsd_2
identifier_name
roundsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn roundsd_1() { run_test(&Instruction { mnemonic: Mnemonic::ROUNDSD, operand1: Some(Direct(XMM0)), operand2: Some(Direct(...
{ run_test(&Instruction { mnemonic: Mnemonic::ROUNDSD, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledIndexedDisplaced(RDX, RCX, Eight, 1515642711, Some(OperandSize::Qword), None)), operand3: Some(Literal8(102)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None,...
identifier_body
process.rs
use std::io::process::{Command,ProcessOutput}; fn main()
let s = String::from_utf8_lossy(err.as_slice()); print!("rustc failed and stderr was:\n{}", s); } }, } }
{ // Initial command `rustc` let mut cmd = Command::new("rustc"); // append the "--version" flag to the command cmd.arg("--version"); // The `output` method will spawn `rustc --version`, wait until the process // finishes and return the output of the process match cmd.output() { Err...
identifier_body
process.rs
use std::io::process::{Command,ProcessOutput}; fn main() { // Initial command `rustc` let mut cmd = Command::new("rustc"); // append the "--version" flag to the command cmd.arg("--version");
Ok(ProcessOutput { error: err, output: out, status: exit }) => { // Check if the process succeeded, i.e. the exit code was 0 if exit.success() { // `out` has type `Vec<u8>`, convert it to a UTF-8 `$str` let s = String::from_utf8_lossy(out.as_slice()); ...
// The `output` method will spawn `rustc --version`, wait until the process // finishes and return the output of the process match cmd.output() { Err(why) => panic!("couldn't spawn rustc: {}", why.desc), // Destructure `ProcessOutput`
random_line_split
process.rs
use std::io::process::{Command,ProcessOutput}; fn
() { // Initial command `rustc` let mut cmd = Command::new("rustc"); // append the "--version" flag to the command cmd.arg("--version"); // The `output` method will spawn `rustc --version`, wait until the process // finishes and return the output of the process match cmd.output() { ...
main
identifier_name
gcs.rs
_acl(attrs.get("predefined_acl").unwrap_or(def)) .or_invalid_input("invalid predefined_acl")?; let storage_class = parse_storage_class(&none_to_empty(bucket.storage_class.clone())) .or_invalid_input("invalid storage_class")?; let credentials_blob_opt = StringNonEmpty::opt( ...
let (parts, body) = res.into_parts(); let body = hyper::body::to_bytes(body) .await .map_err(|e| RequestError::Hyper(e, "set auth body".to_owned()))?; svc_access .parse_token_response(scope_hash, Response::from_par...
{ return Err(status_code_error( res.status(), "set auth request".to_string(), )); }
conditional_block
gcs.rs
fn deserialize_service_account_info( cred: StringNonEmpty, ) -> std::result::Result<ServiceAccountInfo, RequestError> { ServiceAccountInfo::deserialize(cred.to_string()) .map_err(|e| RequestError::OAuth(e, "deserialize ServiceAccountInfo".to_string())) } impl BlobConfig for Config { fn name(&self) ...
test_config_round_trip
identifier_name
gcs.rs
_predefined_acl(attrs.get("predefined_acl").unwrap_or(def)) .or_invalid_input("invalid predefined_acl")?; let storage_class = parse_storage_class(&none_to_empty(bucket.storage_class.clone())) .or_invalid_input("invalid storage_class")?; let credentials_blob_opt = StringNonEmpty::o...
fn deserialize_service_account_info( cred: StringNonEmpty, ) -> std::result::Result<ServiceAccountInfo, RequestError> { ServiceAccountInfo::deserialize(cred.to_string()) .map_err(|e| RequestError::OAuth(e, "deserialize ServiceAccountInfo".to_string())) } impl BlobConfig for Config { fn name(&self) ...
storage_class, }) } }
random_line_split
gcs.rs
_acl(attrs.get("predefined_acl").unwrap_or(def)) .or_invalid_input("invalid predefined_acl")?; let storage_class = parse_storage_class(&none_to_empty(bucket.storage_class.clone())) .or_invalid_input("invalid storage_class")?; let credentials_blob_opt = StringNonEmpty::opt( ...
)); } let (parts, body) = res.into_parts(); let body = hyper::body::to_bytes(body) .await .map_err(|e| RequestError::Hyper(e, "set auth body".to_owned()))?; svc_access .parse_toke...
{ let token_or_request = svc_access .get_token(&[scope]) .map_err(|e| RequestError::OAuth(e, "get_token".to_string()))?; let token = match token_or_request { TokenOrRequest::Token(token) => token, TokenOrRequest::Request { request, ...
identifier_body
lib.rs
//! # nom, eating data byte by byte //! //! nom is a parser combinator library with a focus on safe parsing, //! streaming patterns, and as much as possible zero copy. //! //! ## Example //! //! ```rust //! use nom::{ //! IResult, //! bytes::complete::{tag, take_while_m_n}, //! combinator::map_res, //! sequence...
//! There are more complex (and more useful) parsers like `tuple!`, which is //! used to apply a series of parsers then assemble their results. //! //! Example with `tuple`: //! //! ```rust //! # fn main() { //! use nom::{error::ErrorKind, Needed, //! number::streaming::be_u16, //! bytes::streaming::{tag, take}, //! se...
//! - **`many0`**: Will apply the parser 0 or more times (if it returns the `O` type, the new parser returns `Vec<O>`) //! - **`many1`**: Will apply the parser 1 or more times //!
random_line_split
mod.rs
//! Lexical analysis. use std::str; use std::fmt; use kailua_diag::{Locale, Localize, Localized}; use string::{Name, Str}; /// A token. #[derive(Clone, Debug, PartialEq)] pub enum Tok { /// A token which is distinct from all other tokens. /// /// The lexer emits this token on an error. Error, //...
DashDashColon "`--:`", /// `--:`. [M] DashDashGt "`-->`", /// `-->`. [M] Ques "`?`", /// `?`. [M] Bang "`!`", /// `!`. [M] Newline match &locale[..] { "ko" => "개행문자", _ => "a newline" }, /// A newline. Only generated at the end...
DashDashHash "`--#`", /// `--#`. [M] DashDashV "`--v`", /// `--v`. [M]
random_line_split
mod.rs
//! Lexical analysis. use std::str; use std::fmt; use kailua_diag::{Locale, Localize, Localized}; use string::{Name, Str}; /// A token. #[derive(Clone, Debug, PartialEq)] pub enum
{ /// A token which is distinct from all other tokens. /// /// The lexer emits this token on an error. Error, /// A comment token. The parser should ignore this. /// /// The shebang line (the first line starting with `#`) is also considered as a comment. Comment, /// A punctuation...
Tok
identifier_name
mod.rs
//! Lexical analysis. use std::str; use std::fmt; use kailua_diag::{Locale, Localize, Localized}; use string::{Name, Str}; /// A token. #[derive(Clone, Debug, PartialEq)] pub enum Tok { /// A token which is distinct from all other tokens. /// /// The lexer emits this token on an error. Error, //...
Keyword) -> Name { kw.name().into() } } impl Localize for Keyword { fn fmt_localized(&self, f: &mut fmt::Formatter, locale: Locale) -> fmt::Result { let name = str::from_utf8(self.name()).unwrap(); match &locale[..] { "ko" => write!(f, "예약어 `{}`", name), _ => wri...
ord> for Name { fn from(kw:
identifier_body
sha1.rs
// Implements http://rosettacode.org/wiki/SHA-1 // straight port from golang crypto/sha1 // library implementation #![feature(core)] use std::num::Wrapping as wr; use std::slice::bytes::copy_memory; use std::io::{Write, Result}; // The size of a SHA1 checksum in bytes. const SIZE: usize = 20; // The blocksize of SHA...
assert!(self.x.len() >= ln); copy_memory(buf_m, &mut self.x); self.nx = ln; } Ok(()) } fn flush(&mut self) -> Result<()> { Ok(()) } } #[test] fn known_sha1s() { let input_output = [ ( "His money is twice tainted: 'taint yours and 'tain...
buf_m = &buf_m[n..]; } let ln=buf_m.len(); if ln > 0 {
random_line_split
sha1.rs
// Implements http://rosettacode.org/wiki/SHA-1 // straight port from golang crypto/sha1 // library implementation #![feature(core)] use std::num::Wrapping as wr; use std::slice::bytes::copy_memory; use std::io::{Write, Result}; // The size of a SHA1 checksum in bytes. const SIZE: usize = 20; // The blocksize of SHA...
Ok(()) } fn flush(&mut self) -> Result<()> { Ok(()) } } #[test] fn known_sha1s() { let input_output = [ ( "His money is twice tainted: 'taint yours and 'taint mine.", [0x59u8, 0x7f, 0x6a, 0x54, 0x0, 0x10, 0xf9, 0x4c, 0x15, 0xd7, 0x18, 0x6, 0xa9, 0x9a...
{ assert!(self.x.len() >= ln); copy_memory(buf_m, &mut self.x); self.nx = ln; }
conditional_block
sha1.rs
// Implements http://rosettacode.org/wiki/SHA-1 // straight port from golang crypto/sha1 // library implementation #![feature(core)] use std::num::Wrapping as wr; use std::slice::bytes::copy_memory; use std::io::{Write, Result}; // The size of a SHA1 checksum in bytes. const SIZE: usize = 20; // The blocksize of SHA...
(&mut self) -> Result<()> { Ok(()) } } #[test] fn known_sha1s() { let input_output = [ ( "His money is twice tainted: 'taint yours and 'taint mine.", [0x59u8, 0x7f, 0x6a, 0x54, 0x0, 0x10, 0xf9, 0x4c, 0x15, 0xd7, 0x18, 0x6, 0xa9, 0x9a, 0x2c, 0x87, 0x10, ...
flush
identifier_name
alignment-gep-tup-like-1.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<A,B> { a: A, b: B } fn f<A:Copy +'static>(a: A, b: u16) -> @fn() -> (A, u16) { let result: @fn() -> (A, u16) = || (copy a, b); result } pub fn main() { let (a, b) = f(22_u64, 44u16)(); info!("a=%? b=%?", a, b); assert_eq!(a, 22u64); assert_eq!(b, 44u16); }
pair
identifier_name
alignment-gep-tup-like-1.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, b) = f(22_u64, 44u16)(); info!("a=%? b=%?", a, b); assert_eq!(a, 22u64); assert_eq!(b, 44u16); }
}
random_line_split
glyph.rs
// This whole file is strongly inspired by: https://github.com/jeaye/q3/blob/master/src/client/ui/ttf/glyph.rs // available under the BSD-3 licence. // It has been modified to work with gl-rs, nalgebra, and rust-freetype use na::Vector2; /// A ttf glyph. pub struct
{ #[doc(hidden)] pub tex: Vector2<f32>, #[doc(hidden)] pub advance: Vector2<f32>, #[doc(hidden)] pub dimensions: Vector2<f32>, #[doc(hidden)] pub offset: Vector2<f32>, #[doc(hidden)] pub buffer: Vec<u8>, } impl Glyph { /// Creates a new empty glyph. pub fn new( ...
Glyph
identifier_name
glyph.rs
// This whole file is strongly inspired by: https://github.com/jeaye/q3/blob/master/src/client/ui/ttf/glyph.rs // available under the BSD-3 licence. // It has been modified to work with gl-rs, nalgebra, and rust-freetype use na::Vector2; /// A ttf glyph. pub struct Glyph { #[doc(hidden)] pub tex: Vector2<f32>...
}
{ Glyph { tex, advance, dimensions, offset, buffer, } }
identifier_body
glyph.rs
// This whole file is strongly inspired by: https://github.com/jeaye/q3/blob/master/src/client/ui/ttf/glyph.rs // available under the BSD-3 licence. // It has been modified to work with gl-rs, nalgebra, and rust-freetype use na::Vector2; /// A ttf glyph. pub struct Glyph { #[doc(hidden)] pub tex: Vector2<f32>...
} } }
random_line_split
peripheral.rs
use bare_metal::{CriticalSection, Mutex}; use once_cell::unsync::OnceCell; static PERIPHERALS: Mutex<OnceCell<At2XtPeripherals>> = Mutex::new(OnceCell::new()); pub struct At2XtPeripherals { pub port: msp430g2211::PORT_1_2, pub timer: msp430g2211::TIMER_A2, } impl AsRef<msp430g2211::PORT_1_2> for At2XtPeriphe...
impl At2XtPeripherals { pub fn init(self, cs: &CriticalSection) -> Result<(), ()> { // We want to consume our Peripherals struct so interrupts // and the main thread can access the peripherals; OnceCell // returns the data to you on error. PERIPHERALS.borrow(*cs).set(self).map_err(|...
} }
random_line_split
peripheral.rs
use bare_metal::{CriticalSection, Mutex}; use once_cell::unsync::OnceCell; static PERIPHERALS: Mutex<OnceCell<At2XtPeripherals>> = Mutex::new(OnceCell::new()); pub struct
{ pub port: msp430g2211::PORT_1_2, pub timer: msp430g2211::TIMER_A2, } impl AsRef<msp430g2211::PORT_1_2> for At2XtPeripherals { fn as_ref(&self) -> &msp430g2211::PORT_1_2 { &self.port } } impl AsRef<msp430g2211::TIMER_A2> for At2XtPeripherals { fn as_ref(&self) -> &msp430g2211::TIMER_A2 {...
At2XtPeripherals
identifier_name
dst-rvalue.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 _x: Box<str> = box *"hello world"; //~^ ERROR E0161 //~^^ ERROR cannot move out of borrowed content let array: &[isize] = &[1, 2, 3]; let _x: Box<[isize]> = box *array; //~^ ERROR E0161 //~^^ ERROR cannot move out of borrowed content }
main
identifier_name
dst-rvalue.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 ...
//~^ ERROR E0161 //~^^ ERROR cannot move out of borrowed content let array: &[isize] = &[1, 2, 3]; let _x: Box<[isize]> = box *array; //~^ ERROR E0161 //~^^ ERROR cannot move out of borrowed content }
random_line_split
dst-rvalue.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 _x: Box<str> = box *"hello world"; //~^ ERROR E0161 //~^^ ERROR cannot move out of borrowed content let array: &[isize] = &[1, 2, 3]; let _x: Box<[isize]> = box *array; //~^ ERROR E0161 //~^^ ERROR cannot move out of borrowed content }
identifier_body
textattributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
use gtk::ffi; pub struct TextAttributes { pointer: *mut ffi::C_GtkTextAttributes } impl TextAttributes { pub fn new() -> Option<TextAttributes> { let tmp_pointer = unsafe { ffi::gtk_text_attributes_new() }; if tmp_pointer.is_null() { None } else { Some(TextAttr...
//! GtkTextTag — A tag that can be applied to text in a GtkTextBuffer
random_line_split
textattributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
} } impl_GObjectFunctions!(TextAttributes, C_GtkTextAttributes)
Some(TextAttributes { pointer : tmp_pointer }) }
conditional_block
textattributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
self) -> Option<TextAttributes> { let tmp_pointer = unsafe { ffi::gtk_text_attributes_ref(self.pointer) }; if tmp_pointer.is_null() { None } else { Some(TextAttributes { pointer : tmp_pointer }) } } } impl_GObjectFunctions!(TextAttributes, C_GtkTextAttribute...
ef(&
identifier_name
f10-read-timeout.rs
/// Figure 10.10: Calling read with a timeout /// /// Takeaway: First I tried with the regular `signal` function of libc /// only to find out that the alarm signal does not interrupt the read /// call. Digging into the C code it got obvious that the signal function /// gets overriden by `lib/signal.c` which is a "relia...
alarm(0); write(STDOUT_FILENO, as_void!(line), n as _); } }
{ println!("read error!"); exit(1); }
conditional_block
f10-read-timeout.rs
/// Figure 10.10: Calling read with a timeout /// /// Takeaway: First I tried with the regular `signal` function of libc /// only to find out that the alarm signal does not interrupt the read /// call. Digging into the C code it got obvious that the signal function
/// using POSIX sigaction()". But this function gets only introduced in /// Figure 10.18. This was quite misleading IMO. /// /// $ f10-read-timeout 2>&1 /// read error! /// ERROR: return code 1 extern crate libc; #[macro_use(as_void)] extern crate apue; use libc::{STDOUT_FILENO, STDIN_FILENO, SIGALRM, SIG_ERR, c_int}...
/// gets overriden by `lib/signal.c` which is a "reliable version of signal(),
random_line_split
f10-read-timeout.rs
/// Figure 10.10: Calling read with a timeout /// /// Takeaway: First I tried with the regular `signal` function of libc /// only to find out that the alarm signal does not interrupt the read /// call. Digging into the C code it got obvious that the signal function /// gets overriden by `lib/signal.c` which is a "relia...
{ unsafe { let line: [u8; MAXLINE] = std::mem::uninitialized(); if signal(SIGALRM, sig_alrm) == SIG_ERR { panic!("signal(SIGALRM) error"); } alarm(1); let n = read(STDIN_FILENO, as_void!(line), MAXLINE); if n < 0 { println!("read error!"); ...
identifier_body
f10-read-timeout.rs
/// Figure 10.10: Calling read with a timeout /// /// Takeaway: First I tried with the regular `signal` function of libc /// only to find out that the alarm signal does not interrupt the read /// call. Digging into the C code it got obvious that the signal function /// gets overriden by `lib/signal.c` which is a "relia...
() { unsafe { let line: [u8; MAXLINE] = std::mem::uninitialized(); if signal(SIGALRM, sig_alrm) == SIG_ERR { panic!("signal(SIGALRM) error"); } alarm(1); let n = read(STDIN_FILENO, as_void!(line), MAXLINE); if n < 0 { println!("read error!"); ...
main
identifier_name
lookups.rs
/// this is a table lookup for all "flush" hands (e.g. both /// flushes and straight-flushes. entries containing a zero /// mean that combination is not possible with a five-card /// flush hand. pub const FLUSHES : [u16; 7937] = include!("snip/flushes.snip"); /// this is a table lookup for all non-flush hands consis...
[ 0, 1, 2, 4, 5 ], [ 0, 1, 2, 4, 6 ], [ 0, 1, 2, 5, 6 ], [ 0, 1, 3, 4, 5 ], [ 0, 1, 3, 4, 6 ], [ 0, 1, 3, 5, 6 ], [ 0, 1, 4, 5, 6 ], [ 0, 2, 3, 4, 5 ], [ 0, 2, 3, 4, 6 ], [ 0, 2, 3, 5, 6 ], [ 0, 2, 4, 5, 6 ], [ 0, 3, 4, 5, 6 ], [ 1, 2, 3, 4, 5 ], [ 1, 2, 3, 4, 6 ], [ 1, 2, 3, 5, 6 ], [ 1...
[ 0, 1, 2, 3, 6 ],
random_line_split
test.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/. */ pub use crate::dom::bindings::str::{ByteString, DOMString}; pub use crate::dom::headers::normalize_value; // For...
} pub fn Node() -> usize { size_of::<Node>() } pub fn Text() -> usize { size_of::<Text>() } } pub mod srcset { pub use crate::dom::htmlimageelement::{parse_a_srcset_attribute, Descriptor, ImageSource}; } pub mod timeranges { pub use crate::dom::timeranges::TimeRangesConta...
pub fn HTMLSpanElement() -> usize { size_of::<HTMLSpanElement>()
random_line_split
test.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/. */ pub use crate::dom::bindings::str::{ByteString, DOMString}; pub use crate::dom::headers::normalize_value; // For...
() -> usize { size_of::<HTMLSpanElement>() } pub fn Node() -> usize { size_of::<Node>() } pub fn Text() -> usize { size_of::<Text>() } } pub mod srcset { pub use crate::dom::htmlimageelement::{parse_a_srcset_attribute, Descriptor, ImageSource}; } pub mod timeranges { ...
HTMLSpanElement
identifier_name
test.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/. */ pub use crate::dom::bindings::str::{ByteString, DOMString}; pub use crate::dom::headers::normalize_value; // For...
} pub mod srcset { pub use crate::dom::htmlimageelement::{parse_a_srcset_attribute, Descriptor, ImageSource}; } pub mod timeranges { pub use crate::dom::timeranges::TimeRangesContainer; }
{ size_of::<Text>() }
identifier_body
queue_alt.rs
/*! Heterogeneous Queue (alternative) This version is hand-written (no macros) but has a simpler architecture that allows implicit consumption by deconstruction on assignment. # Example ```rust use heterogene::queue_alt::{Q0,Q1,Q2}; let q = (); let q = q.append(1u); let q = q.append('c'); le...
(t1,(t2,())) } } pub trait Q2<T1,T2> { fn append<T3>(self, t3: T3) -> (T1,(T2,(T3,()))); } impl<T1,T2> Q2<T1,T2> for (T1,(T2,())) { fn append<T3>(self, t3: T3) -> (T1,(T2,(T3,()))) { let(t1,(t2,_)) = self; (t1,(t2,(t3,()))) } }
fn append<T2>(self, t2: T2) -> (T1,(T2,())) { let (t1,_) = self;
random_line_split
queue_alt.rs
/*! Heterogeneous Queue (alternative) This version is hand-written (no macros) but has a simpler architecture that allows implicit consumption by deconstruction on assignment. # Example ```rust use heterogene::queue_alt::{Q0,Q1,Q2}; let q = (); let q = q.append(1u); let q = q.append('c'); le...
<T2>(self, t2: T2) -> (T1,(T2,())) { let (t1,_) = self; (t1,(t2,())) } } pub trait Q2<T1,T2> { fn append<T3>(self, t3: T3) -> (T1,(T2,(T3,()))); } impl<T1,T2> Q2<T1,T2> for (T1,(T2,())) { fn append<T3>(self, t3: T3) -> (T1,(T2,(T3,()))) { let(t1,(t2,_)) = self; (t1,(t2,(t3,(...
append
identifier_name
queue_alt.rs
/*! Heterogeneous Queue (alternative) This version is hand-written (no macros) but has a simpler architecture that allows implicit consumption by deconstruction on assignment. # Example ```rust use heterogene::queue_alt::{Q0,Q1,Q2}; let q = (); let q = q.append(1u); let q = q.append('c'); le...
} pub trait Q2<T1,T2> { fn append<T3>(self, t3: T3) -> (T1,(T2,(T3,()))); } impl<T1,T2> Q2<T1,T2> for (T1,(T2,())) { fn append<T3>(self, t3: T3) -> (T1,(T2,(T3,()))) { let(t1,(t2,_)) = self; (t1,(t2,(t3,()))) } }
{ let (t1,_) = self; (t1,(t2,())) }
identifier_body
transaction_map.rs
use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied,Vacant}; use primitive::{UInt256,Transaction}; #[derive(PartialEq)] pub enum TransactionIndexStatus { Init = 0, Get = 1, } pub struct TransactionIndex { status: TransactionIndexStatus, hash: UInt256, transaction: Option<...
pub fn get_hash(&self) -> &UInt256 { &self.hash } pub fn get_transaction(&self) -> &Option<Transaction> { &self.transaction } pub fn set_transaction(&mut self, transaction: Transaction) { self.transaction = Some(transaction); self.status = TransactionIndexStatus::Get; } pub fn ad...
random_line_split
transaction_map.rs
use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied,Vacant}; use primitive::{UInt256,Transaction}; #[derive(PartialEq)] pub enum TransactionIndexStatus { Init = 0, Get = 1, } pub struct TransactionIndex { status: TransactionIndexStatus, hash: UInt256, transaction: Option<...
(&self, hash: &UInt256) -> Option<&TransactionIndex> { self.map.get(hash) } pub fn get_mut(&mut self, hash: &UInt256) -> Option<&mut TransactionIndex> { self.map.get_mut(hash) } pub fn insert(&mut self, hash: &UInt256) -> Result<&mut TransactionIndex, &mut TransactionIndex> { match self.ma...
get
identifier_name
simd_add.rs
#![feature(test)] #![feature(core)] use std::simd::f32x4; macro_rules! assert_equal_len { ($a:ident, $b: ident) => { assert!($a.len() == $b.len(), "add_assign: dimension mismatch: {:?} += {:?}", ($a.len(),), ($b.len(),)); } } // element-wise addition fn...
(xs: &mut Vec<f32>, ys: &Vec<f32>) { assert_equal_len!(xs, ys); let size = xs.len() as isize; let chunks = size / 4; // pointer to the start of the vector data let p_x: *mut f32 = xs.as_mut_ptr(); let p_y: *const f32 = ys.as_ptr(); // sum excess elements that don't fit in the simd vector ...
simd_add_assign
identifier_name
simd_add.rs
#![feature(test)] #![feature(core)] use std::simd::f32x4; macro_rules! assert_equal_len { ($a:ident, $b: ident) => { assert!($a.len() == $b.len(), "add_assign: dimension mismatch: {:?} += {:?}", ($a.len(),), ($b.len(),)); } } // element-wise addition fn...
// simd accelerated addition fn simd_add_assign(xs: &mut Vec<f32>, ys: &Vec<f32>) { assert_equal_len!(xs, ys); let size = xs.len() as isize; let chunks = size / 4; // pointer to the start of the vector data let p_x: *mut f32 = xs.as_mut_ptr(); let p_y: *const f32 = ys.as_ptr(); // sum e...
{ assert_equal_len!(xs, ys); for (x, y) in xs.iter_mut().zip(ys.iter()) { *x += *y; } }
identifier_body
simd_add.rs
#![feature(test)] #![feature(core)] use std::simd::f32x4; macro_rules! assert_equal_len { ($a:ident, $b: ident) => { assert!($a.len() == $b.len(), "add_assign: dimension mismatch: {:?} += {:?}", ($a.len(),), ($b.len(),)); } } // element-wise addition fn...
} } } mod bench { extern crate test; use self::test::Bencher; use std::iter; static BENCH_SIZE: usize = 10_000; macro_rules! bench { ($name:ident, $func:ident) => { #[bench] fn $name(b: &mut Bencher) { let mut x: Vec<_> = iter::repeat(1.0...
// sum "simd vector" for i in 0..chunks { unsafe { *simd_p_x.offset(i) += *simd_p_y.offset(i);
random_line_split
context.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl RustcFlags { fn flag_strs(&self) -> ~[~str] { let linker_flag = match self.linker { Some(ref l) => ~[~"--linker", l.clone()], None => ~[] }; let link_args_flag = match self.link_args { Some(ref l) => ~[~"--link-args", l.clone()], None...
{ debug2!("Checking whether {} is in target", sysroot.display()); let mut p = sysroot.dir_path(); p.set_filename("rustc"); os::path_is_dir(&p) }
identifier_body
context.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ // Config strings that the user passed in with --cfg cfgs: ~[~str], // Flags to pass to rustc rustc_flags: RustcFlags, // If use_rust_path_hack is true, rustpkg searches for sources // in *package* directories that are in the RUST_PATH (for example, // FOO/src/bar-0.1 instead of FOO). The...
Context
identifier_name
context.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
#[deriving(Clone)] pub struct Context { // Config strings that the user passed in with --cfg cfgs: ~[~str], // Flags to pass to rustc rustc_flags: RustcFlags, // If use_rust_path_hack is true, rustpkg searches for sources // in *package* directories that are in the RUST_PATH (for example, /...
use extra::workcache; use rustc::driver::session::{OptLevel, No};
random_line_split
acceptor.rs
//! Future for mediating the processing of commands received from the //! CtlGateway in the Supervisor. use super::handler::CtlHandler; use crate::{ctl_gateway::server::MgrReceiver, manager::{action::ActionSender, ManagerState}}; use futures::{channel::oneshot, future::F...
Poll::Pending => { match futures::ready!(self.mgr_receiver.poll_next_unpin(cx)) { Some(cmd) => { let task = CtlHandler::new(cmd, self.state.clone(), self.action_sender.clone()); Poll::Ready(Some(...
{ error!("Error polling CtlAcceptor shutdown trigger: {}", e); Poll::Ready(None) }
conditional_block
acceptor.rs
//! Future for mediating the processing of commands received from the //! CtlGateway in the Supervisor. use super::handler::CtlHandler; use crate::{ctl_gateway::server::MgrReceiver, manager::{action::ActionSender, ManagerState}}; use futures::{channel::oneshot, future::F...
(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> { match self.shutdown_trigger.poll_unpin(cx) { Poll::Ready(Ok(())) => { info!("Signal received; stopping CtlAcceptor"); Poll::Ready(None) } Poll::Ready(Err(e)) => { ...
poll_next
identifier_name
acceptor.rs
//! Future for mediating the processing of commands received from the //! CtlGateway in the Supervisor. use super::handler::CtlHandler; use crate::{ctl_gateway::server::MgrReceiver, manager::{action::ActionSender, ManagerState}}; use futures::{channel::oneshot, future::F...
shutdown_trigger: oneshot::Receiver<()>, action_sender: ActionSender) -> Self { CtlAcceptor { mgr_receiver, state, shutdown_trigger, action_sender } } } impl Stream for CtlAcceptor { type Item...
mgr_receiver: MgrReceiver,
random_line_split
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate glob; use docopt::Docopt; use std::io::Write; use std::path::PathBuf; use glob::glob; #[cfg_attr(rustfmt, rustfmt_skip)]
Kibar imager. Helper utils to download, format, install and manage raspbery pi images for the kibar project. Usage: img install <device> img mount <device> <location> img unmount (<device> | <location>) img chroot <device> img (-h | --help | --version) Options: -h --help Show this screen. --version ...
const USAGE: &'static str = "
random_line_split
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate glob; use docopt::Docopt; use std::io::Write; use std::path::PathBuf; use glob::glob; #[cfg_attr(rustfmt, rustfmt_skip)] const USAGE: &'static str = " Kibar imager. Helper utils to download, format, install and manage raspbery pi images for the kibar pro...
{ arg_device: String, arg_location: String, cmd_install: bool, cmd_mount: bool, cmd_unmount: bool, cmd_chroot: bool, } #[derive(Debug)] struct Device { device_file: PathBuf, partitions: Vec<PathBuf>, } impl Device { // TODO pass errors up rather then just panicing fn new(devic...
Args
identifier_name
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate glob; use docopt::Docopt; use std::io::Write; use std::path::PathBuf; use glob::glob; #[cfg_attr(rustfmt, rustfmt_skip)] const USAGE: &'static str = " Kibar imager. Helper utils to download, format, install and manage raspbery pi images for the kibar pro...
}
{ let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); if args.cmd_install { unimplemented!() } else if args.cmd_mount { let d = Device::new(args.arg_device); printl...
identifier_body
main.rs
extern crate rustc_serialize; extern crate docopt; extern crate glob; use docopt::Docopt; use std::io::Write; use std::path::PathBuf; use glob::glob; #[cfg_attr(rustfmt, rustfmt_skip)] const USAGE: &'static str = " Kibar imager. Helper utils to download, format, install and manage raspbery pi images for the kibar pro...
else if args.cmd_mount { let d = Device::new(args.arg_device); println!("{:?}", d); } else if args.cmd_unmount { unimplemented!(); writeln!(&mut std::io::stderr(), "Error!").unwrap(); ::std::process::exit(1) } else if args.cmd_chroot { unimplemented!() } else...
{ unimplemented!() }
conditional_block
microtask.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/. */ //! Implementation of [microtasks](https://html.spec.whatwg.org/multipage/#microtask) and //! microtask queues. I...
match *job { Microtask::Promise(ref job) => { if let Some(target) = target_provider(job.pipeline) { let _ = job.callback.Call_(&*target, ExceptionHandling::Report); } }, ...
{ if self.performing_a_microtask_checkpoint.get() { return; } // Step 1 self.performing_a_microtask_checkpoint.set(true); debug!("Now performing a microtask checkpoint"); // Steps 2 while !self.microtask_queue.borrow().is_empty() { roote...
identifier_body
microtask.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/. */ //! Implementation of [microtasks](https://html.spec.whatwg.org/multipage/#microtask) and //! microtask queues. I...
(&self, job: Microtask, cx: JSContext) { self.microtask_queue.borrow_mut().push(job); unsafe { JobQueueMayNotBeEmpty(*cx) }; } /// <https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint> /// Perform a microtask checkpoint, executing all queued microtasks until the queue is ...
enqueue
identifier_name
microtask.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/. */ //! Implementation of [microtasks](https://html.spec.whatwg.org/multipage/#microtask) and //! microtask queues. I...
}, Microtask::CustomElementReaction => { ScriptThread::invoke_backup_element_queue(); }, Microtask::NotifyMutationObservers => { MutationObserver::notify_mutation_observers(); ...
task.handler(); }, Microtask::ImageElement(ref task) => { task.handler();
random_line_split
microtask.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/. */ //! Implementation of [microtasks](https://html.spec.whatwg.org/multipage/#microtask) and //! microtask queues. I...
}, Microtask::MediaElement(ref task) => { task.handler(); }, Microtask::ImageElement(ref task) => { task.handler(); }, Microtask::CustomElementReaction...
{ let _ = job.callback.Call_(&*target, ExceptionHandling::Report); }
conditional_block
fn_to_numeric_cast_any.rs
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::FN_TO_NUMERIC_CAST_ANY; pub(super) fn
(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { // We allow casts from any function type to any function type. match cast_to.kind() { ty::FnDef(..) | ty::FnPtr(..) => return, _ => { /* continue to checks */ }, } match cast_from.kind() ...
check
identifier_name
fn_to_numeric_cast_any.rs
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability;
use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::FN_TO_NUMERIC_CAST_ANY; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { // We allow casts from any function type to...
random_line_split
fn_to_numeric_cast_any.rs
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::FN_TO_NUMERIC_CAST_ANY; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, ca...
, } }
{}
conditional_block
fn_to_numeric_cast_any.rs
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use super::FN_TO_NUMERIC_CAST_ANY; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, ca...
); }, _ => {}, } }
{ // We allow casts from any function type to any function type. match cast_to.kind() { ty::FnDef(..) | ty::FnPtr(..) => return, _ => { /* continue to checks */ }, } match cast_from.kind() { ty::FnDef(..) | ty::FnPtr(_) => { let mut applicability = Applicability::May...
identifier_body
init.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::RegisterBindings; use crate::dom::bindings::proxyhandler; use crate::script_ru...
let mut rlim = libc::rlimit { rlim_cur: 0, rlim_max: 0, }; match libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) { 0 => { if rlim.rlim_cur >= MAX_FILE_LIMIT { // we have more than enough return; ...
// Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe {
random_line_split
init.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::RegisterBindings; use crate::dom::bindings::proxyhandler; use crate::script_ru...
pub fn init_service_workers(sw_senders: SWManagerSenders) { // Spawn the service worker manager passing the constellation sender ServiceWorkerManager::spawn_manager(sw_senders); } #[allow(unsafe_code)] pub fn init() -> JSEngineSetup { unsafe { proxyhandler::init(); // Create the global v...
{}
identifier_body
init.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::RegisterBindings; use crate::dom::bindings::proxyhandler; use crate::script_ru...
() { // 4096 is default max on many linux systems const MAX_FILE_LIMIT: libc::rlim_t = 4096; // Bump up our number of file descriptors to save us from impending doom caused by an onslaught // of iframes. unsafe { let mut rlim = libc::rlimit { rlim_cur: 0, rlim_max: 0...
perform_platform_specific_initialization
identifier_name
clarity_cli.rs
/* copyright: (c) 2013-2019 by Blockstack PBC, a public benefit corporation. This file is part of Blockstack. Blockstack is free software. You may redistribute 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...
() { log::set_loglevel(log::LOG_DEBUG).unwrap(); let argv : Vec<String> = env::args().collect(); clarity::invoke_command(&argv[0], &argv[1..]); }
main
identifier_name
clarity_cli.rs
/* copyright: (c) 2013-2019 by Blockstack PBC, a public benefit corporation. This file is part of Blockstack. Blockstack is free software. You may redistribute 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...
{ log::set_loglevel(log::LOG_DEBUG).unwrap(); let argv : Vec<String> = env::args().collect(); clarity::invoke_command(&argv[0], &argv[1..]); }
identifier_body
clarity_cli.rs
/* copyright: (c) 2013-2019 by Blockstack PBC, a public benefit corporation. This file is part of Blockstack.
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. Blockstack is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, including without the implied warranty of MERCHANTABILI...
Blockstack is free software. You may redistribute or modify
random_line_split