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
base64.rs
/// Entry point for encoding input strings into base64-encoded output strings. pub fn encode(inp: &str) -> String { let base64_index = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" .chars() .collect::<Vec<char>>(); let mut result = String:...
#[test] fn decode_man() { assert_eq!("Man".to_owned(), decode("TWFu")); } #[test] fn decode_leviathan() { assert_eq!(leviathan(), decode(leviathan_b64())); } }
{ assert_eq!(leviathan_b64(), encode(leviathan())); }
identifier_body
request.rs
//! AWS API requests. //! //! Wraps the Hyper library to send PUT, POST, DELETE and GET requests. extern crate lazy_static; use std::env; use std::io::Read; use std::io::Error as IoError; use std::error::Error; use std::fmt; use std::collections::HashMap; use hyper::Client; use hyper::Error as HyperError; use hyper:...
} impl fmt::Display for HttpDispatchError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.message) } } impl From<HyperError> for HttpDispatchError { fn from(err: HyperError) -> HttpDispatchError { HttpDispatchError { message: err.description().to_string() } ...
}
random_line_split
request.rs
//! AWS API requests. //! //! Wraps the Hyper library to send PUT, POST, DELETE and GET requests. extern crate lazy_static; use std::env; use std::io::Read; use std::io::Error as IoError; use std::error::Error; use std::fmt; use std::collections::HashMap; use hyper::Client; use hyper::Error as HyperError; use hyper:...
(&self, request: &SignedRequest) -> Result<HttpResponse, HttpDispatchError> { let hyper_method = match request.method().as_ref() { "POST" => Method::Post, "PUT" => Method::Put, "DELETE" => Method::Delete, "GET" => Method::Get, "HEAD" => Method::Head, ...
dispatch
identifier_name
request.rs
//! AWS API requests. //! //! Wraps the Hyper library to send PUT, POST, DELETE and GET requests. extern crate lazy_static; use std::env; use std::io::Read; use std::io::Error as IoError; use std::error::Error; use std::fmt; use std::collections::HashMap; use hyper::Client; use hyper::Error as HyperError; use hyper:...
if log_enabled!(Debug) { let payload = request.payload().map(|mut payload_bytes| { let mut payload_string = String::new(); payload_bytes.read_to_string(&mut payload_string) .map(|_| payload_string) .unwrap_or_else(|_| String::f...
{ final_uri = final_uri + &format!("?{}", request.canonical_query_string()); }
conditional_block
unify_key.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 tag(_: Option<ty::FloatVid>) -> &'static str { "FloatVid" } } impl<'tcx> ToType<'tcx> for ast::FloatTy { fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { tcx.mk_mach_float(*self) } }
type Value = Option<ast::FloatTy>; fn index(&self) -> u32 { self.index } fn from_index(i: u32) -> ty::FloatVid { ty::FloatVid { index: i } }
random_line_split
unify_key.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...
(i: u32) -> ty::FloatVid { ty::FloatVid { index: i } } fn tag(_: Option<ty::FloatVid>) -> &'static str { "FloatVid" } } impl<'tcx> ToType<'tcx> for ast::FloatTy { fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { tcx.mk_mach_float(*self) } }
from_index
identifier_name
unify_key.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 tag(_: Option<ty::FloatVid>) -> &'static str { "FloatVid" } } impl<'tcx> ToType<'tcx> for ast::FloatTy { fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> { tcx.mk_mach_float(*self) } }
{ ty::FloatVid { index: i } }
identifier_body
rpath.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...
fn get_rpaths_relative_to_output(os: session::os, output: &Path, libs: &[Path]) -> ~[Path] { libs.iter().transform(|a| get_rpath_relative_to_output(os, output, a)).collect() } pub fn get_rpath_relative_to_output(os: session::os, ...
// Remove duplicates let rpaths = minimize_rpaths(rpaths); return rpaths; }
random_line_split
rpath.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...
#[test] fn test_get_absolute_rpath() { let res = get_absolute_rpath(&Path("lib/libstd.so")); debug!("test_get_absolute_rpath: %s vs. %s", res.to_str(), os::make_absolute(&Path("lib")).to_str()); assert_eq!(res, os::make_absolute(&Path("lib"))); } }
{ // this is why refinements would be nice let o = session::os_macos; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); assert_eq!(res.to_str(), ~"@executabl...
identifier_body
rpath.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 flags = rpaths_to_flags([Path("path1"), Path("path2")]); assert_eq!(flags, ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]); } #[test] fn test_prefix_rpath() { let res = get_install_prefix_rpath("triple"); let d = Path(env!("CFG_PREF...
test_rpaths_to_flags
identifier_name
binary_search.rs
fn main() { let nums = vec![1, 3, 5, 7, 9]; let find_me = 5; let result = binary_search(&nums, find_me, 0, nums.len()); println!("Given Array: {:?}", nums); match result { Some(index) => println!("Searched for {} and found index {}.", find_me, index), None => println!("Searched for...
fn binary_search(nums: &[i64], search_value: i64, left: usize, right: usize) -> Option<usize> { let mut left: usize = left; let mut right: usize = right; while left <= right { let middle = (left + right) / 2; if middle == nums.len() { break; } if nums[middle] =...
random_line_split
binary_search.rs
fn main() { let nums = vec![1, 3, 5, 7, 9]; let find_me = 5; let result = binary_search(&nums, find_me, 0, nums.len()); println!("Given Array: {:?}", nums); match result { Some(index) => println!("Searched for {} and found index {}.", find_me, index), None => println!("Searched for...
else if nums[middle] > search_value && middle!= 0 { right = middle - 1; } else { break; } } None }
{ left = middle + 1; }
conditional_block
binary_search.rs
fn main() { let nums = vec![1, 3, 5, 7, 9]; let find_me = 5; let result = binary_search(&nums, find_me, 0, nums.len()); println!("Given Array: {:?}", nums); match result { Some(index) => println!("Searched for {} and found index {}.", find_me, index), None => println!("Searched for...
} None }
{ let mut left: usize = left; let mut right: usize = right; while left <= right { let middle = (left + right) / 2; if middle == nums.len() { break; } if nums[middle] == search_value { return Some(middle); } else if nums[middle] < search_valu...
identifier_body
binary_search.rs
fn main() { let nums = vec![1, 3, 5, 7, 9]; let find_me = 5; let result = binary_search(&nums, find_me, 0, nums.len()); println!("Given Array: {:?}", nums); match result { Some(index) => println!("Searched for {} and found index {}.", find_me, index), None => println!("Searched for...
(nums: &[i64], search_value: i64, left: usize, right: usize) -> Option<usize> { let mut left: usize = left; let mut right: usize = right; while left <= right { let middle = (left + right) / 2; if middle == nums.len() { break; } if nums[middle] == search_value {...
binary_search
identifier_name
audio.rs
use docopt::ArgvMap; use toml::{Value, ParserError}; use settings::Load; #[derive(Clone, Debug)] pub struct Audio { music: bool, only: bool, } impl Default for Audio { fn default() -> Audio { Audio { music: true, only: false, } } } impl Load for Audio { fn load(&mut self, args: &ArgvMap, toml: &Va...
self.music = false; } Ok(()) } } impl Audio { #[inline(always)] pub fn music(&self) -> bool { self.music } #[inline(always)] pub fn only(&self) -> bool { self.only } }
{ let toml = toml.as_table().unwrap(); if let Some(toml) = toml.get("audio") { let toml = expect!(toml.as_table(), "`audio` must be a table"); if let Some(value) = toml.get("only") { self.only = expect!(value.as_bool(), "`audio.only` must be a boolean"); } if let Some(value) = toml.get("music") {...
identifier_body
audio.rs
use docopt::ArgvMap; use toml::{Value, ParserError}; use settings::Load; #[derive(Clone, Debug)] pub struct Audio { music: bool, only: bool, } impl Default for Audio { fn default() -> Audio { Audio { music: true, only: false, } } } impl Load for Audio { fn load(&mut self, args: &ArgvMap, toml: &Va...
impl Audio { #[inline(always)] pub fn music(&self) -> bool { self.music } #[inline(always)] pub fn only(&self) -> bool { self.only } }
}
random_line_split
audio.rs
use docopt::ArgvMap; use toml::{Value, ParserError}; use settings::Load; #[derive(Clone, Debug)] pub struct
{ music: bool, only: bool, } impl Default for Audio { fn default() -> Audio { Audio { music: true, only: false, } } } impl Load for Audio { fn load(&mut self, args: &ArgvMap, toml: &Value) -> Result<(), ParserError> { let toml = toml.as_table().unwrap(); if let Some(toml) = toml.get("audio") { ...
Audio
identifier_name
audio.rs
use docopt::ArgvMap; use toml::{Value, ParserError}; use settings::Load; #[derive(Clone, Debug)] pub struct Audio { music: bool, only: bool, } impl Default for Audio { fn default() -> Audio { Audio { music: true, only: false, } } } impl Load for Audio { fn load(&mut self, args: &ArgvMap, toml: &Va...
if args.get_bool("--no-music") { self.music = false; } Ok(()) } } impl Audio { #[inline(always)] pub fn music(&self) -> bool { self.music } #[inline(always)] pub fn only(&self) -> bool { self.only } }
{ self.only = true; }
conditional_block
geniza.rs
// Free Software under GPL-3.0, see LICENSE // Copyright 2017 Bryan Newbold extern crate clap; extern crate env_logger; #[macro_use] extern crate error_chain; extern crate geniza; extern crate sodiumoxide; // TODO: more careful import use geniza::*; use std::path::{Path, PathBuf}; use clap::{App, SubCommand}; use std...
fn run() -> Result<()> { env_logger::init().unwrap(); let matches = App::new("geniza") .version(env!("CARGO_PKG_VERSION")) .subcommand( SubCommand::with_name("clone") .about("Finds and downloads a dat archive from the network into a given folder") .arg_...
{ let mut here: &Path = &current_dir().unwrap(); loop { let check = here.join(".dat"); if check.is_dir() && check.join("metadata.tree").is_file() { return Some(check); }; here = match here.parent() { None => return None, Some(t) => t, }...
identifier_body
geniza.rs
// Free Software under GPL-3.0, see LICENSE // Copyright 2017 Bryan Newbold extern crate clap; extern crate env_logger; #[macro_use] extern crate error_chain; extern crate geniza; extern crate sodiumoxide; // TODO: more careful import use geniza::*; use std::path::{Path, PathBuf}; use clap::{App, SubCommand}; use std...
() -> Option<PathBuf> { let mut here: &Path = &current_dir().unwrap(); loop { let check = here.join(".dat"); if check.is_dir() && check.join("metadata.tree").is_file() { return Some(check); }; here = match here.parent() { None => return None, S...
find_dat_dir
identifier_name
geniza.rs
// Free Software under GPL-3.0, see LICENSE // Copyright 2017 Bryan Newbold extern crate clap; extern crate env_logger; #[macro_use] extern crate error_chain; extern crate geniza; extern crate sodiumoxide; // TODO: more careful import use geniza::*; use std::path::{Path, PathBuf}; use clap::{App, SubCommand}; use std...
.subcommand( SubCommand::with_name("ls") .about("Lists contents of the archive") .arg_from_usage("[path] 'path to display'") .arg_from_usage("--recursive'show directory recursively'"), ) .subcommand( SubCommand::with_name("seed")...
.arg_from_usage("<path> 'file to delete from dat archive'"), )
random_line_split
geniza.rs
// Free Software under GPL-3.0, see LICENSE // Copyright 2017 Bryan Newbold extern crate clap; extern crate env_logger; #[macro_use] extern crate error_chain; extern crate geniza; extern crate sodiumoxide; // TODO: more careful import use geniza::*; use std::path::{Path, PathBuf}; use clap::{App, SubCommand}; use std...
else { println!("{}\t[del] {}", entry.index, entry.path.display()); } } } ("checkout", Some(subm)) => { let _path = Path::new(subm.value_of("path").unwrap()); unimplemented!(); } ("add", Som...
{ if stat.get_blocks() == 0 { println!("{}\t[chg] {}", entry.index, entry.path.display()); } else { println!("{}\t[put] {}\t{} bytes ({} blocks)", entry.index, entry.path.dis...
conditional_block
serviceworkerjob.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/. */ //! A Job is an abstraction of async operation in service worker lifecycle propagation. //! Each Job is uniquely i...
(&self, job: Job, script_thread: &ScriptThread) { debug!("scheduling {:?} job", job.job_type); let mut queue_ref = self.0.borrow_mut(); let job_queue = queue_ref.entry(job.scope_url.clone()).or_insert(vec![]); // Step 1 if job_queue.is_empty() { let scope_url = job.sc...
schedule_job
identifier_name
serviceworkerjob.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/. */ //! A Job is an abstraction of async operation in service worker lifecycle propagation. //! Each Job is uniquely i...
else { // Step 6.1 let global = &*job.client.global(); let pipeline = global.pipeline_id(); let new_reg = ServiceWorkerRegistration::new(&*global, &job.script_url, scope_url); script_thread.handle_serviceworker_registration(&job.scope_url, &*new_reg, pipeline...
{ // Step 5.1 if reg.get_uninstalling() { reg.set_uninstalling(false); } // Step 5.3 if let Some(ref newest_worker) = reg.get_newest_worker() { if (&*newest_worker).get_script_url() == job.script_url { // Ste...
conditional_block
serviceworkerjob.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/. */ //! A Job is an abstraction of async operation in service worker lifecycle propagation. //! Each Job is uniquely i...
front_scope_url }; self.finish_job(url, script_thread); } #[allow(unrooted_must_root)] // https://w3c.github.io/ServiceWorker/#register-algorithm fn run_register(&self, job: &Job, scope_url: ServoUrl, script_thread: &ScriptThread) { debug!("running register job"); ...
JobType::Register => self.run_register(front_job, scope_url, script_thread), JobType::Update => self.update(front_job, script_thread), JobType::Unregister => unreachable!(), };
random_line_split
pg_specific_expressions_cant_be_used_in_a_sqlite_query.rs
extern crate diesel; use diesel::*; use diesel::sql_types::*; use diesel::dsl::*; use diesel::upsert::on_constraint; table! { users { id -> Integer, name -> VarChar, } } sql_function!(fn lower(x: VarChar) -> VarChar); #[derive(Insertable)] #[table_name="users"] struct
(#[column_name = "name"] &'static str); // NOTE: This test is meant to be comprehensive, but not exhaustive. fn main() { use self::users::dsl::*; let connection = SqliteConnection::establish(":memory:").unwrap(); users.select(id).filter(name.eq(any(Vec::<String>::new()))) .load::<i32>(&connection);...
NewUser
identifier_name
pg_specific_expressions_cant_be_used_in_a_sqlite_query.rs
extern crate diesel; use diesel::*; use diesel::sql_types::*; use diesel::dsl::*; use diesel::upsert::on_constraint;
table! { users { id -> Integer, name -> VarChar, } } sql_function!(fn lower(x: VarChar) -> VarChar); #[derive(Insertable)] #[table_name="users"] struct NewUser(#[column_name = "name"] &'static str); // NOTE: This test is meant to be comprehensive, but not exhaustive. fn main() { use self...
random_line_split
editor.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
<'a>(&'a Runtime<'a>); impl<'a> EditorView<'a> { pub fn new(rt: &'a Runtime) -> EditorView<'a> { EditorView(rt) } } impl<'a> Viewer for EditorView<'a> { fn view_entry(&self, e: &Entry) -> Result<()> { let mut entry = e.to_str().clone().to_string(); edit_in_tmpfile(self.0, &mut entr...
EditorView
identifier_name
editor.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
}
{ let mut entry = e.to_str().clone().to_string(); edit_in_tmpfile(self.0, &mut entry).chain_err(|| VEK::ViewError) }
identifier_body
editor.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
impl<'a> Viewer for EditorView<'a> { fn view_entry(&self, e: &Entry) -> Result<()> { let mut entry = e.to_str().clone().to_string(); edit_in_tmpfile(self.0, &mut entry).chain_err(|| VEK::ViewError) } }
random_line_split
dsp_waveforms.rs
/// DSP waveforms. use std::collections::HashMap; use std; use std::f32; /// Basic struct for holding DSP windows. pub struct DSPWindow { forms_by_bsize : HashMap<u32, Vec<f32>>, } impl DSPWindow { fn new() -> DSPWindow { let v512 = [0.0f32 ; 512]; let v2048 = [0.0f32 ; 512]; ...
() -> WaveFormCache { let m : HashMap<[u32;2], Vec<f32>> = HashMap::new(); //let mut waveforms = DSPWindow::new(); WaveFormCache { waveforms : m } } pub fn get_sine(&self, period : f32, length : usize) -> Vec<f32> { let mut toreturn : Vec<f32> = vec![0.0f32;length];...
new
identifier_name
dsp_waveforms.rs
/// DSP waveforms. use std::collections::HashMap; use std; use std::f32; /// Basic struct for holding DSP windows. pub struct DSPWindow { forms_by_bsize : HashMap<u32, Vec<f32>>, } impl DSPWindow { fn new() -> DSPWindow
} /// Convert amplitude to dbfs value. /// # Parameters /// /// `amplitude` : An amplitude, usually in the range 0.0 to 1.0. /// /// # Returns /// An f32 which usually spans between 0.0 to -infinity. pub fn ampl2dbfs(amplitude : f32) -> f32 { 10.0 * amplitude.log10() } pub struct DSPWindowCollection ...
{ let v512 = [0.0f32 ; 512]; let v2048 = [0.0f32 ; 512]; let mut m : HashMap<u32, Vec<f32>> = HashMap::new(); //(); DSPWindow { forms_by_bsize : m } }
identifier_body
dsp_waveforms.rs
/// DSP waveforms. use std::collections::HashMap; use std; use std::f32; /// Basic struct for holding DSP windows. pub struct DSPWindow { forms_by_bsize : HashMap<u32, Vec<f32>>, } impl DSPWindow { fn new() -> DSPWindow { let v512 = [0.0f32 ; 512]; let v2048 = [0.0f32 ; 512]; ...
/// /// # Returns /// An f32 which usually spans between 0.0 to -infinity. pub fn ampl2dbfs(amplitude : f32) -> f32 { 10.0 * amplitude.log10() } pub struct DSPWindowCollection { hamming : DSPWindow, } impl DSPWindowCollection { fn new() -> DSPWindowCollection { let mut hamming = DSPWin...
random_line_split
state_cache.rs
// Copyright 2016 The xi-editor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
} /// Get the cache entry at the given line number, creating it if necessary. /// Returns None if line_num > number of newlines in doc (ie if it references /// the end of the partial line at EOF). fn get_entry<DS>(&mut self, source: &DS, line_num: usize) -> Option<&mut CacheEntry<S>> where ...
if let Some(entry) = self.get_entry(source, line_num) { entry.user_state = Some(s); }
random_line_split
state_cache.rs
// Copyright 2016 The xi-editor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
ix -= 1; } } (0, 0, S::default()) } /// Get the state at the given line number, if it exists in the cache. pub fn get(&self, line_num: usize) -> Option<&S> { self.find_line(line_num).ok().and_then(|ix| self.state_cache[ix].user_state.as_ref()) } ...
{ break; }
conditional_block
state_cache.rs
// Copyright 2016 The xi-editor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
/// Find an entry in the cache by offset. Similar to `find_line`. pub fn find_offset(&self, offset: usize) -> Result<usize, usize> { self.state_cache.binary_search_by(|probe| probe.offset.cmp(&offset)) } /// Get the state from the nearest cache entry at or before given line number. /// Re...
{ self.state_cache.binary_search_by(|probe| probe.line_num.cmp(&line_num)) }
identifier_body
state_cache.rs
// Copyright 2016 The xi-editor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
(&mut self, new_frontier: usize) { self.cache.update_frontier(new_frontier) } pub fn close_frontier(&mut self) { self.cache.close_frontier() } pub fn reset(&mut self) { self.cache.reset() } pub fn find_offset(&self, offset: usize) -> Result<usize, usize> { self...
update_frontier
identifier_name
boxed.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...
#[inline] fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> { PartialOrd::partial_cmp(&**self, &**other) } #[inline] fn lt(&self, other: &Box<T>) -> bool { PartialOrd::lt(&**self, &**other) } #[inline] fn le(&self, other: &Box<T>) -> bool { PartialOrd::le(&**self, &**other) }...
impl<Sized? T: PartialOrd> PartialOrd for Box<T> {
random_line_split
boxed.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...
} impl<Sized? T: PartialEq> PartialEq for Box<T> { #[inline] fn eq(&self, other: &Box<T>) -> bool { PartialEq::eq(&**self, &**other) } #[inline] fn ne(&self, other: &Box<T>) -> bool { PartialEq::ne(&**self, &**other) } } impl<Sized? T: PartialOrd> PartialOrd for Box<T> { #[inline] fn partial_c...
{ (**self).clone_from(&(**source)); }
identifier_body
boxed.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 = box 8u as Box<Any>; let b = box Test as Box<Any>; match a.downcast::<uint>() { Ok(a) => { assert!(a == box 8u); } Err(..) => panic!() } match b.downcast::<Test>() { Ok(a) => { assert!(a == box Test); } Err(..) => panic...
any_move
identifier_name
model.rs
use Lattice::events::Events; use Lattice::view::View; use ::view::{GameView, Home, Memorial, NewGame, LoadGame, GameHome}; use ::controller::{GameControl}; use ::time; use ::agent::{Class}; use std::sync::{Mutex}; use std::ops::{DerefMut}; lazy_static! { pub static ref GAME_CONTROL: Mutex<GameControl> = Mutex::new...
() -> GameState { GameState { view: GameView::new(), } } pub fn cycle(s: f64, u: u64) -> usize { (((time::precise_time_s().abs()/s) as u64) % u) as usize } pub fn next_frame(&mut self, events: &mut Events) -> View { self.view.new_frame(); { let mut gmc = GAM...
new
identifier_name
model.rs
use Lattice::events::Events; use Lattice::view::View; use ::view::{GameView, Home, Memorial, NewGame, LoadGame, GameHome}; use ::controller::{GameControl}; use ::time; use ::agent::{Class}; use std::sync::{Mutex}; use std::ops::{DerefMut}; lazy_static! { pub static ref GAME_CONTROL: Mutex<GameControl> = Mutex::new...
pub fn next_frame(&mut self, events: &mut Events) -> View { self.view.new_frame(); { let mut gmc = GAME_CONTROL.lock().unwrap(); let mut new_game = None; { let ref mut gm = gmc.deref_mut(); let ref friend = gm.target_friend; let ref mut ma...
{ (((time::precise_time_s().abs()/s) as u64) % u) as usize }
identifier_body
model.rs
use Lattice::events::Events; use Lattice::view::View; use ::view::{GameView, Home, Memorial, NewGame, LoadGame, GameHome}; use ::controller::{GameControl}; use ::time; use ::agent::{Class}; use std::sync::{Mutex}; use std::ops::{DerefMut}; lazy_static! { pub static ref GAME_CONTROL: Mutex<GameControl> = Mutex::new...
else if msg[0].as_str() == "control" && msg[1].as_str()=="transition" { if msg[2].as_str()=="home" { self.view = GameView::Home(Home::new()); } else if msg[2].as_str()=="new_game" { self.view = GameView::NewGame(NewGame::new()); ...
{ self.view.message(msg); }
conditional_block
model.rs
use Lattice::events::Events; use Lattice::view::View; use ::view::{GameView, Home, Memorial, NewGame, LoadGame, GameHome}; use ::controller::{GameControl}; use ::time; use ::agent::{Class}; use std::sync::{Mutex}; use std::ops::{DerefMut}; lazy_static! { pub static ref GAME_CONTROL: Mutex<GameControl> = Mutex::new...
for msg in events.messages.iter() { if msg[0].as_str() == "view" { self.view.message(msg); } else if msg[0].as_str() == "control" && msg[1].as_str()=="transition" { if msg[2].as_str()=="home" { self.view = GameView::Home(...
let ref mut gm = gmc.deref_mut(); let ref friend = gm.target_friend; let ref mut map = gm.map;
random_line_split
with_borders_layout.rs
extern crate wtftw; use self::wtftw::config::GeneralConfig; use self::wtftw::core::stack::Stack; use self::wtftw::layout::Layout; use self::wtftw::layout::LayoutMessage; use self::wtftw::window_system::Rectangle; use self::wtftw::window_system::Window; use self::wtftw::window_system::WindowSystem; pub struct WithBord...
fn unhook(&self, window_system: &WindowSystem, stack: &Option<Stack<Window>>, config: &GeneralConfig) { if let &Some(ref s) = stack { for window in s.integrate().into_iter() { window_system.set_window_border_width(window, config.border_width); let Rectangle(_, _...
{ Box::new(WithBordersLayout { border: self.border, layout: self.layout.copy() }) }
identifier_body
with_borders_layout.rs
extern crate wtftw; use self::wtftw::config::GeneralConfig; use self::wtftw::core::stack::Stack; use self::wtftw::layout::Layout; use self::wtftw::layout::LayoutMessage; use self::wtftw::window_system::Rectangle; use self::wtftw::window_system::Window; use self::wtftw::window_system::WindowSystem; pub struct WithBord...
} }
{ for window in s.integrate().into_iter() { window_system.set_window_border_width(window, config.border_width); let Rectangle(_, _, w, h) = window_system.get_geometry(window); window_system.resize_window(window, w + 2 * config.border_width, h + 2 * config.bord...
conditional_block
with_borders_layout.rs
extern crate wtftw; use self::wtftw::config::GeneralConfig; use self::wtftw::core::stack::Stack; use self::wtftw::layout::Layout; use self::wtftw::layout::LayoutMessage; use self::wtftw::window_system::Rectangle; use self::wtftw::window_system::Window; use self::wtftw::window_system::WindowSystem; pub struct WithBord...
(border: u32, layout: Box<Layout>) -> Box<Layout> { Box::new(WithBordersLayout { border: border, layout: layout.copy() }) } } impl Layout for WithBordersLayout { fn apply_layout(&mut self, window_system: &WindowSystem, screen: Rectangle, config: &GeneralConfig, ...
new
identifier_name
with_borders_layout.rs
extern crate wtftw; use self::wtftw::config::GeneralConfig; use self::wtftw::core::stack::Stack; use self::wtftw::layout::Layout; use self::wtftw::layout::LayoutMessage; use self::wtftw::window_system::Rectangle; use self::wtftw::window_system::Window; use self::wtftw::window_system::WindowSystem; pub struct WithBord...
} fn apply_message(&mut self, message: LayoutMessage, window_system: &WindowSystem, stack: &Option<Stack<Window>>, config: &GeneralConfig) -> bool { self.layout.apply_message(message, window_system, stack, config) } fn description(&self) -> String { self.layout...
for window in s.integrate().into_iter() { window_system.set_window_border_width(window, self.border); } } self.layout.apply_layout(window_system, screen, config, stack)
random_line_split
namespace.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 ...
fn from(impl_kind: &'a hir::ImplItemKind) -> Self { match *impl_kind { hir::ImplItemKind::Existential(..) | hir::ImplItemKind::Type(..) => Namespace::Type, hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) => Namespace::Value, } } }
} } impl<'a> From <&'a hir::ImplItemKind> for Namespace {
random_line_split
namespace.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 ...
}
{ match *impl_kind { hir::ImplItemKind::Existential(..) | hir::ImplItemKind::Type(..) => Namespace::Type, hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) => Namespace::Value, } }
identifier_body
namespace.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 ...
{ Type, Value, } impl From<ty::AssociatedKind> for Namespace { fn from(a_kind: ty::AssociatedKind) -> Self { match a_kind { ty::AssociatedKind::Existential | ty::AssociatedKind::Type => Namespace::Type, ty::AssociatedKind::Const | ty::AssociatedKind:...
Namespace
identifier_name
main.rs
extern crate rustbox; extern crate vex; extern crate getopts; use getopts::Options; use std::env; use std::path::Path; use self::rustbox::{RustBox}; use vex::editor::{State}; fn main() { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.o...
{ let brief = format!("Usage: {} FILE [options]", program); print!("{}", opts.usage(&brief)); }
identifier_body
main.rs
extern crate rustbox; extern crate vex; extern crate getopts; use getopts::Options; use std::env; use std::path::Path; use self::rustbox::{RustBox}; use vex::editor::{State}; fn main() { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.o...
let rustbox = match RustBox::init(Default::default()) { Result::Ok(v) => v, Result::Err(e) => panic!("{}", e), }; let mut state = State::new(rustbox.width(), rustbox.height()); for name in matches.free { state.open(Path::new(&name)); } state.edit(&rustbox); } fn print_usage(program: &s...
{ print_usage(&program, opts); return; }
conditional_block
main.rs
extern crate rustbox; extern crate vex; extern crate getopts; use getopts::Options; use std::env; use std::path::Path; use self::rustbox::{RustBox}; use vex::editor::{State}; fn main() { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.o...
print_usage(&program, opts); return; } let rustbox = match RustBox::init(Default::default()) { Result::Ok(v) => v, Result::Err(e) => panic!("{}", e), }; let mut state = State::new(rustbox.width(), rustbox.height()); for name in matches.free { state.open(Path::new(&name)...
Err(f) => { panic!(f.to_string()) } }; if matches.opt_present("h") {
random_line_split
main.rs
extern crate rustbox; extern crate vex; extern crate getopts; use getopts::Options; use std::env; use std::path::Path; use self::rustbox::{RustBox}; use vex::editor::{State}; fn
() { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); let matches = match opts.parse(&args[1..]) { Ok(m) => { m } Err(f) => { panic!(f.to_string()) } }; if matches.opt...
main
identifier_name
bindless.rs
/*! Without bindless textures, using a texture in a shader requires binding the texture to a specific bind point before drawing. This not only slows down rendering, but may also prevent you from grouping multiple draw calls into one because of the limitation to the number of available texture units. Instead, bindless...
*/ use texture::any::TextureAny; use TextureExt; use GlObject; use ContextExt; use gl; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use program::BlockLayout; use uniforms::AsUniformValue; use uniforms::LayoutMismatchError; use uniforms::UniformBlock; use uniforms::UniformValue; use uniforms::Unifo...
currently doesn't check whether the type of your texture matches the expected type (but it may do in the future). Binding the wrong type of texture may lead to undefined values when sampling the texture.
random_line_split
bindless.rs
/*! Without bindless textures, using a texture in a shader requires binding the texture to a specific bind point before drawing. This not only slows down rendering, but may also prevent you from grouping multiple draw calls into one because of the limitation to the number of available texture units. Instead, bindless...
} // TODO: implement `vertex::Attribute` on `TextureHandle` /// Bindless textures are not supported. #[derive(Debug, Copy, Clone)] pub struct BindlessTexturesNotSupportedError; #[cfg(test)] mod test { use std::mem; use super::TextureHandle; #[test] fn texture_handle_size() { assert_eq!(mem:...
{ BlockLayout::BasicType { ty: UniformType::Sampler2d, // TODO: wrong offset_in_buffer: base_offset, } }
identifier_body
bindless.rs
/*! Without bindless textures, using a texture in a shader requires binding the texture to a specific bind point before drawing. This not only slows down rendering, but may also prevent you from grouping multiple draw calls into one because of the limitation to the number of available texture units. Instead, bindless...
(texture: &'a ResidentTexture, _: &SamplerBehavior) -> TextureHandle<'a> { // FIXME: take sampler into account TextureHandle { value: texture.handle, marker: PhantomData, } } /// Sets the value to the given texture. #[inline] pub fn set(&mut self, texture...
new
identifier_name
lib.rs
//! //! Core library entry point. //! extern crate rustc_serialize; extern crate byteorder; extern crate bincode; extern crate flate2; extern crate rust_htslib as htslib; use std::fs; use std::io::ErrorKind; use std::process::exit; // generic functions pub fn
<P: AsRef<Path>>(filename: P) -> bool { let ref_filename = filename.as_ref(); match fs::metadata(ref_filename) { Ok(meta) => meta.is_file(), Err(err) => match err.kind() { ErrorKind::NotFound => false, _ => { println!("Failed to open file {}: {:}", ref_filename.to_string_lossy(), err); exit(-1) }, }, } ...
file_exists
identifier_name
lib.rs
//! //! Core library entry point. //! extern crate rustc_serialize; extern crate byteorder; extern crate bincode; extern crate flate2; extern crate rust_htslib as htslib; use std::fs; use std::io::ErrorKind; use std::process::exit; // generic functions
pub fn file_exists<P: AsRef<Path>>(filename: P) -> bool { let ref_filename = filename.as_ref(); match fs::metadata(ref_filename) { Ok(meta) => meta.is_file(), Err(err) => match err.kind() { ErrorKind::NotFound => false, _ => { println!("Failed to open file {}: {:}", ref_filename.to_string_lossy(), err); exi...
random_line_split
lib.rs
//! //! Core library entry point. //! extern crate rustc_serialize; extern crate byteorder; extern crate bincode; extern crate flate2; extern crate rust_htslib as htslib; use std::fs; use std::io::ErrorKind; use std::process::exit; // generic functions pub fn file_exists<P: AsRef<Path>>(filename: P) -> bool
// private modules mod randfile; // public modules pub mod tallyrun; pub mod tallyread; pub mod seqtable; pub mod fasta; pub mod filter; pub mod counts; pub mod bigwig; pub mod scale; pub mod outputfile; // C API pub mod c_api; pub use c_api::*; use std::path::Path;
{ let ref_filename = filename.as_ref(); match fs::metadata(ref_filename) { Ok(meta) => meta.is_file(), Err(err) => match err.kind() { ErrorKind::NotFound => false, _ => { println!("Failed to open file {}: {:}", ref_filename.to_string_lossy(), err); exit(-1) }, }, } }
identifier_body
disciplines.rs
use std::collections::HashMap; use crate::common::TeamSize; /// Additional fields for `Discipline` wrap. #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct AdditionalFields(pub HashMap<String, HashMap<String, String>>); /// A game discipline identity. #[derive( Clone, Debug, Defaul...
<S: Into<String>>( id: DisciplineId, name: S, short_name: S, full_name: S, copyrights: S, ) -> Discipline { Discipline { id, name: name.into(), short_name: short_name.into(), full_name: full_name.into(), copy...
new
identifier_name
disciplines.rs
use std::collections::HashMap; use crate::common::TeamSize; /// Additional fields for `Discipline` wrap. #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct AdditionalFields(pub HashMap<String, HashMap<String, String>>); /// A game discipline identity. #[derive( Clone, Debug, Defaul...
assert_eq!(d.name, "COD4:MW"); assert_eq!(d.short_name, "COD4"); assert_eq!(d.full_name, "Call of Duty 4 : Modern Warfare"); assert_eq!(d.copyrights, r#"Infinity Ward / Activision"#); assert!(d.team_size.is_some()); let ts = d.team_size.unwrap(); // safe assert_eq...
{ let string = r#"{ "id": "cod4", "name": "COD4:MW", "shortname": "COD4", "fullname": "Call of Duty 4 : Modern Warfare", "copyrights": "Infinity Ward / Activision", "team_size": { "min": 4, "max": 4 ...
identifier_body
disciplines.rs
use std::collections::HashMap; use crate::common::TeamSize; /// Additional fields for `Discipline` wrap. #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] pub struct AdditionalFields(pub HashMap<String, HashMap<String, String>>); /// A game discipline identity. #[derive( Clone, Debug, Defaul...
"additional_fields": { "field_name": { "value": "label" } } }"#; let d: Discipline = serde_json::from_str(string).unwrap(); assert_eq!(d.id.0, "cod4"); assert_eq!(d.name, "COD4:MW"); assert_eq!(d.short_n...
"max": 4 },
random_line_split
combox.rs
use super::*; use crate::attributes::{ComClass, ComInterface, HasInterface}; use crate::raw::RawComPtr; use crate::type_system::TypeSystemName; use std::sync::atomic::{AtomicU32, Ordering}; /// Pointer to a COM-enabled Rust struct. /// /// Intercom requires a specific memory layout for the COM objects so that it /// c...
(&mut self) -> &mut T { &mut self.value } } impl<T> std::ops::Deref for ComBox<T> where T: ComClass, { type Target = T; fn deref(&self) -> &T { unsafe { &(*self.data).value } } } impl<T> std::ops::DerefMut for ComBox<T> where T: ComClass, { fn deref_mut(&mut self) -...
deref_mut
identifier_name
combox.rs
use super::*; use crate::attributes::{ComClass, ComInterface, HasInterface}; use crate::raw::RawComPtr; use crate::type_system::TypeSystemName; use std::sync::atomic::{AtomicU32, Ordering}; /// Pointer to a COM-enabled Rust struct. /// /// Intercom requires a specific memory layout for the COM objects so that it /// c...
} } /// Increments the reference count. /// /// Returns the reference count after the increment. /// /// # Safety /// /// The method isn't technically unsafe in regard to Rust unsafety, but /// it's marked as unsafe to discourage it's use due to high risks of /// memory...
{ *out = std::ptr::null_mut(); e }
conditional_block
combox.rs
use super::*; use crate::attributes::{ComClass, ComInterface, HasInterface}; use crate::raw::RawComPtr; use crate::type_system::TypeSystemName; use std::sync::atomic::{AtomicU32, Ordering}; /// Pointer to a COM-enabled Rust struct. /// /// Intercom requires a specific memory layout for the COM objects so that it /// c...
} /// Type factory for the concrete COM coclass types. /// /// Includes the virtual tables required for COM method invocations, reference /// count required for `IUnknown` implementation and the custom value struct /// required for any user defined interfaces. /// /// While this struct is available for manual handlin...
{ // The ComItf temporary doesn't outlive self, making this safe. unsafe { ComRc::from(&combox.as_comitf()) } }
identifier_body
combox.rs
use super::*; use crate::attributes::{ComClass, ComInterface, HasInterface}; use crate::raw::RawComPtr; use crate::type_system::TypeSystemName; use std::sync::atomic::{AtomicU32, Ordering}; /// Pointer to a COM-enabled Rust struct. /// /// Intercom requires a specific memory layout for the COM objects so that it /// c...
{ fn as_ref(&self) -> &ComBoxData<T> { // 'data' should always be valid pointer. unsafe { self.data.as_ref().expect("ComBox had null reference") } } } impl<I: ComInterface +?Sized, T: HasInterface<I>> From<ComBox<T>> for ComRc<I> { fn from(source: ComBox<T>) -> ComRc<I> { //...
} } impl<T: ComClass> AsRef<ComBoxData<T>> for ComBox<T>
random_line_split
oss.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 anyhow::Result; use fbinit::FacebookInit; use sql_ext::facebook::MysqlOptions; use crate::{SqlConstruct, SqlShardedConstruct}; macro_...
} impl<T: SqlShardedConstruct> FbSqlShardedConstruct for T {}
{ fb_unimplemented!() }
identifier_body
oss.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 anyhow::Result; use fbinit::FacebookInit; use sql_ext::facebook::MysqlOptions; use crate::{SqlConstruct, SqlShardedConstruct}; macro_...
} } impl<T: SqlShardedConstruct> FbSqlShardedConstruct for T {}
_: &MysqlOptions, _: bool, ) -> Result<Self> { fb_unimplemented!()
random_line_split
oss.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 anyhow::Result; use fbinit::FacebookInit; use sql_ext::facebook::MysqlOptions; use crate::{SqlConstruct, SqlShardedConstruct}; macro_...
<'a>(_: FacebookInit, _: String, _: &'a MysqlOptions, _: bool) -> Result<Self> { fb_unimplemented!() } } impl<T: SqlConstruct> FbSqlConstruct for T {} /// Construct a sharded SQL data manager backed by Facebook infrastructure pub trait FbSqlShardedConstruct: SqlShardedConstruct + Sized + Send + Sync +'sta...
with_mysql
identifier_name
mfenced.rs
/* * Copyright 2017 Sreejith Krishnan R * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
(&mut self) -> &mut Any { self } fn instance_id(&self) -> &InstanceId { &self.instance_id } } impl PresentationPrivate<Mfenced> for Mfenced { fn get_specified_presentation_props(&self) -> &SpecifiedPresentationProps { &self.presentation_props } fn get_specified_present...
as_any_mut
identifier_name
mfenced.rs
/* * Copyright 2017 Sreejith Krishnan R * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
content.with_child(child); } self } pub fn with_open<'a>(&'a mut self, fence: Option<String>) -> &'a Mfenced { self.open = fence; self } pub fn open(&self) -> Option<&String> { self.open.as_ref() } pub fn with_close<'a>(&'a mut self...
{ // Separator placeholder content.with_child(Box::new(Mo::new(String::new()))); }
conditional_block
mfenced.rs
/* * Copyright 2017 Sreejith Krishnan R * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
fn instance_id(&self) -> &InstanceId { &self.instance_id } } impl PresentationPrivate<Mfenced> for Mfenced { fn get_specified_presentation_props(&self) -> &SpecifiedPresentationProps { &self.presentation_props } fn get_specified_presentation_props_mut(&mut self) -> &mut Specified...
{ self }
identifier_body
local_data.rs
`local_data_key!` macro. This macro will expand to a `static` item appropriately named and annotated. This name is then passed to the functions in this module to modify/read the slot specified by the key. ```rust use std::local_data; local_data_key!(key_int: int) local_data_key!(key_vector: ~[int]) local_data::set(...
/// Inserts a value into task local storage. If the key is already present in /// TLS, then the previous value is removed and replaced with the provided data. /// /// It is considered a runtime error to attempt to set a key which is currently /// on loan via the `get` or `get_mut` methods. pub fn set<T:'static>(key: ...
{ unsafe { libc::abort() } }
identifier_body
local_data.rs
`local_data_key!` macro. This macro will expand to a `static` item appropriately named and annotated. This name is then passed to the functions in this module to modify/read the slot specified by the key. ```rust use std::local_data; local_data_key!(key_int: int) local_data_key!(key_vector: ~[int]) local_data::set(...
(map: &mut Map, key: *libc::c_void) -> Option<uint> { // First see if the map contains this key already let curspot = map.iter().position(|entry| { match *entry { Some((ekey, _, loan)) if key == ekey => { if loan!= NoLoan { ...
insertion_position
identifier_name
local_data.rs
the `local_data_key!` macro. This macro will expand to a `static` item appropriately named and annotated. This name is then passed to the functions in this module to modify/read the slot specified by the key. ```rust use std::local_data; local_data_key!(key_int: int) local_data_key!(key_vector: ~[int]) local_data::...
assert!(get(my_key, |k| k.map(|k| (*k).clone())).is_none()); set(my_key, ~"child data"); assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"child data"); // should be cleaned up for us } // Must work multiple times a...
random_line_split
config.rs
/* * Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy,...
/// Create the config file with its default content if it does not exist. pub fn create_default_config_file(path: &Path, content: &'static str) -> Result<(), io::Error> { if!path.exists() { let mut file = File::create(path)?; write!(file, "{}", content)?; } Ok(()) } /// Parse a configurat...
{ for config_item in default_config { match config_item { DefaultConfig::Dir(directory) => create_dir_all(directory?)?, DefaultConfig::File(name, content) => create_default_config_file(&name?, content)?, } } Ok(()) }
identifier_body
config.rs
/* * Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy,...
<P: AsRef<Path>, COMM: EnumFromStr>(filename: P, user_modes: Modes, include_path: Option<PathBuf>) -> (Parser<COMM>, ParseResult<COMM>, ModesHash) { let mut parse_result = ParseResult::new(); let mut modes = HashMap::new(); for mode in user_modes { modes.insert(mode.prefix, mode.clone()); }...
parse_config
identifier_name
config.rs
/* * Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com> *
* this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to...
* Permission is hereby granted, free of charge, to any person obtaining a copy of
random_line_split
config.rs
/* * Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy,...
let file = file::open(&filename); let file = rtry_no_return!(parse_result, file, { return (parser, parse_result, modes); }); let buf_reader = BufReader::new(file); let parse_result = parser.parse(buf_reader, None); (parser, parse_result, modes) }
{ parser.set_include_path(include_path); }
conditional_block
type-id-higher-rank-2.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn get(&'a self) -> &'a str { self } } fn bad2(s: String) -> Option<&'static str> { let a: Box<Any> = Box::new(Box::new(s) as Box<for<'a> AsStr<'a, 'a>>); a.downcast_ref::<Box<for<'a> AsStr<'a,'static>>>().map(|x| x.get()) } fn main() { assert_eq!(bad1(String::from("foo")), None); assert_eq!(bad2(S...
impl<'a> AsStr<'a, 'a> for String {
random_line_split
type-id-higher-rank-2.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(s: String) -> Option<&'static str> { let a: Box<Any> = Box::new(good as fn(&String) -> Foo); a.downcast_ref::<fn(&String) -> Foo<'static>>().map(|f| f(&s).0) } trait AsStr<'a, 'b> { fn get(&'a self) -> &'b str; } impl<'a> AsStr<'a, 'a> for String { fn get(&'a self) -> &'a str { self } } fn bad2(s: St...
bad1
identifier_name
meg_csar_create.rs
extern crate megam_api; extern crate rand; extern crate rustc_serialize; extern crate term_painter; extern crate yaml_rust; extern crate toml; use std::path::Path; use util::parse_csar::CConfig; use self::term_painter::ToStyle; use self::term_painter::Color::*; use megam_api::api::Api; use self::megam_api::util::csa...
#[derive(PartialEq, Clone, Debug)] pub struct CsarCoptions { pub file: String, } impl CsarCoptions { pub fn create(&self) { let file = from_utf8(self.file.as_bytes()).unwrap(); let path = Path::new(file).to_str().unwrap(); let we = CConfig; let data = we.load(path); let mut opts = Csar:...
use self::rustc_serialize::json; use std::str::from_utf8;
random_line_split
meg_csar_create.rs
extern crate megam_api; extern crate rand; extern crate rustc_serialize; extern crate term_painter; extern crate yaml_rust; extern crate toml; use std::path::Path; use util::parse_csar::CConfig; use self::term_painter::ToStyle; use self::term_painter::Color::*; use megam_api::api::Api; use self::megam_api::util::cs...
() -> CsarCoptions { CsarCoptions { file: "".to_string() } } } pub trait CreateCSAR { fn new() -> Self; }
new
identifier_name
get_pushers.rs
//! `GET /_matrix/client/*/pushers` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3pushers use ruma_common::api::ruma_api; use serde::{Deserialize, Serialize}; use crate::push::{PusherData, PusherKind}; ruma_api! { ...
} impl Response { /// Creates a new `Response` with the given pushers. pub fn new(pushers: Vec<Pusher>) -> Self { Self { pushers } } } /// Defines a pusher. /// /// To create an instance of this type, first create a `PusherInit` and convert it via /// `P...
random_line_split
get_pushers.rs
//! `GET /_matrix/client/*/pushers` pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3pushers use ruma_common::api::ruma_api; use serde::{Deserialize, Serialize}; use crate::push::{PusherData, PusherKind}; ruma_api! { ...
{ /// A unique identifier for this pusher. /// /// The maximum allowed length is 512 bytes. pub pushkey: String, /// The kind of the pusher. pub kind: PusherKind, /// A reverse-DNS style identifier for the application. /// /// The maximum allowe...
PusherInit
identifier_name
xmlhttprequesteventtarget.rs
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::XMLHttpRequestEventTargetBinding::XMLHttpRequestEventTargetMethods; use dom::bindings::codegen::InheritTypes::EventTargetCast; use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived...
/* 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/. */
random_line_split
xmlhttprequesteventtarget.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
(type_id: XMLHttpRequestEventTargetTypeId) -> XMLHttpRequestEventTarget { XMLHttpRequestEventTarget { eventtarget: EventTarget::new_inherited(EventTargetTypeId::XMLHttpRequestEventTarget(type_id)) } } #[inline] pub fn eventtarget<'a>(&'a self) -> &'a EventTarget { &self....
new_inherited
identifier_name
xmlhttprequesteventtarget.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
} impl XMLHttpRequestEventTargetDerived for EventTarget { fn is_xmlhttprequesteventtarget(&self) -> bool { match *self.type_id() { EventTargetTypeId::XMLHttpRequestEventTarget(_) => true, _ => false } } } impl<'a> XMLHttpRequestEventTargetMethods for JSRef<'a, XMLHttpR...
{ &self.eventtarget }
identifier_body
color.rs
//! A color type, with utility methods for modifying colors and parsing colors from hex integers and strings. use std::str::FromStr; use gl; use gl::types::*; use shader::{UniformValue, UniformKind}; use buffer::VertexData; /// A color with red, green, blue and alpha components. All components are expected to be /...
; impl<'de> Visitor<'de> for ColorVisitor { type Value = Color; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("A string representing a valid hex color") } fn visit_str<E: Error>(self, v: &str) -> Result<Self::Value, E> { match Colo...
ColorVisitor
identifier_name
color.rs
//! A color type, with utility methods for modifying colors and parsing colors from hex integers and strings. use std::str::FromStr; use gl; use gl::types::*; use shader::{UniformValue, UniformKind}; use buffer::VertexData; /// A color with red, green, blue and alpha components. All components are expected to be //...
} } } // Custom serialization #[cfg(feature = "serialize")] mod serialize { use super::*; use std::fmt; use serde::{Serialize, Deserialize, Serializer, Deserializer}; use serde::de::{Visitor, Error}; impl Serialize for Color { fn serialize<S: Serializer>(&self, s: S) -> Result...
None => Err(()),
random_line_split
color.rs
//! A color type, with utility methods for modifying colors and parsing colors from hex integers and strings. use std::str::FromStr; use gl; use gl::types::*; use shader::{UniformValue, UniformKind}; use buffer::VertexData; /// A color with red, green, blue and alpha components. All components are expected to be /...
impl VertexData for Color { type Primitive = f32; fn primitives() -> usize { 4 } } impl UniformValue for Color { const KIND: UniformKind = UniformKind::VEC4_F32; unsafe fn set_uniform(color: &Color, location: GLint) { gl::Uniform4f(location, color.r, color.g, color.b, color.a); } un...
{ if value < min { return min; } if value > max { return max; } value }
identifier_body
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
} else if dom_spans.is_empty() { cx.span_lint(INHERITANCE_INTEGRITY, cx.tcx.map.expect_item(id).span, "This DOM struct has no reflector or parent DOM struct"); } } } }
db.span_note(*span, "Bare DOM struct found here"); } }
random_line_split
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
if cx.tcx.has_attr(def.def_id(), "_dom_struct_marker") { // If the field is not the first, it's probably // being misused (a) if ctr > 0 { cx.span_lint(INHERITANCE_INTEGRITY, f.sp...
{ return None; }
conditional_block
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
} impl LateLintPass for InheritancePass { fn check_struct_def(&mut self, cx: &LateContext, def: &hir::VariantData, _n: ast::Name, _gen: &hir::Generics, id: ast::NodeId) { // Lints are run post expansion, so it's fine to use // #[_dom_struct_marker] here without also checkin...
{ lint_array!(INHERITANCE_INTEGRITY) }
identifier_body
inheritance_integrity.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 rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext}; use rustc::middle::def; use...
; impl LintPass for InheritancePass { fn get_lints(&self) -> LintArray { lint_array!(INHERITANCE_INTEGRITY) } } impl LateLintPass for InheritancePass { fn check_struct_def(&mut self, cx: &LateContext, def: &hir::VariantData, _n: ast::Name, _gen: &hir::Generics, id: ast::Nod...
InheritancePass
identifier_name
asm-out-read-uninit.rs
// Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// 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. // ignore-fast #[feature] doesn't work with check-fast #![feature(asm)] fn foo(x: int) ...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
asm-out-read-uninit.rs
// Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICEN...
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] #[cfg(target_arch = "arm")] pub fn main() { let x: int; unsafe { asm!("mov $1, $0" : "=r"(x) : "r"(x)); //~ ERROR use of possibly uninitialized variable: `x` } foo(x); } #[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"), not...
{ println!("{}", x); }
identifier_body
asm-out-read-uninit.rs
// Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICEN...
(x: int) { println!("{}", x); } #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] #[cfg(target_arch = "arm")] pub fn main() { let x: int; unsafe { asm!("mov $1, $0" : "=r"(x) : "r"(x)); //~ ERROR use of possibly uninitialized variable: `x` } foo(x); } #[cfg(not(target_arch = "x86"), n...
foo
identifier_name