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
triangle.rs
extern mod gl; extern mod glfw; extern mod sgl; use sgl::buffer::*; use sgl::vertex_array::*; use sgl::shader::*; use sgl::shader_program::*; fn draw_array(vao: &VertexArray,first: gl::types::GLint,size: gl::types::GLsizei) { vao.bind(); gl::DrawArrays(gl::TRIANGLES, first,size); } fn draw_element_array(vao: &V...
#[start] fn start(argc: int, argv: **u8, crate_map: *u8) -> int { // Run GLFW on the main thread std::rt::start_on_main_thread(argc, argv, crate_map, main) } fn main() { static vertices: [gl::types::GLfloat,..6] = [ -0.5, -0.5, 0.5, -0.5, -0.5, 0.5 ]; static color: [gl::types::GLfl...
{ vao.bind(); ibo.bind(); unsafe { gl::DrawElements(gl::TRIANGLES, 6, gl::UNSIGNED_INT, std::ptr::null()); } }
identifier_body
triangle.rs
extern mod gl; extern mod glfw; extern mod sgl; use sgl::buffer::*; use sgl::vertex_array::*; use sgl::shader::*; use sgl::shader_program::*; fn draw_array(vao: &VertexArray,first: gl::types::GLint,size: gl::types::GLsizei) { vao.bind(); gl::DrawArrays(gl::TRIANGLES, first,size); } fn draw_element_array(vao: &V...
(argc: int, argv: **u8, crate_map: *u8) -> int { // Run GLFW on the main thread std::rt::start_on_main_thread(argc, argv, crate_map, main) } fn main() { static vertices: [gl::types::GLfloat,..6] = [ -0.5, -0.5, 0.5, -0.5, -0.5, 0.5 ]; static color: [gl::types::GLfloat,..9] = [ ...
start
identifier_name
triangle.rs
extern mod gl; extern mod glfw; extern mod sgl; use sgl::buffer::*; use sgl::vertex_array::*; use sgl::shader::*; use sgl::shader_program::*; fn draw_array(vao: &VertexArray,first: gl::types::GLint,size: gl::types::GLsizei) { vao.bind(); gl::DrawArrays(gl::TRIANGLES, first,size); } fn draw_element_array(vao: &V...
printfln!("GLFW Error: %s", description); } do glfw::start { // Choose a GL profile that is compatible with OS X 10.7+ glfw::window_hint::context_version(4, 3); glfw::window_hint::opengl_profile(glfw::OPENGL_CORE_PROFILE); glfw::window_hint::opengl_forward_compat(true); ...
0,1,2,3,4,5 ]; do glfw::set_error_callback |_, description| {
random_line_split
parser.rs
use std::collections::HashSet; use std::ffi::OsStr; use std::ffi::OsString; use std::path::Path; use std::path::PathBuf; use anyhow::Context; use protobuf::descriptor::FileDescriptorSet; use crate::protoc; use crate::pure; use crate::which_parser::WhichParser; use crate::ParsedAndTypechecked; /// Configure and invok...
/// Use pure rust parser. pub fn pure(&mut self) -> &mut Self { self.which_parser = WhichParser::Pure; self } /// Use `protoc` for parsing. pub fn protoc(&mut self) -> &mut Self { self.which_parser = WhichParser::Protoc; self } /// Add an include directory...
{ Parser::default() }
identifier_body
parser.rs
use std::collections::HashSet; use std::ffi::OsStr; use std::ffi::OsString; use std::path::Path; use std::path::PathBuf; use anyhow::Context; use protobuf::descriptor::FileDescriptorSet; use crate::protoc; use crate::pure; use crate::which_parser::WhichParser; use crate::ParsedAndTypechecked; /// Configure and invok...
(&mut self, includes: impl IntoIterator<Item = impl AsRef<Path>>) -> &mut Self { for include in includes { self.include(include); } self } /// Append a `.proto` file path to compile pub fn input(&mut self, input: impl AsRef<Path>) -> &mut Self { self.inputs.push(...
includes
identifier_name
parser.rs
use std::collections::HashSet; use std::ffi::OsStr; use std::ffi::OsString; use std::path::Path; use std::path::PathBuf; use anyhow::Context; use protobuf::descriptor::FileDescriptorSet; use crate::protoc; use crate::pure; use crate::which_parser::WhichParser; use crate::ParsedAndTypechecked; /// Configure and invok...
pub(crate) protoc_extra_args: Vec<OsString>, } impl Parser { /// Create new default configured parser. pub fn new() -> Parser { Parser::default() } /// Use pure rust parser. pub fn pure(&mut self) -> &mut Self { self.which_parser = WhichParser::Pure; self } ///...
pub(crate) protoc: Option<PathBuf>,
random_line_split
blob_url_store.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::filemanager_thread::FileOrigin; use servo_url::ServoUrl; use std::str::FromStr; use url::Url; use uuid...
{ pub filename: Option<String>, /// MIME type string pub type_string: String, /// Size of content in bytes pub size: u64, /// Content of blob pub bytes: Vec<u8>, } /// Parse URL as Blob URL scheme's definition /// /// <https://w3c.github.io/FileAPI/#DefinitionOfScheme> pub fn parse_blob_ur...
BlobBuf
identifier_name
blob_url_store.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::filemanager_thread::FileOrigin; use servo_url::ServoUrl; use std::str::FromStr; use url::Url; use uuid...
let id = segs.first().ok_or(())?; Uuid::from_str(id).map_err(|_| ())? }; Ok((id, get_blob_origin(&ServoUrl::from_url(url_inner)))) } /// Given an URL, returning the Origin that a Blob created under this /// URL should have. /// /// HACK(izgzhen): Not well-specified on spec, and it is a bit a ha...
random_line_split
blob_url_store.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::filemanager_thread::FileOrigin; use servo_url::ServoUrl; use std::str::FromStr; use url::Url; use uuid...
else { url.origin().ascii_serialization() } }
{ // NOTE: by default this is "null" (Opaque), which is not ideal "file://".to_string() }
conditional_block
multiple_return_terminators.rs
//! This pass removes jumps to basic blocks containing only a return, and replaces them with a //! return instead. use crate::{simplify, MirPass}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; pub struct MultipleReturnTerminators; impl<'tcx> MirPass<'tcx> for MultipleRetur...
} if let TerminatorKind::Goto { target } = bb.terminator().kind { if bbs_simple_returns.contains(target) { bb.terminator_mut().kind = TerminatorKind::Return; } } } simplify::remove_dead_blocks(tcx, body) } }
{ if tcx.sess.mir_opt_level() < 4 { return; } // find basic blocks with no statement and a return terminator let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks().len()); let def_id = body.source.def_id(); let bbs = body.basic_blocks_mut(); ...
identifier_body
multiple_return_terminators.rs
//! This pass removes jumps to basic blocks containing only a return, and replaces them with a //! return instead. use crate::{simplify, MirPass}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; pub struct MultipleReturnTerminators; impl<'tcx> MirPass<'tcx> for MultipleRetur...
} for bb in bbs { if!tcx.consider_optimizing(|| format!("MultipleReturnTerminators {:?} ", def_id)) { break; } if let TerminatorKind::Goto { target } = bb.terminator().kind { if bbs_simple_returns.contains(target) { ...
{ bbs_simple_returns.insert(idx); }
conditional_block
multiple_return_terminators.rs
//! This pass removes jumps to basic blocks containing only a return, and replaces them with a //! return instead. use crate::{simplify, MirPass}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; pub struct MultipleReturnTerminators; impl<'tcx> MirPass<'tcx> for MultipleRetur...
simplify::remove_dead_blocks(tcx, body) } }
} } }
random_line_split
multiple_return_terminators.rs
//! This pass removes jumps to basic blocks containing only a return, and replaces them with a //! return instead. use crate::{simplify, MirPass}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; pub struct MultipleReturnTerminators; impl<'tcx> MirPass<'tcx> for MultipleRetur...
(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { if tcx.sess.mir_opt_level() < 4 { return; } // find basic blocks with no statement and a return terminator let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks().len()); let def_id = body.source.def_id()...
run_pass
identifier_name
solver.rs
b| b).count() } let (choices, cell) = grid.cells() // We swap order so min sorts correctly .map(|(cell_id, values)| (count_true(values), cell_id)) .filter(|&(choices, _)| choices!= 1) ...
Self::insert(referrers, cross_axis_item); Self::check_for_partition(&key.1, referrers, cross_axis, grid, &mut self.inferences); } fn check_for_partition<A, C>(...
let referrers = referrers_lookup.get_mut(&key) .expect("Partitioner bug: \ No referrers for new possibilities.");
random_line_split
solver.rs
| b).count() } let (choices, cell) = grid.cells() // We swap order so min sorts correctly .map(|(cell_id, values)| (count_true(values), cell_id)) .filter(|&(choices, _)| choices!= 1) ...
(rules: R) -> Partitioner<R> { let grid = Grid::new(rules.size()); let mut valueset_cells = collections::HashMap::new(); let mut cellset_values = collections::HashMap::new(); let values: Vec<_> = grid.range_iter::<ValueId>().collect(); for clique_id in rules.clique_ids() { ...
new
identifier_name
solver.rs
| b).count() } let (choices, cell) = grid.cells() // We swap order so min sorts correctly .map(|(cell_id, values)| (count_true(values), cell_id)) .filter(|&(choices, _)| choices!= 1) ...
} // Removes element `e` from an ordered Vec `v`, or else panics // This is just to simplify remove_possibility() slightly. fn remove<T: Ord>(v: &mut Vec<T>, e: &T) { let i = v.binary_search(e) .expect("Partitioner bug: Bookkeeping missing expected element"); v.remove(i...
{ // This is really saying "veto the cartesian product of non-referrers and // possibilities". for &cross_element in cross_axis { if referrers.binary_search(&cross_element).is_err() { for &element in possibilities { let case...
conditional_block
solver.rs
| b).count() } let (choices, cell) = grid.cells() // We swap order so min sorts correctly .map(|(cell_id, values)| (count_true(values), cell_id)) .filter(|&(choices, _)| choices!= 1) ...
} impl<R> Strategy for Partitioner<R> where R: Deref<Target=Rules> + Clone +'static { fn veto(&mut self, vetoes: &[CaseId]) { self.veto(vetoes.iter().cloned()); } fn inferences(&mut self) -> &mut Vec<CaseId> { &mut self.inferences } fn boxed_clone(&self) -> Box<Strategy> { ...
{ let i = v.binary_search(&e) .err().expect("Partitioner bug: Bookkeeping already had element."); v.insert(i, e); }
identifier_body
util.rs
/* Copyright (c) 2017 The swc Project Developers 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, modify, merge, publish, ...
<T>(&self, index: usize) -> napi::Result<T> where T: DeserializeOwned, { let buffer = self.get::<JsBuffer>(index)?.into_value()?; let v = serde_json::from_slice(&buffer) .with_context(|| { format!( "Failed to deserialize argument at `{}` as ...
get_deserialized
identifier_name
util.rs
/* Copyright (c) 2017 The swc Project Developers 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, modify, merge, publish, ...
.with_context(|| { format!( "Failed to deserialize argument at `{}` as {}\nJSON: {}", index, type_name::<T>(), String::from_utf8_lossy(&buffer) ) }) .convert_err()?; ...
T: DeserializeOwned, { let buffer = self.get::<JsBuffer>(index)?.into_value()?; let v = serde_json::from_slice(&buffer)
random_line_split
util.rs
/* Copyright (c) 2017 The swc Project Developers 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, modify, merge, publish, ...
fn get_deserialized<T>(&self, index: usize) -> napi::Result<T> where T: DeserializeOwned, { let buffer = self.get::<JsBuffer>(index)?.into_value()?; let v = serde_json::from_slice(&buffer) .with_context(|| { format!( "Failed to deseria...
{ let buffer = self.get::<JsBuffer>(index)?.into_value()?; Ok(String::from_utf8_lossy(buffer.as_ref()).to_string()) }
identifier_body
basic.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #![cfg(not(target_arch = "arm"))] use libc::{c_char, ioctl, open, O_RDWR}; use kvm_sys::*; const KVM_PATH: &str = "/dev/kvm\0"; #[test] fn get_vers...
#[test] fn check_vm_extension() { let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; assert!(sys_fd >= 0); let has_user_memory = unsafe { ioctl(sys_fd, KVM_CHECK_EXTENSION(), KVM_CAP_USER_MEMORY) }; assert_eq!(has_user_memory, 1); }
{ let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; assert!(sys_fd >= 0); let vm_fd = unsafe { ioctl(sys_fd, KVM_CREATE_VM(), 0) }; assert!(vm_fd >= 0); }
identifier_body
basic.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #![cfg(not(target_arch = "arm"))] use libc::{c_char, ioctl, open, O_RDWR}; use kvm_sys::*; const KVM_PATH: &str = "/dev/kvm\0"; #[test] fn get_vers...
() { let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; assert!(sys_fd >= 0); let has_user_memory = unsafe { ioctl(sys_fd, KVM_CHECK_EXTENSION(), KVM_CAP_USER_MEMORY) }; assert_eq!(has_user_memory, 1); }
check_vm_extension
identifier_name
basic.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
use kvm_sys::*; const KVM_PATH: &str = "/dev/kvm\0"; #[test] fn get_version() { let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; assert!(sys_fd >= 0); let ret = unsafe { ioctl(sys_fd, KVM_GET_API_VERSION(), 0) }; assert_eq!(ret as u32, KVM_API_VERSION); } #[test] fn create_...
#![cfg(not(target_arch = "arm"))] use libc::{c_char, ioctl, open, O_RDWR};
random_line_split
request.rs
/*! Functions to make requests against the planets.nu API. */ extern crate curl; extern crate flate2; extern crate url; use self::curl::http; use self::flate2::reader::GzDecoder; use std::io::BufReader; use std::str; use std::vec; use error; use builders::game; use builders::load_turn; use builders::login; use parse;...
() { assert_eq!( "http://api.planets.nu/game/loadturn?gameid=1337&forsave=false", build_load_turn_url(1337, None, None, None, false).as_slice()); } #[test] fn test_build_load_turn_url() { assert_eq!( "http://api.planets.nu/game/loadturn?gameid=1337&turn=5...
test_build_load_turn_url_defaults
identifier_name
request.rs
/*! Functions to make requests against the planets.nu API. */ extern crate curl; extern crate flate2; extern crate url; use self::curl::http; use self::flate2::reader::GzDecoder; use std::io::BufReader; use std::str; use std::vec; use error; use builders::game; use builders::load_turn; use builders::login; use parse;...
DefaultScope => (), PublicScope => { url = url + prepend_char + "scope=0"; prepend_char = "&".to_string(); }, CustomScope => { url = url + prepend_char + "scope=1"; prepend_char = "&".to_string(); }, }; let ids_as_str: Vec<...
random_line_split
request.rs
/*! Functions to make requests against the planets.nu API. */ extern crate curl; extern crate flate2; extern crate url; use self::curl::http; use self::flate2::reader::GzDecoder; use std::io::BufReader; use std::str; use std::vec; use error; use builders::game; use builders::load_turn; use builders::login; use parse;...
, None => (), }; url } /// Builds the URL used for the load turn API. fn build_load_turn_url(game_id: i32, turn: Option<i32>, api_key: Option<String>, player_id: Option<i32>, for_save: bool) -> String { let...
{ url = url + prepend_char + "limit=" + i.to_string(); }
conditional_block
request.rs
/*! Functions to make requests against the planets.nu API. */ extern crate curl; extern crate flate2; extern crate url; use self::curl::http; use self::flate2::reader::GzDecoder; use std::io::BufReader; use std::str; use std::vec; use error; use builders::game; use builders::load_turn; use builders::login; use parse;...
#[test] fn test_build_games_list_url() { assert_eq!( "http://api.planets.nu/games/list\ ?status=1,3&type=1,4&scope=1&ids=12,13371337&username=theuser&limit=123", build_games_list_url( request::STATUS_JOINING | request::STATUS_FINISHED, ...
{ assert_eq!( "http://api.planets.nu/games/list", build_games_list_url( request::STATUS_DEFAULT, request::GAME_TYPE_DEFAULT, request::DefaultScope, &Vec::new(), None, None).as_slice()); }
identifier_body
lib.rs
//! Maman is a Rust Web Crawler saving pages on Redis. //! //! # Default environment variables //! //! * `MAMAN_ENV`=development //! * `REDIS_URL`="redis://127.0.0.1/" #![doc(html_root_url = "https://docs.rs/maman/0.13.1")] #![deny(warnings)] #![crate_name = "maman"] extern crate html5ever; #[macro_use] extern crate l...
pub use crate::maman::{Page, Spider}; pub mod maman;
concat!(maman_version_string!(), " (https://crates.io/crates/maman)") }; }
random_line_split
chester.rs
use std::io::BufRead; struct Point { x: f64, y: f64, } fn square(x: f64) -> f64 { x*x } impl Point { fn distance(&self, p: &Point) -> f64 { self.distance_squared(p).sqrt() } fn distance_squared(&self, p: &Point) -> f64 { square(self.x - p.x) + square(self.y - p.y) } } fn read_input()...
let mut position = Point { x:0.5, y:0.5 }; let mut total_distance = 0f64; while let Some(next_position) = pop_closest(&position, &mut treats) { total_distance += position.distance(&next_position); position = next_position; } println!("{:.16}", total_distance); }
let mut treats = read_input();
random_line_split
chester.rs
use std::io::BufRead; struct Point { x: f64, y: f64, } fn square(x: f64) -> f64 { x*x } impl Point { fn distance(&self, p: &Point) -> f64 { self.distance_squared(p).sqrt() } fn distance_squared(&self, p: &Point) -> f64 { square(self.x - p.x) + square(self.y - p.y) } } fn
() -> Vec<Point> { let stdin = std::io::stdin(); let mut input = stdin.lock().lines(); let n_treats = input.next().unwrap().unwrap().parse().unwrap(); let mut treats = Vec::with_capacity(n_treats); for _ in 0..n_treats { let numbers: Vec<f64> = input.next().unwrap().unwrap().split(' ') ...
read_input
identifier_name
chester.rs
use std::io::BufRead; struct Point { x: f64, y: f64, } fn square(x: f64) -> f64 { x*x } impl Point { fn distance(&self, p: &Point) -> f64 { self.distance_squared(p).sqrt() } fn distance_squared(&self, p: &Point) -> f64 { square(self.x - p.x) + square(self.y - p.y) } } fn read_input()...
let len = ps.len(); let mut closest = (0, p.distance_squared(&ps[0])); for i in 1..len { let d = p.distance_squared(&ps[i]); if d < closest.1 { closest = (i, d); } } Some(ps.swap_remove(closest.0)) } fn main() { let mut treats = read_input(); let mut pos...
{ return None; }
conditional_block
markdown.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
data: *u8, size: libc::size_t, asize: libc::size_t, unit: libc::size_t, } // sundown FFI #[link(name = "sundown", kind = "static")] extern { fn sdhtml_renderer(callbacks: *sd_callbacks, options_ptr: *html_renderopt, render_flags: libc::c_uint); fn s...
flags: libc::c_uint, link_attributes: Option<extern "C" fn(*buf, *buf, *libc::c_void)>, } struct buf {
random_line_split
markdown.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a>(&'a str); static OUTPUT_UNIT: libc::size_t = 64; static MKDEXT_NO_INTRA_EMPHASIS: libc::c_uint = 1 << 0; static MKDEXT_TABLES: libc::c_uint = 1 << 1; static MKDEXT_FENCED_CODE: libc::c_uint = 1 << 2; static MKDEXT_AUTOLINK: libc::c_uint = 1 << 3; static MKDEXT_STRIKETHROUGH: libc::c_uint = 1 << 4; type sd_markdo...
Markdown
identifier_name
markdown.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
render(fmt.buf, md.as_slice()); } }
{ return; }
conditional_block
htmlbrelement.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::root::DomRoot; use crate::dom::document::Document;
use crate::dom::node::Node; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLBRElement { htmlelement: HTMLElement, } impl HTMLBRElement { fn new_inherited( local_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> HTMLBREle...
use crate::dom::htmlelement::HTMLElement;
random_line_split
htmlbrelement.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::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLEle...
{ htmlelement: HTMLElement, } impl HTMLBRElement { fn new_inherited( local_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> HTMLBRElement { HTMLBRElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), } } ...
HTMLBRElement
identifier_name
htmlbrelement.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::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLEle...
#[allow(unrooted_must_root)] pub fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> DomRoot<HTMLBRElement> { Node::reflect_node( Box::new(HTMLBRElement::new_inherited(local_name, prefix, document)), document, ) ...
{ HTMLBRElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), } }
identifier_body
aeabi_memcpy.rs
#![cfg(all( target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux", feature = "mem" ))] #![feature(compiler_builtins_lib)] #![feature(lang_items)] #![no_std] extern crate compiler_builtins; // test runner extern crate utest_cortex_m_qemu; // overrides `panic!` #[m...
fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize); fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize); } struct Aligned { array: [u8; 8], _alignment: [u32; 0], } impl Aligned { fn new(array: [u8; 8]) -> Self { Aligned { array: array, _alignment: []...
upanic!($($tt)*); }; } extern "C" {
random_line_split
aeabi_memcpy.rs
#![cfg(all( target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux", feature = "mem" ))] #![feature(compiler_builtins_lib)] #![feature(lang_items)] #![no_std] extern crate compiler_builtins; // test runner extern crate utest_cortex_m_qemu; // overrides `panic!` #[m...
} #[test] fn memcpy() { let mut dest = [0; 4]; let src = [0xde, 0xad, 0xbe, 0xef]; for n in 0..dest.len() { dest.copy_from_slice(&[0; 4]); unsafe { __aeabi_memcpy(dest.as_mut_ptr(), src.as_ptr(), n) } assert_eq!(&dest[0..n], &src[0..n]) } } #[test] fn memcpy4() { let mu...
{ Aligned { array: array, _alignment: [], } }
identifier_body
aeabi_memcpy.rs
#![cfg(all( target_arch = "arm", not(any(target_env = "gnu", target_env = "musl")), target_os = "linux", feature = "mem" ))] #![feature(compiler_builtins_lib)] #![feature(lang_items)] #![no_std] extern crate compiler_builtins; // test runner extern crate utest_cortex_m_qemu; // overrides `panic!` #[m...
(array: [u8; 8]) -> Self { Aligned { array: array, _alignment: [], } } } #[test] fn memcpy() { let mut dest = [0; 4]; let src = [0xde, 0xad, 0xbe, 0xef]; for n in 0..dest.len() { dest.copy_from_slice(&[0; 4]); unsafe { __aeabi_memcpy(dest.as_mut...
new
identifier_name
io.rs
/*! # Input and Output This module holds a single struct (`FC`) that keeps what would otherwise be global state of the running process. All the open file handles and sockets are stored here as well as helper functions to properly initialize the program and all the necessary packing and work to receive, log, and send a...
, Err(e) => { panic!(e) }, } // Try and open telemetry socket match UdpSocket::bind("0.0.0.0:0") { Ok(socket) => { telemetry_socket = socket; }, Err(e) => { panic!(e) }, } // Try and open log file, loop until we find a name that's not taken ...
{ fc_listen_socket = socket; }
conditional_block
io.rs
/*! # Input and Output This module holds a single struct (`FC`) that keeps what would otherwise be global state of the running process. All the open file handles and sockets are stored here as well as helper functions to properly initialize the program and all the necessary packing and work to receive, log, and send a...
{ /// Instant we started boot_time: time::Instant, /// Socket to listen on for messages. fc_listen_socket: UdpSocket, /// Socket to send telemetry. telemetry_socket: UdpSocket, /// File to write data to. fc_log_file: File, /// Current count of telemetry messages sent. seque...
FC
identifier_name
io.rs
/*! # Input and Output This module holds a single struct (`FC`) that keeps what would otherwise be global state of the running process. All the open file handles and sockets are stored here as well as helper functions to properly initialize the program and all the necessary packing and work to receive, log, and send a...
}
{ let mut buffer = [0u8; SIZE_OF_SEQE]; { let mut message = Cursor::<&mut [u8]>::new(&mut buffer); // Struct Fields: message.write_u16::<BigEndian>(self.port).unwrap(); message.write_u32::<BigEndian>(self.expected).unwrap(); message.write_u32:...
identifier_body
io.rs
/*! # Input and Output This module holds a single struct (`FC`) that keeps what would otherwise be global
here as well as helper functions to properly initialize the program and all the necessary packing and work to receive, log, and send any data. In many ways this is the guts of the flight computer. */ extern crate byteorder; use std::net::UdpSocket; use std::net::SocketAddrV4; use std::net::Ipv4Addr; use std::io::...
state of the running process. All the open file handles and sockets are stored
random_line_split
row.rs
use blas::{Copy, Gemv}; use Forward; use onezero::{One, Zero}; use ops::{set, self}; use traits::Transpose as _0; use traits::{Matrix, Set, Slice, SliceMut}; use {Product, RowMut, Row, RowVec, Scaled, SubMat, Transposed}; // NOTE Core impl<'a, T> Set<T> for RowMut<'a, T> where T: Copy { fn set(&mut self, value: T...
(&mut self, rhs: Scaled<Product<Row<T>, SubMat<T>>>) { self.slice_mut(..).t().set(rhs.t()) } } // NOTE Secondary impl<'a, 'b, 'c, T> Set<Scaled<Product<Row<'b, T>, Transposed<SubMat<'a, T>>>>> for RowMut<'c, T> where T: Gemv + Zero, { fn set(&mut self, rhs: Scaled<Product<Row<T>, Transposed<SubMat<...
set
identifier_name
row.rs
use blas::{Copy, Gemv}; use Forward; use onezero::{One, Zero}; use ops::{set, self}; use traits::Transpose as _0; use traits::{Matrix, Set, Slice, SliceMut}; use {Product, RowMut, Row, RowVec, Scaled, SubMat, Transposed}; // NOTE Core impl<'a, T> Set<T> for RowMut<'a, T> where T: Copy { fn set(&mut self, value: T...
} // NOTE Secondary impl<'a, 'b, 'c, T> Set<Scaled<Product<Row<'b, T>, Transposed<SubMat<'a, T>>>>> for RowMut<'c, T> where T: Gemv + Zero, { fn set(&mut self, rhs: Scaled<Product<Row<T>, Transposed<SubMat<T>>>>) { self.slice_mut(..).t().set(rhs.t()) } } // NOTE Secondary impl<'a, 'b, 'c, T> Set<...
{ self.slice_mut(..).t().set(rhs.t()) }
identifier_body
row.rs
use blas::{Copy, Gemv}; use Forward; use onezero::{One, Zero}; use ops::{set, self}; use traits::Transpose as _0; use traits::{Matrix, Set, Slice, SliceMut}; use {Product, RowMut, Row, RowVec, Scaled, SubMat, Transposed}; // NOTE Core impl<'a, T> Set<T> for RowMut<'a, T> where T: Copy { fn set(&mut self, value: T...
// NOTE Secondary impl<'a, 'b, 'c, T> Set<Scaled<Product<Row<'b, T>, SubMat<'a, T>>>> for RowMut<'c, T> where T: Gemv + Zero, { fn set(&mut self, rhs: Scaled<Product<Row<T>, SubMat<T>>>) { self.slice_mut(..).t().set(rhs.t()) } } // NOTE Secondary impl<'a, 'b, 'c, T> Set<Scaled<Product<Row<'b, T>, ...
}
random_line_split
lib.rs
#![allow(non_upper_case_globals)] #![deny(missing_docs)] // Copyright 2015 Adrien Champion. See the COPYRIGHT file at the top-level // directory of this distribution. // // 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...
} /// Parses, type checks and remembers the input. pub mod ctxt { pub use super::base::Callable ; pub use super::parse::{ Res, Context } ; pub use super::parse::check::CheckError ; pub use type_check::type_check ; } pub use base::{ CallSet, PropStatus } ; pub use parse::Cex ; /// A signature, a list o...
pub mod real_sys { pub use base::{ Sig, Args, Uf, Fun, Prop, Sys, Callable } ;
random_line_split
lib.rs
#![allow(non_upper_case_globals)] #![deny(missing_docs)] // Copyright 2015 Adrien Champion. See the COPYRIGHT file at the top-level // directory of this distribution. // // 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...
& self) { match * self { Error::Parse { ref line, ref blah, ref notes } => { println!("parse error {}: {}", line, blah) ; for & (ref line, ref blah) in notes { println!("| {}: {}", line, blah) } }, Error::Io(ref e) => println!("io error: {:?}", e) } } } impl...
rint(
identifier_name
domainxover.rs
use super::{lerp, PVocDescriptor, PVocPlugin}; use ladspa::{DefaultValue, Plugin, PluginDescriptor, Port, PortConnection, PortDescriptor}; use pvoc::{Bin, PhaseVocoder}; plugin!(DomainXOver); struct DomainXOver; impl PVocPlugin for DomainXOver { fn
() -> PVocDescriptor { PVocDescriptor { name: "pvoc domain crossover", author: "Noah Weninger", channels: 1, ports: vec![ Port { name: "Add", desc: PortDescriptor::ControlInput, hint: None...
descriptor
identifier_name
domainxover.rs
use super::{lerp, PVocDescriptor, PVocPlugin}; use ladspa::{DefaultValue, Plugin, PluginDescriptor, Port, PortConnection, PortDescriptor}; use pvoc::{Bin, PhaseVocoder}; plugin!(DomainXOver); struct DomainXOver; impl PVocPlugin for DomainXOver { fn descriptor() -> PVocDescriptor { PVocDescriptor { ...
DomainXOver } fn process( &mut self, ports: &[f64], sample_rate: f64, channels: usize, bins: usize, input: &[Vec<Bin>], output: &mut [Vec<Bin>], ) { let freq_per_bin = sample_rate / (bins as f64); let add = ports[0]; let...
} fn new(_: usize, _: f64, _: usize, _: usize) -> DomainXOver {
random_line_split
domainxover.rs
use super::{lerp, PVocDescriptor, PVocPlugin}; use ladspa::{DefaultValue, Plugin, PluginDescriptor, Port, PortConnection, PortDescriptor}; use pvoc::{Bin, PhaseVocoder}; plugin!(DomainXOver); struct DomainXOver; impl PVocPlugin for DomainXOver { fn descriptor() -> PVocDescriptor { PVocDescriptor { ...
}
{ let freq_per_bin = sample_rate / (bins as f64); let add = ports[0]; let shift = ports[1]; let alpha = ports[2]; for i in 0..channels { let mut avg = input[i][0].amp; for j in 0..bins { output[i][j].freq = input[i][j].f...
identifier_body
private-type-alias.rs
type MyResultPriv<T> = Result<T, u16>; pub type MyResultPub<T> = Result<T, u64>; // @has private_type_alias/fn.get_result_priv.html '//pre' 'Result<u8, u16>' pub fn get_result_priv() -> MyResultPriv<u8> { panic!(); } // @has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub<u32>' pub fn
() -> MyResultPub<u32> { panic!(); } pub type PubRecursive = u16; type PrivRecursive3 = u8; type PrivRecursive2 = PubRecursive; type PrivRecursive1 = PrivRecursive3; // PrivRecursive1 is expanded twice and stops at u8 // PrivRecursive2 is expanded once and stops at public type alias PubRecursive // @has private_t...
get_result_pub
identifier_name
private-type-alias.rs
type MyResultPriv<T> = Result<T, u16>; pub type MyResultPub<T> = Result<T, u64>; // @has private_type_alias/fn.get_result_priv.html '//pre' 'Result<u8, u16>' pub fn get_result_priv() -> MyResultPriv<u8> { panic!();
} // @has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub<u32>' pub fn get_result_pub() -> MyResultPub<u32> { panic!(); } pub type PubRecursive = u16; type PrivRecursive3 = u8; type PrivRecursive2 = PubRecursive; type PrivRecursive1 = PrivRecursive3; // PrivRecursive1 is expanded twice and stops a...
random_line_split
private-type-alias.rs
type MyResultPriv<T> = Result<T, u16>; pub type MyResultPub<T> = Result<T, u64>; // @has private_type_alias/fn.get_result_priv.html '//pre' 'Result<u8, u16>' pub fn get_result_priv() -> MyResultPriv<u8> { panic!(); } // @has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub<u32>' pub fn get_result_pu...
type MyLifetimePriv<'a> = &'a isize; // @has private_type_alias/fn.get_lifetime_priv.html '//pre' "&'static isize" pub fn get_lifetime_priv() -> MyLifetimePriv<'static> { panic!(); }
{ panic!(); }
identifier_body
signature.rs
use bytes; use {Error, FileType}; use std::io::Read; const SIGNATURE_FILE: u32 = 0x9AA2D903; const SIGNATURE_KEEPASS1: u32 = 0xB54BFB65; const SIGNATURE_KEEPASS2_PRE_RELEASE: u32 = 0xB54BFB66; const SIGNATURE_KEEPASS2: u32 = 0xB54BFB67; pub fn read_file_type(reader: &mut Read) -> Result<FileType, Error> { let si...
bytes.write_u32::<LittleEndian>(super::SIGNATURE_FILE).unwrap(); bytes.write_u32::<LittleEndian>(super::SIGNATURE_KEEPASS2).unwrap(); let result = read_file_type(&mut &bytes[..]); match result { Ok(FileType::KeePass2) => (), _ => panic!("Invalid result: {:#?}", ...
#[test] pub fn should_return_file_type() { let mut bytes = vec![];
random_line_split
signature.rs
use bytes; use {Error, FileType}; use std::io::Read; const SIGNATURE_FILE: u32 = 0x9AA2D903; const SIGNATURE_KEEPASS1: u32 = 0xB54BFB65; const SIGNATURE_KEEPASS2_PRE_RELEASE: u32 = 0xB54BFB66; const SIGNATURE_KEEPASS2: u32 = 0xB54BFB67; pub fn read_file_type(reader: &mut Read) -> Result<FileType, Error> { let si...
(file_type: u32) -> Result<FileType, Error> { match file_type { SIGNATURE_KEEPASS1 => Ok(FileType::KeePass1), SIGNATURE_KEEPASS2_PRE_RELEASE => Ok(FileType::KeePass2PreRelease), SIGNATURE_KEEPASS2 => Ok(FileType::KeePass2), _ => Err(Error::InvalidFileType(file_type)), } } #[cfg(...
match_file_type
identifier_name
signature.rs
use bytes; use {Error, FileType}; use std::io::Read; const SIGNATURE_FILE: u32 = 0x9AA2D903; const SIGNATURE_KEEPASS1: u32 = 0xB54BFB65; const SIGNATURE_KEEPASS2_PRE_RELEASE: u32 = 0xB54BFB66; const SIGNATURE_KEEPASS2: u32 = 0xB54BFB67; pub fn read_file_type(reader: &mut Read) -> Result<FileType, Error> { let si...
}
{ let file_type = super::SIGNATURE_KEEPASS2 + 1; let mut bytes = vec![]; bytes.write_u32::<LittleEndian>(super::SIGNATURE_FILE).unwrap(); bytes.write_u32::<LittleEndian>(file_type).unwrap(); let result = read_file_type(&mut &bytes[..]); match result { Err(E...
identifier_body
class-methods-cross-crate.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 mut nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); assert_eq!(nyan.meow_count(), 53u); }
main
identifier_name
class-methods-cross-crate.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
// option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:cci_class_3.rs extern crate cci_class_3; use cci_class_3::kitties::cat; pub fn main() { let mut nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); asser...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
class-methods-cross-crate.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 mut nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert_eq!(nyan.how_hungry, 99); assert_eq!(kitty.how_hungry, 2); nyan.speak(); assert_eq!(nyan.meow_count(), 53u); }
identifier_body
winusbio.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
pub const SHORT_PACKET_TERMINATE: ULONG = 0x01; pub const AUTO_CLEAR_STALL: ULONG = 0x02; pub const PIPE_TRANSFER_TIMEOUT: ULONG = 0x03; pub const IGNORE_SHORT_PACKETS: ULONG = 0x04; pub const ALLOW_PARTIAL_READS: ULONG = 0x05; pub const AUTO_FLUSH: ULONG = 0x06; pub const RAW_IO: ULONG = 0x07; pub const MAXIMUM_TRANSF...
// All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Public header for WINUSB use shared::minwindef::{UCHAR, ULONG, USHORT}; use shared::usb::USBD_PIPE_TYPE;
random_line_split
pixmap.rs
//! Custom pixmaps which can handle kinds of data that the `image` library //! doesn't support. use cast; use common_failures::prelude::*; use image::{ImageBuffer, Rgba, RgbaImage}; use std::fmt; use std::slice; #[cfg(test)] use test_util::rgba_hex; /// A type which can be used as a pixel in a `Pixmap`. pub trait Pi...
else { None } } } /// An iterator over the coordinates `(x, y)` of all neighboring pixels, /// including only in-bounds pixels. pub struct RealNeighbors { width: usize, height: usize, x: usize, y: usize, i: usize, } impl Iterator for RealNeighbors { type Item = (usize,...
{ self.i += 1; Some((self.x + dx, self.y + dy)) }
conditional_block
pixmap.rs
//! Custom pixmaps which can handle kinds of data that the `image` library //! doesn't support. use cast; use common_failures::prelude::*; use image::{ImageBuffer, Rgba, RgbaImage}; use std::fmt; use std::slice; #[cfg(test)] use test_util::rgba_hex; /// A type which can be used as a pixel in a `Pixmap`. pub trait Pi...
false => rgba_hex(0x00ff00ff), } }); assert_eq!(mapped.get(0, 0), rgba_hex(0xff0000ff)); assert_eq!(mapped.get(0, 1), rgba_hex(0x00ff00ff)); } #[test] fn to_image_converts_to_image() { let mut pixmap = Pixmap::<bool>::blank(1, 2); *pixmap.get_mut(0, 0) = true; let image = pi...
*pixmap.get_mut(0, 0) = true; let mapped = pixmap.map(|p| { match p { true => rgba_hex(0xff0000ff),
random_line_split
pixmap.rs
//! Custom pixmaps which can handle kinds of data that the `image` library //! doesn't support. use cast; use common_failures::prelude::*; use image::{ImageBuffer, Rgba, RgbaImage}; use std::fmt; use std::slice; #[cfg(test)] use test_util::rgba_hex; /// A type which can be used as a pixel in a `Pixmap`. pub trait Pi...
/// An iterator over all the pixels in an image. pub struct Pixels<'a, P: Pixel> { iter: slice::Iter<'a, P>, } impl<'a, P: Pixel> Iterator for Pixels<'a, P> { type Item = P; fn next(&mut self) -> Option<Self::Item> { self.iter.next().map(|v| *v) } } /// An iterator over `(x, y, value)` for a...
{ // This will always succeed on 32-bit platforms. Ok(cast::u32(i)) }
identifier_body
pixmap.rs
//! Custom pixmaps which can handle kinds of data that the `image` library //! doesn't support. use cast; use common_failures::prelude::*; use image::{ImageBuffer, Rgba, RgbaImage}; use std::fmt; use std::slice; #[cfg(test)] use test_util::rgba_hex; /// A type which can be used as a pixel in a `Pixmap`. pub trait Pi...
(i: usize) -> Result<u32> { // This will always succeed on 32-bit platforms. Ok(cast::u32(i)) } /// An iterator over all the pixels in an image. pub struct Pixels<'a, P: Pixel> { iter: slice::Iter<'a, P>, } impl<'a, P: Pixel> Iterator for Pixels<'a, P> { type Item = P; fn next(&mut self) -> Option...
u32_from_usize
identifier_name
mutex.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
/// Attempts to acquire the lock. The value returned is whether the lock was /// acquired or not pub unsafe fn trylock(&mut self) -> bool { imp::trylock(self.getlock()) } /// Unlocks the lock. This assumes that the current thread already holds the /// lock. pub unsafe fn unlock(&mut self) { i...
{ imp::lock(self.getlock()) }
identifier_body
mutex.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub unsafe fn unlock(l: *c_void) { LeaveCriticalSection(l as LPCRITICAL_SECTION) } pub unsafe fn wait(cond: *c_void, m: *c_void) { unlock(m); WaitForSingleObject(cond as HANDLE, 0); lock(m); } pub unsafe fn signal(cond: *c_void) { assert!(SetEvent(con...
TryEnterCriticalSection(l as LPCRITICAL_SECTION) != 0
random_line_split
mutex.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(h: uint) { let block = h as *c_void; assert_eq!(pthread_cond_destroy(block), 0); libc::free(block); } pub unsafe fn lock(l: *pthread_mutex_t) { assert_eq!(pthread_mutex_lock(l), 0); } pub unsafe fn trylock(l: *c_void) -> bool { pthread_mutex_trylock(l) == 0 ...
free_cond
identifier_name
ex_1.rs
/* Copyright © 2013 Free Software Foundation, Inc See licensing in LICENSE file File: examples/ex_1.rs Author: Jesse 'Jeaye' Wilkerson Description: Simple "Hello, world" example. */ extern crate ncurses; use ncurses::*; fn main() { /* If your locale env is unicode, you should use `setloc...
initscr(); /* Print to the back buffer. */ printw("Hello, world!"); /* Print some unicode(Chinese) string. */ // printw("Great Firewall dislike VPN protocol.\nGFW 不喜欢 VPN 协议。"; /* Update the screen. */ refresh(); /* Wait for a key press. */ getch(); /* Terminate ncurses. */ endwin(); }
/* Start ncurses. */
random_line_split
ex_1.rs
/* Copyright © 2013 Free Software Foundation, Inc See licensing in LICENSE file File: examples/ex_1.rs Author: Jesse 'Jeaye' Wilkerson Description: Simple "Hello, world" example. */ extern crate ncurses; use ncurses::*; fn main() {
/* Terminate ncurses. */ endwin(); }
/* If your locale env is unicode, you should use `setlocale`. */ // let locale_conf = LcCategory::all; // setlocale(locale_conf, "zh_CN.UTF-8"); // if your locale is like mine(zh_CN.UTF-8). /* Start ncurses. */ initscr(); /* Print to the back buffer. */ printw("Hello, world!"); /* Print some unicode...
identifier_body
ex_1.rs
/* Copyright © 2013 Free Software Foundation, Inc See licensing in LICENSE file File: examples/ex_1.rs Author: Jesse 'Jeaye' Wilkerson Description: Simple "Hello, world" example. */ extern crate ncurses; use ncurses::*; fn m
) { /* If your locale env is unicode, you should use `setlocale`. */ // let locale_conf = LcCategory::all; // setlocale(locale_conf, "zh_CN.UTF-8"); // if your locale is like mine(zh_CN.UTF-8). /* Start ncurses. */ initscr(); /* Print to the back buffer. */ printw("Hello, world!"); /* Print some unic...
ain(
identifier_name
pipeline.rs
fn parse_cluster(record: csv::StringRecord) -> Result<Vec<usize>> { let seqids = &record[2]; Ok(csv::ReaderBuilder::new() .delimiter(b',') .has_headers(false) .from_reader(seqids.as_bytes()) .deserialize() .next() .unwrap()?) } /// Calculates the median hamming distanc...
/// Interpret a cluster returned by starcode
random_line_split
pipeline.rs
next() .unwrap()?) } /// Calculates the median hamming distance for all records by deriving the overlap from insert size fn median_hamming_distance( insert_size: usize, f_recs: &[fastq::Record], r_recs: &[fastq::Record], ) -> Option<f64> { let distances = f_recs.iter().zip(r_recs).filter_map(|(f...
elf, f_recs: &[Record], r_recs: &[Record], outer_seqids: &[usize], uuid: &str, ) -> OverlappingConsensus { //Returns consensus record by filtering overlaps with lowest hamming distance. //For these overlaps(insert sizes) the consensus reads and their likelihoods are c...
od_overlapping_consensus( &mut s
identifier_name
pipeline.rs
.next() .unwrap()?) } /// Calculates the median hamming distance for all records by deriving the overlap from insert size fn median_hamming_distance( insert_size: usize, f_recs: &[fastq::Record], r_recs: &[fastq::Record], ) -> Option<f64> { let distances = f_recs.iter().zip(r_recs).filter_map(|(...
.0, )?; } else { self.fq1_writer.write_record(&f_recs[0])?; self.fq2_writer.write_record(&r_recs[0])?; } Ok(()) } fn fq1_rea der(&mut self) -> &mut fastq::Reader<R> { self.fq1_reader } fn fq2_reader(&mut self) -> &mut f...
ecs.len() > 1 { let uuid = &Uuid::new_v4().to_hyphenated().to_string(); self.fq1_writer.write_record( &CalcNonOverlappingConsensus::new( &f_recs, &outer_seqids, uuid, self.verbose_read_names, ...
identifier_body
cli.rs
// Copyright (c) 2017 Chef Software Inc. and/or applicable contributors // // 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 r...
Ok(_) => Ok(()), Err(_) => Err(format!("{} is not a natural number", val)), } } #[cfg(test)] mod tests { use super::*; #[test] fn test_valid_natural_number() { valid_natural_number("99".to_owned()).unwrap(); for &s in ["x", "", "#####", "0x11", "ab"].iter() { ...
random_line_split
cli.rs
// Copyright (c) 2017 Chef Software Inc. and/or applicable contributors // // 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 r...
pub fn add_docker_args(self) -> Self { let cli = docker::Cli { app: self.app }; let app = cli.add_base_packages_args() .add_builder_args() .add_tagging_args() .add_publishing_args() .add_pkg_ident_arg(docker::PkgIdentArgOptions { multiple: false }) ...
{ self.add_docker_args() .add_output_args() .add_runtime_args() .add_secret_names_args() .add_bind_args() }
identifier_body
cli.rs
// Copyright (c) 2017 Chef Software Inc. and/or applicable contributors // // 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 r...
(val: String) -> result::Result<(), String> { match val.parse::<u32>() { Ok(_) => Ok(()), Err(_) => Err(format!("{} is not a natural number", val)), } } #[cfg(test)] mod tests { use super::*; #[test] fn test_valid_natural_number() { valid_natural_number("99".to_owned()).unw...
valid_natural_number
identifier_name
macro-input-future-proofing.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ }
identifier_body
macro-input-future-proofing.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
($pa:pat $pb:pat $ty:ty,) => (); //~^ ERROR `$pa:pat` is followed by `$pb:pat`, which is not allowed //~^^ ERROR `$pb:pat` is followed by `$ty:ty`, which is not allowed ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-` ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-` ($...
random_line_split
macro-input-future-proofing.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
box-of-array-of-drop-2.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// Issue 23222: The order in which the elements actually get // dropped is a little funky. See similar notes in nested-vec-3; // in essence, I would not be surprised if we change the ordering // given in `expect` in the future. let expect = 0x__A_9__5_6_7_8__1_2_3_4; let actual = LOG.load(Orde...
// When the panic occurs, we will be in the midst of constructing // the input to `_b3`. Therefore, we drop the elements of the // partially filled array first, before we get around to dropping // the elements of `_b1` and _b2`.
random_line_split
box-of-array-of-drop-2.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self) { println!("Dropping {}", self.0); let old = LOG.load(Ordering::SeqCst); LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); } } fn main() { fn die() -> D { panic!("Oh no"); } let g = thread::spawn(|| { let _b1: Box<[D; 4]> = Box::new([D( 1),...
drop
identifier_name
box-of-array-of-drop-2.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() { fn die() -> D { panic!("Oh no"); } let g = thread::spawn(|| { let _b1: Box<[D; 4]> = Box::new([D( 1), D( 2), D( 3), D( 4)]); let _b2: Box<[D; 4]> = Box::new([D( 5), D( 6), D( 7), D( 8)]); let _b3: Box<[D; 4]> = Box::new([D( 9), D(10), die(), D(12)]); let _b4: Box<...
{ println!("Dropping {}", self.0); let old = LOG.load(Ordering::SeqCst); LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); }
identifier_body
lib.rs
use std::collections::HashMap; pub fn get_sorted_chars(string : &str) -> String { let mut chars : Vec<char> = string.chars().collect(); chars.sort(); let mut sorted_string = String::new(); for c in chars { sorted_string.push(c); } sorted_string } pub fn get_anagrams<'a>(strings : &[&'a...
() { let string = "waffles"; let sorted = get_sorted_chars(string); assert_eq!(sorted, "aefflsw"); } #[test] fn get_anagrams_works_on_simple_data() { let strings = ["ate", "eat"]; let mut expected_anagrams = Vec::new(); expected_anagrams.push("ate"); expected_anagrams.push("eat"); let a...
get_sorted_chars_works
identifier_name
lib.rs
use std::collections::HashMap; pub fn get_sorted_chars(string : &str) -> String { let mut chars : Vec<char> = string.chars().collect(); chars.sort(); let mut sorted_string = String::new(); for c in chars { sorted_string.push(c); } sorted_string } pub fn get_anagrams<'a>(strings : &[&'a...
#[test] fn get_anagrams_works_on_simple_data() { let strings = ["ate", "eat"]; let mut expected_anagrams = Vec::new(); expected_anagrams.push("ate"); expected_anagrams.push("eat"); let anagram_map = get_anagrams(&strings); assert_eq!(anagram_map.keys().len(), 1); assert_eq!(anagram_map["aet"...
}
random_line_split
lib.rs
use std::collections::HashMap; pub fn get_sorted_chars(string : &str) -> String { let mut chars : Vec<char> = string.chars().collect(); chars.sort(); let mut sorted_string = String::new(); for c in chars { sorted_string.push(c); } sorted_string } pub fn get_anagrams<'a>(strings : &[&'a...
#[test] fn get_anagrams_works_on_simple_data() { let strings = ["ate", "eat"]; let mut expected_anagrams = Vec::new(); expected_anagrams.push("ate"); expected_anagrams.push("eat"); let anagram_map = get_anagrams(&strings); assert_eq!(anagram_map.keys().len(), 1); assert_eq!(anagram_map["ae...
{ let string = "waffles"; let sorted = get_sorted_chars(string); assert_eq!(sorted, "aefflsw"); }
identifier_body
on_disk.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{CryptoKVStorage, Error, GetResponse, KVStorage}; use diem_temppath::TempPath; use diem_time_service::{TimeService, TimeServiceTrait}; use serde::{de::DeserializeOwned, Serialize}; use serde_json::Value; use std::{ collec...
(&self) -> Result<(), Error> { Ok(()) } fn get<V: DeserializeOwned>(&self, key: &str) -> Result<GetResponse<V>, Error> { let mut data = self.read()?; data.remove(key) .ok_or_else(|| Error::KeyNotSet(key.to_string())) .and_then(|value| serde_json::from_value(value)....
available
identifier_name
on_disk.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{CryptoKVStorage, Error, GetResponse, KVStorage}; use diem_temppath::TempPath; use diem_time_service::{TimeService, TimeServiceTrait}; use serde::{de::DeserializeOwned, Serialize}; use serde_json::Value; use std::{ collec...
let data = serde_json::from_str(&contents)?; Ok(data) } fn write(&self, data: &HashMap<String, Value>) -> Result<(), Error> { let contents = serde_json::to_vec(data)?; let mut file = File::create(self.temp_path.path())?; file.write_all(&contents)?; fs::rename(&s...
{ return Ok(HashMap::new()); }
conditional_block
on_disk.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{CryptoKVStorage, Error, GetResponse, KVStorage}; use diem_temppath::TempPath; use diem_time_service::{TimeService, TimeServiceTrait}; use serde::{de::DeserializeOwned, Serialize}; use serde_json::Value; use std::{ collec...
); self.write(&data) } #[cfg(any(test, feature = "testing"))] fn reset_and_clear(&mut self) -> Result<(), Error> { self.write(&HashMap::new()) } } impl CryptoKVStorage for OnDiskStorage {}
serde_json::to_value(&GetResponse::new(value, now))?,
random_line_split
callback.rs
use std::mem; use std::ptr; use std::cell::RefCell; use std::sync::mpsc::Sender; use std::sync::{Arc, Mutex}; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; use CursorState; use Event; use super::event; use user32; use shell32; use winapi; /// There's no parameters passed to the callback function, s...
winapi::WM_MOUSEWHEEL => { use events::Event::MouseWheel; use events::MouseScrollDelta::LineDelta; let value = (wparam >> 16) as i16; let value = value as i32; let value = value as f32 / winapi::WHEEL_DELTA as f32; send_event(window, Mou...
0 },
random_line_split
callback.rs
use std::mem; use std::ptr; use std::cell::RefCell; use std::sync::mpsc::Sender; use std::sync::{Arc, Mutex}; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; use CursorState; use Event; use super::event; use user32; use shell32; use winapi; /// There's no parameters passed to the callback function, s...
0 }, winapi::WM_ERASEBKGND => { 1 }, winapi::WM_SIZE => { use events::Event::Resized; let w = winapi::LOWORD(lparam as winapi::DWORD) as u32; let h = winapi::HIWORD(lparam as winapi::DWORD) as u32; send_event(windo...
{ match msg { winapi::WM_DESTROY => { use events::Event::Closed; CONTEXT_STASH.with(|context_stash| { let context_stash = context_stash.borrow(); let stored = match *context_stash { None => return, Some(ref v) =...
identifier_body
callback.rs
use std::mem; use std::ptr; use std::cell::RefCell; use std::sync::mpsc::Sender; use std::sync::{Arc, Mutex}; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; use CursorState; use Event; use super::event; use user32; use shell32; use winapi; /// There's no parameters passed to the callback function, s...
(window: winapi::HWND, msg: winapi::UINT, wparam: winapi::WPARAM, lparam: winapi::LPARAM) -> winapi::LRESULT { match msg { winapi::WM_DESTROY => { use events::Event::Closed; CONTEXT_STASH.with(|context_sta...
callback
identifier_name
test_select.rs
use nix::sys::select::{FdSet, FD_SETSIZE, select}; use nix::sys::time::TimeVal; use nix::unistd::{write, pipe}; #[test] fn test_fdset() { let mut fd_set = FdSet::new(); for i in 0..FD_SETSIZE { assert!(!fd_set.contains(i)); } fd_set.insert(7);
assert!(!fd_set.contains(i)); } fd_set.insert(1); fd_set.insert(FD_SETSIZE / 2); fd_set.insert(FD_SETSIZE - 1); fd_set.clear(); for i in 0..FD_SETSIZE { assert!(!fd_set.contains(i)); } } #[test] fn test_select() { let (r1, w1) = pipe().unwrap(); write(w1, b"hi!")....
assert!(fd_set.contains(7)); fd_set.remove(7); for i in 0..FD_SETSIZE {
random_line_split
test_select.rs
use nix::sys::select::{FdSet, FD_SETSIZE, select}; use nix::sys::time::TimeVal; use nix::unistd::{write, pipe}; #[test] fn test_fdset() { let mut fd_set = FdSet::new(); for i in 0..FD_SETSIZE { assert!(!fd_set.contains(i)); } fd_set.insert(7); assert!(fd_set.contains(7)); fd_set.rem...
{ let (r1, w1) = pipe().unwrap(); write(w1, b"hi!").unwrap(); let (r2, _w2) = pipe().unwrap(); let mut fd_set = FdSet::new(); fd_set.insert(r1); fd_set.insert(r2); let mut timeout = TimeVal::seconds(1); assert_eq!(1, select(r2 + 1, Some(&mut fd_set), ...
identifier_body
test_select.rs
use nix::sys::select::{FdSet, FD_SETSIZE, select}; use nix::sys::time::TimeVal; use nix::unistd::{write, pipe}; #[test] fn
() { let mut fd_set = FdSet::new(); for i in 0..FD_SETSIZE { assert!(!fd_set.contains(i)); } fd_set.insert(7); assert!(fd_set.contains(7)); fd_set.remove(7); for i in 0..FD_SETSIZE { assert!(!fd_set.contains(i)); } fd_set.insert(1); fd_set.insert(FD_SETSIZE ...
test_fdset
identifier_name
svg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Computed types for SVG properties. use app_units::Au; use values::RGBA; use values::computed::{LengthOrPercen...
}
{ generic::SVGOpacity::Opacity(1.) }
identifier_body
svg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Computed types for SVG properties. use app_units::Au; use values::RGBA; use values::computed::{LengthOrPercen...
, } } } /// An non-negative wrapper of SVGLength. pub type SVGWidth = generic::SVGLength<NonNegativeSvgLengthOrPercentageOrNumber>; impl From<NonNegativeLength> for SVGWidth { fn from(length: NonNegativeLength) -> Self { generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::Length...
{ generic::SvgLengthOrPercentageOrNumber::Number(num.into()) }
conditional_block
svg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Computed types for SVG properties. use app_units::Au; use values::RGBA; use values::computed::{LengthOrPercen...
/// Computed SVG Paint value pub type SVGPaint = generic::SVGPaint<RGBA, ComputedUrl>; /// Computed SVG Paint Kind value pub type SVGPaintKind = generic::SVGPaintKind<RGBA, ComputedUrl>; impl Default for SVGPaint { fn default() -> Self { SVGPaint { kind: generic::SVGPaintKind::None, ...
random_line_split
svg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Computed types for SVG properties. use app_units::Au; use values::RGBA; use values::computed::{LengthOrPercen...
() -> Self { generic::SVGStrokeDashArray::Values(vec![]) } } /// <opacity-value> | context-fill-opacity | context-stroke-opacity pub type SVGOpacity = generic::SVGOpacity<Opacity>; impl Default for SVGOpacity { fn default() -> Self { generic::SVGOpacity::Opacity(1.) } }
default
identifier_name