file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
trait-inheritance-num.rs | // xfail-fast
// 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
// <... | pub fn main() {} | random_line_split | |
scene_system.rs | use std::sync::{Arc, Mutex};
use render::camera::Camera;
#[derive(Clone,Debug)]
pub struct SceneManager {
pub inner: Arc<Mutex<u8>>,
cameras: Arc<Mutex<Vec<Camera>>>,
}
impl SceneManager{
fn new() -> Self {
SceneManager {
inner: Arc::new(Mutex::new(0)),
cameras: Arc::new(M... | } | mod tests {
use super::*;
fn test_load_obj() {
} | random_line_split |
scene_system.rs | use std::sync::{Arc, Mutex};
use render::camera::Camera;
#[derive(Clone,Debug)]
pub struct SceneManager {
pub inner: Arc<Mutex<u8>>,
cameras: Arc<Mutex<Vec<Camera>>>,
}
impl SceneManager{
fn new() -> Self {
SceneManager {
inner: Arc::new(Mutex::new(0)),
cameras: Arc::new(M... |
// fn process_input(&self, event: &glutin::Event) {
// (self.cameras.lock().unwrap())[0].process_input(event)
// }
}
#[cfg(test)]
mod tests {
use super::*;
fn test_load_obj() {
}
}
| {
(self.cameras.lock().unwrap())[0].update()
} | identifier_body |
scene_system.rs | use std::sync::{Arc, Mutex};
use render::camera::Camera;
#[derive(Clone,Debug)]
pub struct SceneManager {
pub inner: Arc<Mutex<u8>>,
cameras: Arc<Mutex<Vec<Camera>>>,
}
impl SceneManager{
fn new() -> Self {
SceneManager {
inner: Arc::new(Mutex::new(0)),
cameras: Arc::new(M... | (&self) {
(self.cameras.lock().unwrap())[0].update()
}
// fn process_input(&self, event: &glutin::Event) {
// (self.cameras.lock().unwrap())[0].process_input(event)
// }
}
#[cfg(test)]
mod tests {
use super::*;
fn test_load_obj() {
}
}
| update | identifier_name |
class-exports.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... |
pub fn main() {
assert_eq!(cat("Spreckles".to_string()).get_name(),
"Spreckles".to_string());
} | meows: 0
}
}
} | random_line_split |
class-exports.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... | {
assert_eq!(cat("Spreckles".to_string()).get_name(),
"Spreckles".to_string());
} | identifier_body | |
class-exports.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... | {
meows: usize,
name: String,
}
impl cat {
pub fn get_name(&self) -> String { self.name.clone() }
}
pub fn cat(in_name: String) -> cat {
cat {
name: in_name,
meows: 0
}
}
}
pub fn main() {
assert_eq!(cat("Spreckles".to_string()).g... | cat | identifier_name |
config.rs | use std::fs;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use failure::format_err;
use serde_derive::{Deserialize, Serialize};
use toml;
use crate::db::Database;
use crate::errors::*;
use crate::repos;
use crate::users;
pub struct Config {
pub ma... | pub pass_hash: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct SlackConfig {
pub bot_token: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct GithubConfig {
pub webhook_secret: String,
pub host: String,
pub api_token: Option<String>,
pub app_id: Option<u... | pub struct MetricsConfig {
pub salt: String, | random_line_split |
config.rs | use std::fs;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use failure::format_err;
use serde_derive::{Deserialize, Serialize};
use toml;
use crate::db::Database;
use crate::errors::*;
use crate::repos;
use crate::users;
pub struct Config {
pub ma... |
}
pub fn resolved_states(&self) -> Vec<String> {
if let Some(ref states) = self.resolved_states {
states.clone() // hmm. do these w/o a clone?
} else {
vec!["Resolved".into(), "Done".into()]
}
}
pub fn fixed_resolutions(&self) -> Vec<String> {
i... | {
vec!["Pending Review".into()]
} | conditional_block |
config.rs | use std::fs;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use failure::format_err;
use serde_derive::{Deserialize, Serialize};
use toml;
use crate::db::Database;
use crate::errors::*;
use crate::repos;
use crate::users;
pub struct Config {
pub ma... | (&self) -> Vec<String> {
if let Some(ref states) = self.progress_states {
states.clone() // hmm. do these w/o a clone?
} else {
vec!["In Progress".into()]
}
}
pub fn review_states(&self) -> Vec<String> {
if let Some(ref states) = self.review_states {
... | progress_states | identifier_name |
htmlulistelement.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::HTMLUListElementBinding;
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::... |
pub fn SetType(&mut self, _type: &DOMString) -> ErrorResult {
Ok(())
}
}
| {
None
} | identifier_body |
htmlulistelement.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::HTMLUListElementBinding; | use dom::element::HTMLUListElementTypeId;
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, Node, ScriptView};
pub struct HTMLUListElement {
htmlelement: HTMLElement
}
impl HTMLUListElement {
pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLUListElement {
HTMLULi... | use dom::bindings::utils::{DOMString, ErrorResult};
use dom::document::AbstractDocument; | random_line_split |
htmlulistelement.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::HTMLUListElementBinding;
use dom::bindings::utils::{DOMString, ErrorResult};
use dom::... | {
htmlelement: HTMLElement
}
impl HTMLUListElement {
pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLUListElement {
HTMLUListElement {
htmlelement: HTMLElement::new(HTMLUListElementTypeId, localName, document)
}
}
pub fn new(localName: ~str, docume... | HTMLUListElement | identifier_name |
supports_rule.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/. */
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
use crate::parser::ParserContext;... | (pub String);
impl ToCss for RawSelector {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
dest.write_str(&self.0)
}
}
impl RawSelector {
/// Tries to evaluate a `selector()` function.
pub fn eval(&self, context: &ParserContext, namespaces: &Namesp... | RawSelector | identifier_name |
supports_rule.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/. */
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
use crate::parser::ParserContext;... | }
}
}
#[cfg(feature = "gecko")]
fn eval_moz_bool_pref(name: &CStr, cx: &ParserContext) -> bool {
use crate::gecko_bindings::bindings;
if!cx.in_ua_or_chrome_sheet() {
return false;
}
unsafe { bindings::Gecko_GetBoolPrefValue(name.as_ptr()) }
}
#[cfg(feature = "servo")]
fn eval_moz_b... | random_line_split | |
ffi.rs | #![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use std::os::raw::c_ulong;
pub type dssim_px_t = f32;
#[link(name = "Accelerate", kind = "framework")]
#[cfg(target_os = "macos")]
extern "C" {
pub fn vImageConvolve_PlanarF(src: *const vImage_Buffer<*const f32>,
... | <T> {
pub data: T,
pub height: vImagePixelCount,
pub width: vImagePixelCount,
pub rowBytes: usize,
}
| vImage_Buffer | identifier_name |
ffi.rs | #![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use std::os::raw::c_ulong;
pub type dssim_px_t = f32;
#[link(name = "Accelerate", kind = "framework")]
#[cfg(target_os = "macos")]
extern "C" {
pub fn vImageConvolve_PlanarF(src: *const vImage_Buffer<*const f32>,
... |
/* Use the nearest pixel for missing pixels. */
kvImageEdgeExtend = 8,
/* Pass to turn off internal tiling and disable internal multithreading. Use this if
you want to do your own tiling, or to use the Min/Max filters in place. */
kvImageDoNotTile = 16,
/* Use a higher quality, slower re... | random_line_split | |
nested-matchs.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() { foo(); } | random_line_split | |
nested-matchs.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 ... | () ->! { panic!(); }
fn foo() {
match Some::<int>(5) {
Some::<int>(_x) => {
let mut bar;
match None::<int> { None::<int> => { bar = 5; } _ => { baz(); } }
println!("{}", bar);
}
None::<int> => { println!("hello"); }
}
}
pub fn main() { foo(); }
| baz | identifier_name |
nested-matchs.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() { foo(); }
| {
match Some::<int>(5) {
Some::<int>(_x) => {
let mut bar;
match None::<int> { None::<int> => { bar = 5; } _ => { baz(); } }
println!("{}", bar);
}
None::<int> => { println!("hello"); }
} | identifier_body |
file_logger.rs | use std::io::Write;
use std::fs::{File, OpenOptions};
use {Logger, MessageType, format_message};
/// Write log to text file.
pub struct FileLogger {
log_file: String
}
impl FileLogger {
pub fn | (file_path: &str) -> FileLogger {
File::create(file_path).unwrap();
FileLogger { log_file: file_path.to_string() }
}
}
impl Logger for FileLogger {
fn log(&self, msg_type:MessageType, message:&str) {
let mut file = OpenOptions::new()
.append(true)
.write(true)
.open(&se... | new | identifier_name |
file_logger.rs | use std::io::Write;
use std::fs::{File, OpenOptions}; | /// Write log to text file.
pub struct FileLogger {
log_file: String
}
impl FileLogger {
pub fn new(file_path: &str) -> FileLogger {
File::create(file_path).unwrap();
FileLogger { log_file: file_path.to_string() }
}
}
impl Logger for FileLogger {
fn log(&self, msg_type:MessageType, message:&str) {
... | use {Logger, MessageType, format_message};
| random_line_split |
file_logger.rs | use std::io::Write;
use std::fs::{File, OpenOptions};
use {Logger, MessageType, format_message};
/// Write log to text file.
pub struct FileLogger {
log_file: String
}
impl FileLogger {
pub fn new(file_path: &str) -> FileLogger {
File::create(file_path).unwrap();
FileLogger { log_file: file_path.to_string... | {
let logger = FileLogger::new("test.log");
logger.info("Test info message.");
logger.warn("Test warn message.");
logger.error("Test error message.");
} | identifier_body | |
alias-uninit-value.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 ... | () { mk_raw_ty(ty_nil, None::<~str>); }
| main | identifier_name |
alias-uninit-value.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 ... | return RawT {struct_: st, cname: cname, hash: 0u};
}
pub fn main() { mk_raw_ty(ty_nil, None::<~str>); } |
fn mk_raw_ty(st: sty, cname: Option<~str>) -> RawT { | random_line_split |
utils.rs | use std::collections::{HashSet, HashMap};
use std::iter::FromIterator;
use std::cmp::min;
use std::error::Error;
use rand::{thread_rng, Rng};
use image::{GenericImage, DynamicImage, ImageBuffer, Luma, FilterType};
use image::imageops::rotate270;
use image::imageops::colorops::grayscale;
pub fn slice(count: u32, limit:... |
fn convert(im: &DynamicImage,
size: u32)
-> Result<(f32, ImageBuffer<Luma<u8>, Vec<u8>>), Box<Error>> {
let mut conv = im.clone();
let (w, h) = conv.dimensions();
let mul = match size > 0 && (w > size || h > size) {
true => {
conv = conv.resize(size, size, Filter... | {
let mut indexes: Vec<u32> = (0..count).collect();
if limit > 0 && limit < count {
let mut rng = thread_rng();
rng.shuffle(&mut indexes);
let len = indexes.len();
indexes.truncate(min(len, limit as usize));
}
Ok(HashSet::from_iter(indexes.iter().cloned()))
} | identifier_body |
utils.rs | use std::collections::{HashSet, HashMap};
use std::iter::FromIterator;
use std::cmp::min;
use std::error::Error;
use rand::{thread_rng, Rng};
use image::{GenericImage, DynamicImage, ImageBuffer, Luma, FilterType};
use image::imageops::rotate270;
use image::imageops::colorops::grayscale;
pub fn slice(count: u32, limit:... | (strip: &mut ImageBuffer<Luma<u8>, Vec<u8>>,
x: u32,
y: u32,
width: u32,
height: u32)
-> Result<f32, Box<Error>> {
let sub = strip.sub_image(x, y, width, height);
let (w, h) = sub.dimensions();
let len = (w * h) as f32;
let hm = sub.pixels().fold(H... | entropy | identifier_name |
utils.rs | use std::collections::{HashSet, HashMap};
use std::iter::FromIterator;
use std::cmp::min;
use std::error::Error;
use rand::{thread_rng, Rng};
use image::{GenericImage, DynamicImage, ImageBuffer, Luma, FilterType};
use image::imageops::rotate270;
use image::imageops::colorops::grayscale;
pub fn slice(count: u32, limit:... | sub = center;
}
}
if sub == 0 || border == sub {
break;
}
border = sub;
if!deep {
break;
}
}
borders.push((border as f32 * mul) as u32);
if side!= 3 {
... | false => delta,
};
if diff < delta && diff < threshold {
delta = diff; | random_line_split |
mod.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... | .unwrap_or(true);
let codemap = codemap::CodeMap::new();
let diagnostic_handler =
diagnostic::Handler::new(sopts.color, Some(registry), can_print_warnings);
let span_diagnostic_handler =
diagnostic::SpanHandler::new(diagnostic_handler, codemap);
build_session_(sopts, local_crate... | .last() | random_line_split |
mod.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... | (&self, sp: Span, msg: &str) {
self.diagnostic().fileline_note(sp, msg)
}
pub fn fileline_help(&self, sp: Span, msg: &str) {
self.diagnostic().fileline_help(sp, msg)
}
pub fn note(&self, msg: &str) {
self.diagnostic().handler().note(msg)
}
pub fn help(&self, msg: &str) {
... | fileline_note | identifier_name |
mod.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... |
pub fn span_unimpl(&self, sp: Span, msg: &str) ->! {
self.diagnostic().span_unimpl(sp, msg)
}
pub fn unimpl(&self, msg: &str) ->! {
self.diagnostic().handler().unimpl(msg)
}
pub fn add_lint(&self,
lint: &'static lint::Lint,
id: ast::NodeId,
... | {
self.diagnostic().handler().bug(msg)
} | identifier_body |
processinginstruction.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding;
use crate::dom::bindings::codegen::Bin... | (
target: DOMString,
data: DOMString,
document: &Document,
) -> ProcessingInstruction {
ProcessingInstruction {
characterdata: CharacterData::new_inherited(data, document),
target: target,
}
}
pub fn new(
target: DOMString,
dat... | new_inherited | identifier_name |
processinginstruction.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding; | use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::characterdata::CharacterData;
use crate::dom::document::Document;
use crate::dom::node::Node;
use dom_struct::dom_st... | random_line_split | |
processinginstruction.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding;
use crate::dom::bindings::codegen::Bin... |
}
| {
self.target.clone()
} | identifier_body |
mod.rs | // Copyright 2016 LambdaStack All rights reserved.
//
// 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... | (buf: &[u8]) -> StreamIdentifier {
StreamIdentifier(
byteorder::BigEndian::read_u32(buf) & ((1 << 31) - 1)
)
}
pub fn encode(&self, buf: &mut [u8]) -> usize {
encode_u32(buf, self.0)
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct ErrorCode(pub u32);
... | parse | identifier_name |
mod.rs | // Copyright 2016 LambdaStack All rights reserved.
//
// 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... | pub enum HttpError {
Protocol,
Internal,
FlowControlError,
SettingsTimeout,
}
impl ErrorCode {
pub fn parse(buf: &[u8]) -> ErrorCode {
ErrorCode(byteorder::BigEndian::read_u32(buf))
}
pub fn encode(&self, buf: &mut [u8]) -> usize {
encode_u32(buf, self.0)
}
}
#[derive(... | pub struct ErrorCode(pub u32);
| random_line_split |
font_template.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 std::fs::File;
use std::io::Read;
use string_cache::Atom;
/// Platform specific font representation for Linux... | }
impl FontTemplateData {
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> FontTemplateData {
let bytes = match font_data {
Some(bytes) => {
bytes
},
None => {
// TODO: Handle file load failure!
let mut file = Fi... | /// freetype and azure directly.
#[derive(Deserialize, Serialize)]
pub struct FontTemplateData {
pub bytes: Vec<u8>,
pub identifier: Atom, | random_line_split |
font_template.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 std::fs::File;
use std::io::Read;
use string_cache::Atom;
/// Platform specific font representation for Linux... | {
pub bytes: Vec<u8>,
pub identifier: Atom,
}
impl FontTemplateData {
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> FontTemplateData {
let bytes = match font_data {
Some(bytes) => {
bytes
},
None => {
// TODO: Handle... | FontTemplateData | identifier_name |
font_template.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 std::fs::File;
use std::io::Read;
use string_cache::Atom;
/// Platform specific font representation for Linux... |
}
| {
let bytes = match font_data {
Some(bytes) => {
bytes
},
None => {
// TODO: Handle file load failure!
let mut file = File::open(&*identifier).unwrap();
let mut buffer = vec![];
file.read_to_end(&... | identifier_body |
font_template.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 std::fs::File;
use std::io::Read;
use string_cache::Atom;
/// Platform specific font representation for Linux... | ,
};
FontTemplateData {
bytes: bytes,
identifier: identifier,
}
}
}
| {
// TODO: Handle file load failure!
let mut file = File::open(&*identifier).unwrap();
let mut buffer = vec![];
file.read_to_end(&mut buffer).unwrap();
buffer
} | conditional_block |
main.rs | extern crate env_logger;
extern crate glutin;
extern crate gfx;
extern crate gfx_window_glutin;
extern crate claymore_game as game;
pub fn | () {
use gfx::traits::*;
env_logger::init().unwrap();
println!("Initializing the window...");
let window = glutin::WindowBuilder::new()
.with_title("Claymore".to_string())
.with_vsync()
.with_gl(glutin::GlRequest::Specific(glutin::Api::OpenGl, (3, 2)))
.with_srgb(Some(true)... | main | identifier_name |
main.rs | extern crate env_logger;
extern crate glutin;
extern crate gfx;
extern crate gfx_window_glutin;
extern crate claymore_game as game;
pub fn main() {
use gfx::traits::*;
env_logger::init().unwrap();
println!("Initializing the window...");
let window = glutin::WindowBuilder::new()
.with_title("Cl... | }
}
app.render(&mut stream);
stream.present(&mut device);
}
println!("Done.");
} | let (sx, sy) = stream.out.get_size();
app.mouse_click(mouse_x as f32 / sx as f32, mouse_y as f32 / sy as f32);
},
_ => (), | random_line_split |
main.rs | extern crate env_logger;
extern crate glutin;
extern crate gfx;
extern crate gfx_window_glutin;
extern crate claymore_game as game;
pub fn main() | 'main: loop {
// quit when Esc is pressed.
for event in stream.out.window.poll_events() {
use glutin::{ElementState, Event, MouseButton, VirtualKeyCode};
match event {
Event::Closed => break'main,
Event::KeyboardInput(ElementState::Pressed, _, S... | {
use gfx::traits::*;
env_logger::init().unwrap();
println!("Initializing the window...");
let window = glutin::WindowBuilder::new()
.with_title("Claymore".to_string())
.with_vsync()
.with_gl(glutin::GlRequest::Specific(glutin::Api::OpenGl, (3, 2)))
.with_srgb(Some(true... | identifier_body |
use_suggestion_placement.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 | // <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-cloudabi no std::path support
macro_rules! y {
() => {}
}
mod m {
pub const A: i32 = 0;
}
mod foo {
#[derive(Debug)]
pub stru... | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | random_line_split |
use_suggestion_placement.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 ... | ;
// test whether the use suggestion isn't
// placed into the expansion of `#[derive(Debug)]
type Bar = Path; //~ ERROR cannot find
}
fn main() {
y!();
let _ = A; //~ ERROR cannot find
foo();
}
fn foo() {
type Dict<K, V> = HashMap<K, V>; //~ ERROR cannot find
}
| Foo | identifier_name |
use_suggestion_placement.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 ... | {
type Dict<K, V> = HashMap<K, V>; //~ ERROR cannot find
} | identifier_body | |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL DMITRY VYUKOV OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITE... | *
* THIS SOFTWARE IS PROVIDED BY DMITRY VYUKOV "AS IS" AND ANY EXPRESS OR IMPLIED | random_line_split |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... |
#[test]
fn test() {
let nthreads = 8u;
let nmsgs = 1000u;
let q = Queue::new();
match q.pop() {
Empty => {}
Inconsistent | Data(..) => panic!()
}
let (tx, rx) = channel();
let q = Arc::new(q);
for _ in range(0, nthreads) ... | {
let q = Queue::new();
q.push(box 1i);
q.push(box 2i);
} | identifier_body |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... |
}
}
drop(tx);
for _ in range(0, nthreads) {
rx.recv();
}
}
}
| { i += 1 } | conditional_block |
mpsc_queue.rs | /* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of con... | (&mut self) {
unsafe {
let mut cur = *self.tail.get();
while!cur.is_null() {
let next = (*cur).next.load(Relaxed);
let _: Box<Node<T>> = mem::transmute(cur);
cur = next;
}
}
}
}
#[cfg(test)]
mod tests {
use prel... | drop | identifier_name |
optimize_dead_defs.rs | use std::collections::{HashSet};
use grit;
pub fn optimize(mut prog: grit::ProgDef) -> grit::ProgDef {
let info = collect_prog_info(&prog);
prog.fun_defs = prog.fun_defs.into_iter().filter(|def| {
info.used_funs.contains(&def.name)
}).collect();
prog.obj_defs = prog.obj_defs.into_iter().filter(|def| {
... | for arg in args.iter() {
collect_val(info, arg);
}
},
grit::Op::ExternCall(_, _, ref args) =>
for arg in args.iter() {
collect_val(info, arg);
},
grit::Op::AllocClos(ref closs) =>
for &(_, ref clos_name, ref captures) in closs.iter() {
info.used_funs.ins... | fn collect_op(info: &mut ProgInfo, op: &grit::Op) {
match *op {
grit::Op::Call(_, ref callee, ref args) => {
collect_callee(info, callee); | random_line_split |
optimize_dead_defs.rs | use std::collections::{HashSet};
use grit;
pub fn optimize(mut prog: grit::ProgDef) -> grit::ProgDef {
let info = collect_prog_info(&prog);
prog.fun_defs = prog.fun_defs.into_iter().filter(|def| {
info.used_funs.contains(&def.name)
}).collect();
prog.obj_defs = prog.obj_defs.into_iter().filter(|def| {
... | for &(_, ref val) in var_vals.iter() {
collect_val(info, val);
},
}
}
fn collect_jump(info: &mut ProgInfo, jump: &grit::Jump) {
match *jump {
grit::Jump::Goto(_) => {},
grit::Jump::TailCall(ref callee, ref args) => {
collect_callee(info, callee);
for arg in args.iter() {
... | {
match *op {
grit::Op::Call(_, ref callee, ref args) => {
collect_callee(info, callee);
for arg in args.iter() {
collect_val(info, arg);
}
},
grit::Op::ExternCall(_, _, ref args) =>
for arg in args.iter() {
collect_val(info, arg);
},
grit::Op::AllocClos(r... | identifier_body |
optimize_dead_defs.rs | use std::collections::{HashSet};
use grit;
pub fn | (mut prog: grit::ProgDef) -> grit::ProgDef {
let info = collect_prog_info(&prog);
prog.fun_defs = prog.fun_defs.into_iter().filter(|def| {
info.used_funs.contains(&def.name)
}).collect();
prog.obj_defs = prog.obj_defs.into_iter().filter(|def| {
info.used_objs.contains(&def.name)
}).collect();
... | optimize | identifier_name |
optimize_dead_defs.rs | use std::collections::{HashSet};
use grit;
pub fn optimize(mut prog: grit::ProgDef) -> grit::ProgDef {
let info = collect_prog_info(&prog);
prog.fun_defs = prog.fun_defs.into_iter().filter(|def| {
info.used_funs.contains(&def.name)
}).collect();
prog.obj_defs = prog.obj_defs.into_iter().filter(|def| {
... | ,
grit::Op::ExternCall(_, _, ref args) =>
for arg in args.iter() {
collect_val(info, arg);
},
grit::Op::AllocClos(ref closs) =>
for &(_, ref clos_name, ref captures) in closs.iter() {
info.used_funs.insert(clos_name.clone());
for capture in captures.iter() {
c... | {
collect_callee(info, callee);
for arg in args.iter() {
collect_val(info, arg);
}
} | conditional_block |
util.rs | use std::fs::{File, OpenOptions};
use std::hash::Hasher;
use std::io::{Result, Write};
use std::path::Path;
use std::result::Result::Ok;
use std::sync::atomic::{AtomicUsize, Ordering};
use twox_hash::XxHash32 as TwoXhash32;
pub struct XxHash32(TwoXhash32);
impl XxHash32 {
pub fn new() -> XxHash32 |
pub fn update(&mut self, buf: &[u8]) {
self.0.write(buf);
}
pub fn get(&self) -> u32 {
self.0.finish() as u32
}
}
impl Write for XxHash32 {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
self.update(buf);
Ok(buf.len())
}
fn flush(&mut self) -> Result<... | {
XxHash32(TwoXhash32::with_seed(0))
} | identifier_body |
util.rs | use std::fs::{File, OpenOptions};
use std::hash::Hasher;
use std::io::{Result, Write};
use std::path::Path;
use std::result::Result::Ok;
use std::sync::atomic::{AtomicUsize, Ordering};
use twox_hash::XxHash32 as TwoXhash32;
pub struct XxHash32(TwoXhash32);
impl XxHash32 {
pub fn new() -> XxHash32 {
XxHas... |
pub fn get_file_handle(path: &Path, write: bool) -> Result<File> {
if write {
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(path)
} else {
OpenOptions::new().read(true).open(path)
}
}
pub struct Sequence(AtomicUsize);
impl ... | pub fn xxhash32(buf: &[u8]) -> u32 {
let mut hash = TwoXhash32::with_seed(0);
hash.write(buf);
hash.finish() as u32
} | random_line_split |
util.rs | use std::fs::{File, OpenOptions};
use std::hash::Hasher;
use std::io::{Result, Write};
use std::path::Path;
use std::result::Result::Ok;
use std::sync::atomic::{AtomicUsize, Ordering};
use twox_hash::XxHash32 as TwoXhash32;
pub struct XxHash32(TwoXhash32);
impl XxHash32 {
pub fn new() -> XxHash32 {
XxHas... |
let exp = ((bytes as f64).ln() / (unit as f64).ln()) as usize;
let units = if si { "kMGTPE" } else { "KMGTPE" };
let pre = format!(
"{}{}",
units.chars().nth(exp - 1).unwrap(),
if si { "" } else { "i" }
);
format!("{:.1} {}B", bytes / unit.pow(exp as u32), pre)
}
| {
return format!("{} B", bytes);
} | conditional_block |
util.rs | use std::fs::{File, OpenOptions};
use std::hash::Hasher;
use std::io::{Result, Write};
use std::path::Path;
use std::result::Result::Ok;
use std::sync::atomic::{AtomicUsize, Ordering};
use twox_hash::XxHash32 as TwoXhash32;
pub struct | (TwoXhash32);
impl XxHash32 {
pub fn new() -> XxHash32 {
XxHash32(TwoXhash32::with_seed(0))
}
pub fn update(&mut self, buf: &[u8]) {
self.0.write(buf);
}
pub fn get(&self) -> u32 {
self.0.finish() as u32
}
}
impl Write for XxHash32 {
fn write(&mut self, buf: &[u8]... | XxHash32 | identifier_name |
fdentry.rs | use crate::host;
use std::fs::File;
use std::os::unix::prelude::{FileTypeExt, FromRawFd, IntoRawFd, RawFd};
use std::path::PathBuf;
#[derive(Debug)]
pub struct FdEntry {
pub fd_object: FdObject,
pub rights_base: host::__wasi_rights_t,
pub rights_inheriting: host::__wasi_rights_t,
pub preopen_path: Opti... | (rawfd: RawFd) -> FdEntry {
let (ty, mut rights_base, rights_inheriting) =
determine_type_rights(rawfd).expect("can determine file rights");
use nix::fcntl::{fcntl, OFlag, F_GETFL};
let flags_bits = fcntl(rawfd, F_GETFL).expect("fcntl succeeds");
let flags = OFlag::from_bits... | from_raw_fd | identifier_name |
fdentry.rs | use crate::host;
use std::fs::File;
use std::os::unix::prelude::{FileTypeExt, FromRawFd, IntoRawFd, RawFd};
use std::path::PathBuf;
#[derive(Debug)]
pub struct FdEntry {
pub fd_object: FdObject,
pub rights_base: host::__wasi_rights_t,
pub rights_inheriting: host::__wasi_rights_t,
pub preopen_path: Opti... |
impl Drop for FdObject {
fn drop(&mut self) {
if self.needs_close {
nix::unistd::close(self.rawfd).unwrap_or_else(|e| eprintln!("FdObject::drop(): {}", e));
}
}
} | pub needs_close: bool,
// TODO: directories
} | random_line_split |
ahoy.rs | extern crate curl;
extern crate term_painter;
extern crate rustc_serialize;
extern crate toml;
use std::path::Path;
use std::env;
use turbo::util::{CliResult, Config};
use self::term_painter::Color::*;
use self::term_painter::ToStyle;
use self::rustc_serialize::json;
use meg::util::parse_toml::Configz;
//use self::c... | let we = Configz { rand: "sample".to_string()};
let data = we.load(path);
let value: toml::Value = data.unwrap();
let host = value.lookup("api.host").unwrap().as_str().unwrap();
let res = curl::http::handle()
.get(host)
.exec();
let x = res.unwrap().get_code().to_string();
... | let path = Path::new(&set_path).to_str().unwrap(); | random_line_split |
ahoy.rs | extern crate curl;
extern crate term_painter;
extern crate rustc_serialize;
extern crate toml;
use std::path::Path;
use std::env;
use turbo::util::{CliResult, Config};
use self::term_painter::Color::*;
use self::term_painter::ToStyle;
use self::rustc_serialize::json;
use meg::util::parse_toml::Configz;
//use self::c... |
Ok(None)
}
//#[derive(Debug)]
//pub struct ErrCode {
// desc: String
//}
pub fn ahoy() -> String {
let hme = env::home_dir().unwrap();
let y = hme.to_str().unwrap();
let set_path = format!("{}/.megam/megam.toml", y.to_string());
let path = Path::new(&set_path).to_str().unwrap();
let ... | {
println!("{}",
Red.paint("Megam is down!"));
println!("{}",
Blue.paint("Please check whether your host is setup in /home/.megam/megam.toml"));
} | conditional_block |
ahoy.rs | extern crate curl;
extern crate term_painter;
extern crate rustc_serialize;
extern crate toml;
use std::path::Path;
use std::env;
use turbo::util::{CliResult, Config};
use self::term_painter::Color::*;
use self::term_painter::ToStyle;
use self::rustc_serialize::json;
use meg::util::parse_toml::Configz;
//use self::c... | ;
pub fn execute(_: Options, _: &Config) -> CliResult<Option<()>> {
//println!("executing; cmd=meg-version; args={:?}", env::args().collect::<Vec<_>>());
let code = self::ahoy();
// match self::ahoy() {
// Ok(v) => println!("Megam is up and running!"),
// Err(e) => println!("Megam... | Options | identifier_name |
ahoy.rs | extern crate curl;
extern crate term_painter;
extern crate rustc_serialize;
extern crate toml;
use std::path::Path;
use std::env;
use turbo::util::{CliResult, Config};
use self::term_painter::Color::*;
use self::term_painter::ToStyle;
use self::rustc_serialize::json;
use meg::util::parse_toml::Configz;
//use self::c... |
/*
fn error_return(result: Result<curl::http::response::Response, ErrCode>) -> Result<curl::http::response::Response, ErrCode> {
match result {
Ok(n) => {
return Ok(n)
},
Err(FailOne) => return Err(FailOne),
}
} */
| {
let hme = env::home_dir().unwrap();
let y = hme.to_str().unwrap();
let set_path = format!("{}/.megam/megam.toml", y.to_string());
let path = Path::new(&set_path).to_str().unwrap();
let we = Configz { rand: "sample".to_string()};
let data = we.load(path);
let value: toml::Value = data.unw... | identifier_body |
workernavigator.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 crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding;
use crate::dom::bindings::codegen::Bindings::... |
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
fn AppCodeName(&self) -> DOMString {
navigatorinfo::AppCodeName()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
fn Platform(&self) -> DOMString {
navigatorinfo::Platform()
}
// http... | {
navigatorinfo::AppName()
} | identifier_body |
workernavigator.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 crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding;
use crate::dom::bindings::codegen::Bindings::... | } | .or_init(|| Permissions::new(&self.global()))
} | random_line_split |
workernavigator.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 crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding;
use crate::dom::bindings::codegen::Bindings::... | (&self) -> DOMString {
navigatorinfo::Language()
}
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
fn Permissions(&self) -> DomRoot<Permissions> {
self.permissions
.or_init(|| Permissions::new(&self.global()))
}
}
| Language | identifier_name |
cast.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | <T>(arr: &ArrayRef) -> &PrimitiveArray<T>
where
T: ArrowPrimitiveType,
{
arr.as_any()
.downcast_ref::<PrimitiveArray<T>>()
.expect("Unable to downcast to primitive array")
}
/// Force downcast ArrayRef to DictionaryArray<T>
pub fn as_dictionary_array<T>(arr: &ArrayRef) -> &DictionaryArray<T>
wher... | as_primitive_array | identifier_name |
cast.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
/// Force downcast ArrayRef to DictionaryArray<T>
pub fn as_dictionary_array<T>(arr: &ArrayRef) -> &DictionaryArray<T>
where
T: ArrowDictionaryKeyType,
{
arr.as_any()
.downcast_ref::<DictionaryArray<T>>()
.expect("Unable to downcast to dictionary array")
}
macro_rules! array_downcast_fn {
(... | {
arr.as_any()
.downcast_ref::<PrimitiveArray<T>>()
.expect("Unable to downcast to primitive array")
} | identifier_body |
cast.rs | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | }
/// Force downcast ArrayRef to DictionaryArray<T>
pub fn as_dictionary_array<T>(arr: &ArrayRef) -> &DictionaryArray<T>
where
T: ArrowDictionaryKeyType,
{
arr.as_any()
.downcast_ref::<DictionaryArray<T>>()
.expect("Unable to downcast to dictionary array")
}
macro_rules! array_downcast_fn {
... | random_line_split | |
rectangle_wave.rs | //! Game Boy sounds 1 and 2 generate a rectangular waveform
//! with an envelope function. Channel 1 can also sweep through a
//! frequency range.
use spu::{Sample, Mode};
use spu::envelope::Envelope;
pub struct RectangleWave {
/// True if the sound is generating samples
running: bool,
/// Signal d... | return Some(div);
}
// Update the frequency
let offset = div >> (self.shift as usize);
match self.direction {
SweepDirection::Up => {
let div = div + offset;
if div > 0x7ff {
// We stop on overflow
... | // Do nothing and wait for the next step | random_line_split |
rectangle_wave.rs | //! Game Boy sounds 1 and 2 generate a rectangular waveform
//! with an envelope function. Channel 1 can also sweep through a
//! frequency range.
use spu::{Sample, Mode};
use spu::envelope::Envelope;
pub struct RectangleWave {
/// True if the sound is generating samples
running: bool,
/// Signal d... |
pub fn mode(&self) -> Mode {
self.mode
}
pub fn set_mode(&mut self, mode: Mode) {
self.mode = mode;
}
pub fn set_length(&mut self, len: u8) {
if len >= 64 {
panic!("sound length out of range: {}", len);
}
let len = len as u32;
self.rem... | {
// New envelope will become active at the next start
self.start_envelope = envelope;
if !envelope.dac_enabled() {
self.running = false;
}
} | identifier_body |
rectangle_wave.rs | //! Game Boy sounds 1 and 2 generate a rectangular waveform
//! with an envelope function. Channel 1 can also sweep through a
//! frequency range.
use spu::{Sample, Mode};
use spu::envelope::Envelope;
pub struct | {
/// True if the sound is generating samples
running: bool,
/// Signal duty cycle
duty: DutyCycle,
/// Period counter, the period length is configurable and is used
/// to select the desired output frequency. This counter loops 8
/// times per cycle to let us generate the ... | RectangleWave | identifier_name |
mtwt.rs | ), 181-216.
//! DOI=10.1017/S0956796812000093 http://dx.doi.org/10.1017/S0956796812000093
pub use self::SyntaxContext_::*;
use ast::{Ident, Mrk, Name, SyntaxContext};
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
/// The SCTable contains a table of Syntax... | let resolvedthis =
resolve_internal(Ident{name:id.name, ctxt:subctxt},
table, resolve_table);
if (resolvedthis == resolvedfrom)
&& (marksof_internal(ctxt, resolvedthis, table)
== marksof_... | table, resolve_table); | random_line_split |
mtwt.rs | -216.
//! DOI=10.1017/S0956796812000093 http://dx.doi.org/10.1017/S0956796812000093
pub use self::SyntaxContext_::*;
use ast::{Ident, Mrk, Name, SyntaxContext};
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
/// The SCTable contains a table of SyntaxContex... | ,
Mark(mark, tl) => {
xor_push(&mut result, mark);
loopvar = tl;
},
Rename(_,name,tl) => {
// see MTWT for details on the purpose of the stopname.
// short version: it prevents duplication of effort.
if n... | {
return result;
} | conditional_block |
mtwt.rs | 181-216.
//! DOI=10.1017/S0956796812000093 http://dx.doi.org/10.1017/S0956796812000093
pub use self::SyntaxContext_::*;
use ast::{Ident, Mrk, Name, SyntaxContext};
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
/// The SCTable contains a table of SyntaxCo... | () {
let stopname = Name(242);
let name1 = Name(243);
let mut t = new_sctable_internal();
assert_eq!(marksof_internal (EMPTY_CTXT,stopname,&t),Vec::new());
// FIXME #5074: ANF'd to dodge nested calls
{ let ans = unfold_marks(vec!(4,98),EMPTY_CTXT,&mut t);
assert... | test_marksof | identifier_name |
mtwt.rs | 181-216.
//! DOI=10.1017/S0956796812000093 http://dx.doi.org/10.1017/S0956796812000093
pub use self::SyntaxContext_::*;
use ast::{Ident, Mrk, Name, SyntaxContext};
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
/// The SCTable contains a table of SyntaxCo... |
#[test]
fn test_unfold_refold(){
let mut t = new_sctable_internal();
let test_sc = vec!(M(3),R(id(101,0),Name(14)),M(9));
assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4);
{
let table = t.table.borrow();
assert!((*table)[2] == Mark(9,0));... | {
let mut result = Vec::new();
loop {
let table = table.table.borrow();
match (*table)[sc as uint] {
EmptyCtxt => {return result;},
Mark(mrk,tail) => {
result.push(M(mrk));
sc = tail;
cont... | identifier_body |
multiwindow.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/. */
extern crate app_units;
extern crate euclid;
extern crate gleam;
extern crate glutin;
extern crate webrender;
use... | {
events_proxy: glutin::EventsLoopProxy,
}
impl Notifier {
fn new(events_proxy: glutin::EventsLoopProxy) -> Notifier {
Notifier { events_proxy }
}
}
impl RenderNotifier for Notifier {
fn clone(&self) -> Box<RenderNotifier> {
Box::new(Notifier {
events_proxy: self.events_pr... | Notifier | identifier_name |
multiwindow.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/. */
extern crate app_units;
extern crate euclid;
extern crate gleam;
extern crate glutin;
extern crate webrender;
use... |
_ => {}
}
_ => {}
});
if do_exit {
return true
}
let framebuffer_size = {
let (width, height) = self.window.get_inner_size().unwrap();
DeviceUintSize::new(width, height)
};
let device_pixel_rati... | {
println!("toggle flags {}", my_name);
renderer.toggle_debug_flags(webrender::DebugFlags::PROFILER_DBG);
} | conditional_block |
multiwindow.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/. */
extern crate app_units;
extern crate euclid;
extern crate gleam;
extern crate glutin;
extern crate webrender;
use... | .with_multitouch()
.with_dimensions(800, 600);
let window = glutin::GlWindow::new(window_builder, context_builder, &events_loop)
.unwrap();
unsafe {
window.make_current().ok();
}
let gl = match window.get_api() {
glutin::Api::Ope... | let window_builder = glutin::WindowBuilder::new()
.with_title(name) | random_line_split |
multiwindow.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/. */
extern crate app_units;
extern crate euclid;
extern crate gleam;
extern crate glutin;
extern crate webrender;
use... |
}
fn main() {
let mut win1 = Window::new("window1", ColorF::new(0.3, 0.0, 0.0, 1.0));
let mut win2 = Window::new("window2", ColorF::new(0.0, 0.3, 0.0, 1.0));
loop {
if win1.tick() {
break;
}
if win2.tick() {
break;
}
}
win1.deinit();
wi... | {
self.renderer.deinit();
} | identifier_body |
main.rs | use crossbeam::crossbeam_channel::unbounded;
use log::{debug, error, info};
use serialport::prelude::*;
#[cfg(feature = "mqtt")]
use standaertha_gateway::mqtt;
#[cfg(feature = "webthing")]
use standaertha_gateway::webthing;
use standaertha_gateway::{
append_crc16, config, slip_encode, Command, CommandType, Package,... | () -> Result<(), Box<dyn std::error::Error +'static>> {
pretty_env_logger::init();
let config = config::read_config()?;
let mut services: Vec<Box<dyn Service>> = vec![];
let (sender, recv) = unbounded();
#[cfg(feature = "mqtt")]
{
let mqtt = mqtt::init(&config, &sender)?;
if ... | main | identifier_name |
main.rs | use crossbeam::crossbeam_channel::unbounded;
use log::{debug, error, info};
use serialport::prelude::*;
#[cfg(feature = "mqtt")]
use standaertha_gateway::mqtt;
#[cfg(feature = "webthing")]
use standaertha_gateway::webthing;
use standaertha_gateway::{
append_crc16, config, slip_encode, Command, CommandType, Package,... | if thing.is_some() {
services.push(thing.unwrap());
}
}
/*
thread::spawn(move || {
loop {
let mut commands = vec![];
let notification = notifications.recv().expect("Error receiving notification");
commands.push(notification);
... | {
pretty_env_logger::init();
let config = config::read_config()?;
let mut services: Vec<Box<dyn Service>> = vec![];
let (sender, recv) = unbounded();
#[cfg(feature = "mqtt")]
{
let mqtt = mqtt::init(&config, &sender)?;
if mqtt.is_some() {
services.push(mqtt.unwrap... | identifier_body |
main.rs | use crossbeam::crossbeam_channel::unbounded; | use standaertha_gateway::mqtt;
#[cfg(feature = "webthing")]
use standaertha_gateway::webthing;
use standaertha_gateway::{
append_crc16, config, slip_encode, Command, CommandType, Package, PackageInputStream, Service,
};
use std::io::Read;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::t... | use log::{debug, error, info};
use serialport::prelude::*;
#[cfg(feature = "mqtt")] | random_line_split |
main.rs | use crossbeam::crossbeam_channel::unbounded;
use log::{debug, error, info};
use serialport::prelude::*;
#[cfg(feature = "mqtt")]
use standaertha_gateway::mqtt;
#[cfg(feature = "webthing")]
use standaertha_gateway::webthing;
use standaertha_gateway::{
append_crc16, config, slip_encode, Command, CommandType, Package,... |
});
sender.send(Command::new(CommandType::Refresh, 0)).unwrap();
let mut last_package = None;
for p in PackageInputStream::new(input) {
match p {
Ok(p) => {
if p.len() == 36 {
let pkg = Package::from_buf(&p[0..36]);
debug!("P... | {
let mut cmds = vec![c.raw()];
let now = Instant::now();
let timeout_duration = Duration::from_millis(100);
let timeout = now + timeout_duration;
let mut remaining = timeout_duration;
while let Ok(c) = recv.recv_timeout(remaining) {
... | conditional_block |
coherence-pair-covered-uncovered-1.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T>(T);
impl<T, U> Remote1<Pair<T, Local<U>>> for i32 { }
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }
| Local | identifier_name |
coherence-pair-covered-uncovered-1.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() { } | random_line_split | |
coherence-pair-covered-uncovered-1.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 ... | { } | identifier_body | |
static_lifetime.rs | // Make a constant with `'static` lifetime.
static NUM: i32 = 18;
// Returns a reference to `NUM` where its `'static`
// lifetime is coerced to that of the input argument.
fn coerce_static<'a>(_: &'a i32) -> &'a i32 {
&NUM
}
fn main() {
{
// Make a `string` literal and print it:
let static_st... | let coerced_static = coerce_static(&lifetime_num);
println!("coerced_static: {}", coerced_static);
}
println!("NUM: {} stays accessible!", NUM);
} | let lifetime_num = 9;
// Coerce `NUM` to lifetime of `lifetime_num`: | random_line_split |
static_lifetime.rs | // Make a constant with `'static` lifetime.
static NUM: i32 = 18;
// Returns a reference to `NUM` where its `'static`
// lifetime is coerced to that of the input argument.
fn coerce_static<'a>(_: &'a i32) -> &'a i32 {
&NUM
}
fn | () {
{
// Make a `string` literal and print it:
let static_string = "I'm in read-only memory";
println!("static_string: {}", static_string);
// When `static_string` goes out of scope, the reference
// can no longer be used, but the data remains in the binary.
}
... | main | identifier_name |
static_lifetime.rs | // Make a constant with `'static` lifetime.
static NUM: i32 = 18;
// Returns a reference to `NUM` where its `'static`
// lifetime is coerced to that of the input argument.
fn coerce_static<'a>(_: &'a i32) -> &'a i32 |
fn main() {
{
// Make a `string` literal and print it:
let static_string = "I'm in read-only memory";
println!("static_string: {}", static_string);
// When `static_string` goes out of scope, the reference
// can no longer be used, but the data remains in the binary.
}
... | {
&NUM
} | identifier_body |
transform.rs | use std::fmt;
use Result;
/// A scale and an offset that transforms xyz coordinates.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Transform {
/// The scale.
pub scale: f64,
/// The offset.
pub offset: f64,
}
impl Transform {
/// Applies this transform to an i32, returning a float.
///
... | else {
Ok(n as i32)
}
}
}
impl Default for Transform {
fn default() -> Transform {
Transform {
scale: 0.001,
offset: 0.,
}
}
}
impl fmt::Display for Transform {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "`{} * ... | {
Err(Error::InverseTransform {
n,
transform: *self,
})
} | conditional_block |
transform.rs | use std::fmt;
use Result;
/// A scale and an offset that transforms xyz coordinates.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Transform {
/// The scale.
pub scale: f64,
/// The offset.
pub offset: f64,
}
impl Transform {
/// Applies this transform to an i32, returning a float.
///
... | () {
let transform = Transform::default();
let n = i32::MAX as f64 * transform.scale + 1.;
assert!(transform.inverse(n).is_err());
}
#[test]
fn too_small() {
let transform = Transform::default();
let n = i32::MIN as f64 * transform.scale - 1.;
assert!(transfo... | too_large | identifier_name |
transform.rs | use std::fmt;
use Result;
/// A scale and an offset that transforms xyz coordinates.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Transform {
/// The scale.
pub scale: f64,
/// The offset.
pub offset: f64,
}
impl Transform {
/// Applies this transform to an i32, returning a float.
///
... |
#[test]
fn too_small() {
let transform = Transform::default();
let n = i32::MIN as f64 * transform.scale - 1.;
assert!(transform.inverse(n).is_err());
}
}
| {
let transform = Transform::default();
let n = i32::MAX as f64 * transform.scale + 1.;
assert!(transform.inverse(n).is_err());
} | identifier_body |
transform.rs | use std::fmt;
use Result;
/// A scale and an offset that transforms xyz coordinates.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Transform {
/// The scale.
pub scale: f64,
/// The offset.
pub offset: f64, | ///
/// # Examples
///
/// ```
/// use las::Transform;
/// let transform = Transform { scale: 2., offset: 1. };
/// assert_eq!(3., transform.direct(1));
/// ```
pub fn direct(&self, n: i32) -> f64 {
self.scale * f64::from(n) + self.offset
}
/// Applies the inverse tr... | }
impl Transform {
/// Applies this transform to an i32, returning a float. | random_line_split |
http_headers.rs | // Copyright 2020 Google LLC
//
// 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 to in ... | (&self) -> Option<ContextType> {
Some(ContextType::HttpContext)
}
fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>> {
Some(Box::new(HttpHeaders { context_id }))
}
}
struct HttpHeaders {
context_id: u32,
}
impl Context for HttpHeaders {}
impl HttpContext f... | get_type | identifier_name |
http_headers.rs | // Copyright 2020 Google LLC
//
// 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 to in ... | }
Action::Continue
}
fn on_log(&mut self) {
trace!("#{} completed.", self.context_id);
}
} | fn on_http_response_headers(&mut self, _: usize, _: bool) -> Action {
for (name, value) in &self.get_http_response_headers() {
trace!("#{} <- {}: {}", self.context_id, name, value); | random_line_split |
status.rs | #![feature(use_extern_macros)]
extern crate tapioca_testutil;
tapioca_testutil::infer_test_api!(httpbin);
use httpbin::redirect_to;
use httpbin::redirect_to::get::QueryParams;
#[test]
fn ok_err_matching() | }
#[test]
fn status_body_matching() {
let auth = httpbin::ServerAuth::new();
let query200 = QueryParams {
url: "http://httpbin.org/status/200".into(),
};
let query400 = QueryParams {
url: "http://httpbin.org/status/400".into(),
};
match redirect_to::get(&query200, auth) {
... | {
let auth = httpbin::ServerAuth::new();
let query200 = QueryParams {
url: "http://httpbin.org/status/200".into(),
};
let query400 = QueryParams {
url: "http://httpbin.org/status/400".into(),
};
match redirect_to::get(&query200, auth) {
Ok(_) => assert!(true),
... | identifier_body |
status.rs | #![feature(use_extern_macros)]
extern crate tapioca_testutil;
tapioca_testutil::infer_test_api!(httpbin);
use httpbin::redirect_to;
use httpbin::redirect_to::get::QueryParams;
#[test]
fn ok_err_matching() {
let auth = httpbin::ServerAuth::new();
let query200 = QueryParams {
url: "http://httpbin.org/... | () {
let auth = httpbin::ServerAuth::new();
let query200 = QueryParams {
url: "http://httpbin.org/status/200".into(),
};
let query400 = QueryParams {
url: "http://httpbin.org/status/400".into(),
};
match redirect_to::get(&query200, auth) {
Ok(response) => match respons... | status_body_matching | identifier_name |
status.rs | #![feature(use_extern_macros)]
extern crate tapioca_testutil;
tapioca_testutil::infer_test_api!(httpbin);
use httpbin::redirect_to;
use httpbin::redirect_to::get::QueryParams;
#[test]
fn ok_err_matching() {
let auth = httpbin::ServerAuth::new();
let query200 = QueryParams {
url: "http://httpbin.org/... | Ok(response) => match response.body() {
redirect_to::get::OkBody::Status200(_) => assert!(true),
_ => assert!(false),
},
Err(_) => assert!(false),
}
match redirect_to::get(&query400, auth) {
Ok(_) => assert!(false),
Err(response) => match response... | url: "http://httpbin.org/status/400".into(),
};
match redirect_to::get(&query200, auth) { | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.