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
led.rs
//! LED *(Dialog-specification language)* functionalities. //! //! LED is a dialog-specification language whose purpose is not to be a complete programming language, //! but rather to make dialog specification simpler than in C. Additionally it allows users to easily //! edit your application layout from external files...
= CString::new(buf.into()).unwrap(); match unsafe { iup_sys::IupLoadBuffer(cstr.as_ptr()) } { err if err.is_null() => Ok(()), err => Err(string_from_cstr!(err)), } }
identifier_body
led.rs
//! LED *(Dialog-specification language)* functionalities. //! //! LED is a dialog-specification language whose purpose is not to be a complete programming language, //! but rather to make dialog specification simpler than in C. Additionally it allows users to easily //! edit your application layout from external files...
>>(path: P) -> Result<(), String> { let path = path.as_ref(); let str = path.to_str().ok_or_else(|| "Failed to convert Path to string".to_string())?; let cstr = CString::new(str).unwrap(); match unsafe { iup_sys::IupLoad(cstr.as_ptr()) } { err if err.is_null() => Ok(()), err => Err(str...
Path
identifier_name
dnode.rs
use std::fmt; use std::mem; use super::block_ptr::BlockPtr; use super::from_bytes::FromBytes; use super::zil_header::ZilHeader; #[repr(u8)] #[derive(Debug, Eq, PartialEq)] pub enum
{ None, ObjectDirectory, ObjectArray, PackedNvList, NvListSize, BlockPtrList, BlockPtrListHdr, SpaceMapHeader, SpaceMap, IntentLog, DNode, ObjSet, DataSet, DataSetChildMap, ObjSetSnapMap, DslProps, DslObjSet, ZNode, Acl, PlainFileContents,...
ObjectType
identifier_name
dnode.rs
use std::fmt; use std::mem; use super::block_ptr::BlockPtr; use super::from_bytes::FromBytes; use super::zil_header::ZilHeader; #[repr(u8)] #[derive(Debug, Eq, PartialEq)] pub enum ObjectType { None, ObjectDirectory, ObjectArray, PackedNvList, NvListSize, BlockPtrList, BlockPtrListHdr, ...
DslProps, DslObjSet, ZNode, Acl, PlainFileContents, DirectoryContents, MasterNode, DeleteQueue, ZVol, ZVolProp, } #[repr(packed)] pub struct DNodePhys { pub object_type: ObjectType, pub indblkshift: u8, // ln2(indirect block size) pub nlevels: u8, // 1=blkptr->data b...
DataSet, DataSetChildMap, ObjSetSnapMap,
random_line_split
hrtb-precedence-of-plus.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
hrtb-precedence-of-plus.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 ...
() {}
main
identifier_name
hrtb-precedence-of-plus.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 ...
#![allow(unknown_features)] #![feature(box_syntax)] #![feature(unboxed_closures)] // Test that `Fn(int) -> int +'static` parses as `(Fn(int) -> int) + //'static` and not `Fn(int) -> (int +'static)`. The latter would // cause a compilation error. Issue #18772. fn adder(y: int) -> Box<Fn(int) -> int +'static> { box...
random_line_split
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes //! escape, an...
let style = self.as_element().unwrap().resolved_style(); return match style.as_ref().get_counters().content { content::T::Items(ref value) if!value.is_empty() => { TextContent::GeneratedContent((*value).clone()) } _ => TextCont...
fn text_content(&self) -> TextContent { if self.get_pseudo_element_type().is_replaced_content() {
random_line_split
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes //! escape, an...
(self, new_flags: LayoutDataFlags) { self.mutate_layout_data().unwrap().flags.insert(new_flags); } fn remove_flags(self, flags: LayoutDataFlags) { self.mutate_layout_data().unwrap().flags.remove(flags); } fn text_content(&self) -> TextContent { if self.get_pseudo_element_type()...
insert_flags
identifier_name
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes //! escape, an...
} } pub trait ThreadSafeLayoutNodeHelpers { /// Returns the layout data flags for this node. fn flags(self) -> LayoutDataFlags; /// Adds the given flags to this node. fn insert_flags(self, new_flags: LayoutDataFlags); /// Removes the given flags from this node. fn remove_flags(self, flag...
{ unsafe { drop_style_and_layout_data(self.take_style_and_layout_data()) }; }
conditional_block
wrapper.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes //! escape, an...
fn mutate_layout_data(&self) -> Option<AtomicRefMut<LayoutData>> { self.get_raw_data().map(|d| d.layout_data.borrow_mut()) } fn flow_debug_id(self) -> usize { self.borrow_layout_data().map_or(0, |d| d.flow_construction_result.debug_id()) } } pub trait GetRawData { fn get_raw_data...
{ self.get_raw_data().map(|d| d.layout_data.borrow()) }
identifier_body
subresource_integrity.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use base64; use net_traits::response::{Response, ResponseBody, ResponseType}; use openssl::hash::{MessageDigest, h...
fn not_empty(&split: &&str) -> bool {!split.is_empty() } s.split(HTML_SPACE_CHARACTERS).filter(not_empty as fn(&&str) -> bool) }
Filter<Split<'a, StaticCharVec>, fn(&&str) -> bool> {
random_line_split
subresource_integrity.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use base64; use net_traits::response::{Response, ResponseBody, ResponseType}; use openssl::hash::{MessageDigest, h...
else { Some(hash_func_right.to_owned()) } } /// https://w3c.github.io/webappsec-subresource-integrity/#get-the-strongest-metadata pub fn get_strongest_metadata(integrity_metadata_list: Vec<SriEntry>) -> Vec<SriEntry> { let mut result: Vec<SriEntry> = vec![integrity_metadata_list[0].clone()]; let ...
{ Some(hash_func_left.to_owned()) }
conditional_block
subresource_integrity.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use base64; use net_traits::response::{Response, ResponseBody, ResponseType}; use openssl::hash::{MessageDigest, h...
(integrity_metadata: &str, response: &Response) -> bool { let parsed_metadata_list: Vec<SriEntry> = parsed_metadata(integrity_metadata); // Step 2 & 4 if parsed_metadata_list.is_empty() { return true; } // Step 3 if!is_eligible_for_integrity_validation(response) { return false;...
is_response_integrity_valid
identifier_name
htmldialogelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bind...
document: &Document) -> Root<HTMLDialogElement> { let element = HTMLDialogElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLDialogElementBinding::Wrap) } } impl HTMLDialogElementMethods for HTMLDialogElement { // https://html.spec....
random_line_split
htmldialogelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bind...
(&self, return_value: DOMString) { *self.return_value.borrow_mut() = return_value; } }
SetReturnValue
identifier_name
htmldialogelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bind...
}
{ *self.return_value.borrow_mut() = return_value; }
identifier_body
tokens.rs
use slp_shared::*; #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone)] pub struct Identifier(pub String); #[derive(PartialEq, Debug, Clone)] pub enum FollowedBy { Token, Whitespace, } #[derive(PartialEq, Debug, Clone)] pub enum RegisterSlot { T(u32), U(u32), B(u32), S(u32), } #[de...
} #[derive(PartialEq, Debug, Clone)] pub struct Tokens { pub stream: Vec<LexToken>, }
{ LexToken(token, FileLocation::none()) }
identifier_body
tokens.rs
use slp_shared::*; #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone)] pub struct
(pub String); #[derive(PartialEq, Debug, Clone)] pub enum FollowedBy { Token, Whitespace, } #[derive(PartialEq, Debug, Clone)] pub enum RegisterSlot { T(u32), U(u32), B(u32), S(u32), } #[derive(PartialEq, Debug, Clone)] pub enum OffsetSlot { T(u32), U(u32), B(u32), } #[derive(Par...
Identifier
identifier_name
tokens.rs
use slp_shared::*; #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone)] pub struct Identifier(pub String); #[derive(PartialEq, Debug, Clone)] pub enum FollowedBy { Token, Whitespace, } #[derive(PartialEq, Debug, Clone)] pub enum RegisterSlot { T(u32), U(u32), B(u32), S(u32), } #[der...
#[derive(PartialEq, Debug, Clone)] pub enum Token { Eof, // Marks the end of a stream Id(Identifier), LiteralInt(u64), // Int (Hlsl ints do not have sign, the - is an operator on the literal) LiteralUInt(u64), // Int with explicit unsigned type LiteralLong(u64), // Int with explicit long type ...
B(u32), }
random_line_split
unrooted_must_root.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use rustc::hir; use rustc::hir::intravisit as visit; use rustc::hir::map as ast_map; use rustc::lint::{LateContext...
(&mut self, _: &'tcx hir::ForeignItem) {} fn visit_ty(&mut self, _: &'tcx hir::Ty) { } fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap<'this, 'tcx> { hir::intravisit::NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir) } }
visit_foreign_item
identifier_name
unrooted_must_root.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use rustc::hir; use rustc::hir::intravisit as visit; use rustc::hir::map as ast_map; use rustc::lint::{LateContext...
} impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass { /// All structs containing #[must_root] types must be #[must_root] themselves fn check_struct_def(&mut self, cx: &LateContext, def: &hir::VariantData, _n: ast::Name, ...
{ lint_array!(UNROOTED_MUST_ROOT) }
identifier_body
unrooted_must_root.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use rustc::hir; use rustc::hir::intravisit as visit; use rustc::hir::map as ast_map; use rustc::lint::{LateContext...
if let visit::FnKind::Closure(_) = kind { visit::walk_fn(self, kind, decl, body, span, id); } } fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem) {} fn visit_ty(&mut self, _: &'tcx hir::Ty) { } fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedV...
visit::walk_pat(self, pat); } fn visit_fn(&mut self, kind: visit::FnKind<'tcx>, decl: &'tcx hir::FnDecl, body: hir::BodyId, span: codemap::Span, id: ast::NodeId) {
random_line_split
lib.rs
#![recursion_limit = "256"] #![forbid(unsafe_code)]
// // Core Stencila objects e.g `File`, `Article`, `Project` pub mod conversions; pub mod documents; pub mod files; pub use kernels; pub mod projects; pub mod sessions; pub mod sources; // Features // // Features that can be turned off #[cfg(feature = "cli")] pub mod cli; #[cfg(feature = "upgrade")] pub mod upgrade...
// Objects
random_line_split
term.rs
use crate::types::binary::OwnedBinary; use crate::wrapper::env::term_to_binary; use crate::wrapper::NIF_TERM; use crate::{Binary, Decoder, Env, NifResult}; use std::cmp::Ordering; use std::fmt::{self, Debug}; /// Term is used to represent all erlang terms. Terms are always lifetime limited by a Env. /// /// Term is cl...
(&self, other: &Term<'a>) -> Option<Ordering> { Some(cmp(self, other)) } } unsafe impl<'a> Sync for Term<'a> {} unsafe impl<'a> Send for Term<'a> {}
partial_cmp
identifier_name
term.rs
use crate::types::binary::OwnedBinary; use crate::wrapper::env::term_to_binary; use crate::wrapper::NIF_TERM; use crate::{Binary, Decoder, Env, NifResult}; use std::cmp::Ordering; use std::fmt::{self, Debug}; /// Term is used to represent all erlang terms. Terms are always lifetime limited by a Env. /// /// Term is cl...
let ord = unsafe { rustler_sys::enif_compare(lhs.as_c_arg(), rhs.as_c_arg()) }; match ord { 0 => Ordering::Equal, n if n < 0 => Ordering::Less, _ => Ordering::Greater, } } impl<'a> Ord for Term<'a> { fn cmp(&self, other: &Term) -> Ordering { cmp(self, other) } } impl...
} impl<'a> Eq for Term<'a> {} fn cmp(lhs: &Term, rhs: &Term) -> Ordering {
random_line_split
inline.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 ...
(ccx: &CrateContext, fn_id: ast::DefId) -> Option<ast::DefId> { debug!("instantiate_inline({:?})", fn_id); let _icx = push_ctxt("instantiate_inline"); match ccx.external().borrow().get(&fn_id) { Some(&Some(node_id)) => { // Already inline debug!("instantiate_inline({}): ...
instantiate_inline
identifier_name
inline.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 ...
{ get_local_instance(ccx, fn_id).unwrap_or(fn_id) }
identifier_body
inline.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 ...
Some(local_def(inline_id)) } pub fn get_local_instance(ccx: &CrateContext, fn_id: ast::DefId) -> Option<ast::DefId> { if fn_id.krate == ast::LOCAL_CRATE { Some(fn_id) } else { instantiate_inline(ccx, fn_id) } } pub fn maybe_instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)...
} impl_item.id } };
random_line_split
bayesian.rs
// Copyright 2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! Utilities for Bayesian statistics. use ordered_float::OrderedFloat; use itertools::Itertools; use stats::LogProb; ...
} expected_fdr } #[cfg(test)] mod tests { use super::*; use stats::LogProb; #[test] fn test_expected_fdr() { let peps = [LogProb(0.1f64.ln()), LogProb::ln_zero(), LogProb(0.25f64.ln())]; let fdrs = expected_fdr(&peps); println!("{:?}", fdrs); assert_relative_...
LogProb::ln_one() };
conditional_block
bayesian.rs
// Copyright 2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! Utilities for Bayesian statistics.
/// For each of the hypothesis tests given as posterior error probabilities /// (PEPs, i.e. the posterior probability of the null hypothesis), estimate the FDR /// for the case that all null hypotheses with at most this PEP are rejected. /// FDR is calculated as presented by Müller, Parmigiani, and Rice, /// "FDR and...
use ordered_float::OrderedFloat; use itertools::Itertools; use stats::LogProb;
random_line_split
bayesian.rs
// Copyright 2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! Utilities for Bayesian statistics. use ordered_float::OrderedFloat; use itertools::Itertools; use stats::LogProb; ...
#[cfg(test)] mod tests { use super::*; use stats::LogProb; #[test] fn test_expected_fdr() { let peps = [LogProb(0.1f64.ln()), LogProb::ln_zero(), LogProb(0.25f64.ln())]; let fdrs = expected_fdr(&peps); println!("{:?}", fdrs); assert_relative_eq!(*fdrs[1], *LogProb::ln_...
// sort indices let sorted_idx = (0..peps.len()).sorted_by(|&i, &j| OrderedFloat(*peps[i]).cmp(&OrderedFloat(*peps[j]))); // estimate FDR let mut expected_fdr = vec![LogProb::ln_zero(); peps.len()]; for (i, expected_fp) in LogProb::ln_cumsum_exp(sorted_idx.iter().map(|&i| peps[i])) ...
identifier_body
bayesian.rs
// Copyright 2016 Johannes Köster. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! Utilities for Bayesian statistics. use ordered_float::OrderedFloat; use itertools::Itertools; use stats::LogProb; ...
{ let peps = [LogProb(0.1f64.ln()), LogProb::ln_zero(), LogProb(0.25f64.ln())]; let fdrs = expected_fdr(&peps); println!("{:?}", fdrs); assert_relative_eq!(*fdrs[1], *LogProb::ln_zero()); assert_relative_eq!(*fdrs[0], *LogProb(0.05f64.ln())); assert_relative_eq!(*fdrs[2...
st_expected_fdr()
identifier_name
mod.rs
use std::sync::{Arc, RwLock}; use std::vec::IntoIter; use radix_trie::Trie; use crate::completion::Completer; use crate::config::{Config, EditMode}; use crate::edit::init_state; use crate::highlight::Highlighter; use crate::hint::Hinter; use crate::keymap::{Cmd, InputState}; use crate::keys::{KeyCode as K, KeyEvent, ...
(&self, _line: &str, _pos: usize, _ctx: &Context<'_>) -> Option<Self::Hint> { None } } impl Helper for SimpleCompleter {} impl Highlighter for SimpleCompleter {} impl Validator for SimpleCompleter {} #[test] fn complete_line() { let mut out = Sink::default(); let history = crate::history::History:...
hint
identifier_name
mod.rs
use std::sync::{Arc, RwLock}; use std::vec::IntoIter; use radix_trie::Trie; use crate::completion::Completer; use crate::config::{Config, EditMode}; use crate::edit::init_state; use crate::highlight::Highlighter; use crate::hint::Hinter; use crate::keymap::{Cmd, InputState}; use crate::keys::{KeyCode as K, KeyEvent, ...
}
random_line_split
mod.rs
use std::sync::{Arc, RwLock}; use std::vec::IntoIter; use radix_trie::Trie; use crate::completion::Completer; use crate::config::{Config, EditMode}; use crate::edit::init_state; use crate::highlight::Highlighter; use crate::hint::Hinter; use crate::keymap::{Cmd, InputState}; use crate::keys::{KeyCode as K, KeyEvent, ...
} #[test] fn unknown_esc_key() { for mode in &[EditMode::Emacs, EditMode::Vi] { assert_line(*mode, &[E(K::UnknownEscSeq, M::NONE), E::ENTER], ""); } } #[test] fn test_send() { fn assert_send<T: Send>() {} assert_send::<Editor<()>>(); } #[test] fn test_sync() { fn assert_sync<T: Sync>() {...
{ assert_eq!(expected.0.len(), editor.term.cursor); }
conditional_block
mod.rs
use std::sync::{Arc, RwLock}; use std::vec::IntoIter; use radix_trie::Trie; use crate::completion::Completer; use crate::config::{Config, EditMode}; use crate::edit::init_state; use crate::highlight::Highlighter; use crate::hint::Hinter; use crate::keymap::{Cmd, InputState}; use crate::keys::{KeyCode as K, KeyEvent, ...
// `initial`: line status before `keys` pressed: strings before and after cursor // `keys`: keys to press // `expected_line`: line after enter key fn assert_line_with_initial( mode: EditMode, initial: (&str, &str), keys: &[KeyEvent], expected_line: &str, ) { let mut editor = init_editor(mode, keys...
{ let mut editor = init_editor(mode, keys); let actual_line = editor.readline(">>").unwrap(); assert_eq!(expected_line, actual_line); }
identifier_body
kindck-send-object1.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 ...
<'a>() { assert_send::<&'a Dummy>(); //~^ ERROR the trait `core::marker::Sync` is not implemented } fn test52<'a>() { assert_send::<&'a (Dummy+Sync)>(); //~^ ERROR does not fulfill the required lifetime } //...unless they are properly bounded fn test60() { assert_send::<&'static (Dummy+Sync)>(); } ...
test51
identifier_name
kindck-send-object1.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 ...
// option. This file may not be copied, modified, or distributed // except according to those terms. // Test which object types are considered sendable. This test // is broken into two parts because some errors occur in distinct // phases in the compiler. See kindck-send-object2.rs as well! fn assert_send<T:Send+'sta...
random_line_split
kindck-send-object1.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 ...
//...unless they are properly bounded fn test60() { assert_send::<&'static (Dummy+Sync)>(); } fn test61() { assert_send::<Box<Dummy+Send>>(); } // closure and object types can have lifetime bounds which make // them not ok fn test_71<'a>() { assert_send::<Box<Dummy+'a>>(); //~^ ERROR the trait `core:...
{ assert_send::<&'a (Dummy+Sync)>(); //~^ ERROR does not fulfill the required lifetime }
identifier_body
securitybaseapi.rs
// Copyright © 2016-2017 winapi-rs developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied,...
// pub fn GetSecurityDescriptorControl(); // pub fn GetSecurityDescriptorDacl(); // pub fn GetSecurityDescriptorGroup(); // pub fn GetSecurityDescriptorLength(); // pub fn GetSecurityDescriptorOwner(); // pub fn GetSecurityDescriptorRMControl(); // pub fn GetSecurityDescriptorSacl(); // ...
// pub fn GetFileSecurityW(); // pub fn GetKernelObjectSecurity(); // pub fn GetLengthSid(); // pub fn GetPrivateObjectSecurity();
random_line_split
gradient.rs
// Copyright 2015 the simplectic-noise developers. For a full listing of the // authors, refer to the AUTHORS file at the top-level directory of this // distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obta...
use std::num::Float; use math; pub fn get2<T: Float>(index: usize) -> math::Point2<T> { let diag: T = math::cast(0.70710678118f32); let one: T = math::cast(1.0f32); let zero: T = math::cast(0.0f32); match index % 8 { 0 => [ diag, diag], 1 => [ diag, -diag], 2 => [-diag, diag...
// limitations under the License.
random_line_split
gradient.rs
// Copyright 2015 the simplectic-noise developers. For a full listing of the // authors, refer to the AUTHORS file at the top-level directory of this // distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obta...
#[inline(always)] pub fn get3<T: Float>(index: usize) -> math::Point3<T> { let diag: T = math::cast(0.70710678118f32); let zero: T = math::cast(0.0f32); match index % 12 { 0 => [ diag, diag, zero], 1 => [ diag, -diag, zero], 2 => [-diag, diag, zero], 3 => [-diag, -...
{ let diag: T = math::cast(0.70710678118f32); let one: T = math::cast(1.0f32); let zero: T = math::cast(0.0f32); match index % 8 { 0 => [ diag, diag], 1 => [ diag, -diag], 2 => [-diag, diag], 3 => [-diag, -diag], 4 => [ one, zero], 5 => [-one, zero],...
identifier_body
gradient.rs
// Copyright 2015 the simplectic-noise developers. For a full listing of the // authors, refer to the AUTHORS file at the top-level directory of this // distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obta...
<T: Float>(index: usize) -> math::Point3<T> { let diag: T = math::cast(0.70710678118f32); let zero: T = math::cast(0.0f32); match index % 12 { 0 => [ diag, diag, zero], 1 => [ diag, -diag, zero], 2 => [-diag, diag, zero], 3 => [-diag, -diag, zero], 4 => [ d...
get3
identifier_name
ta.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::alloc::{TaPool, MemPool}; #[test] fn alloc() { let mut buf = &mut [d8::new(0); 5][..]; let addr = b...
*alloc = 1; let realloc = pool.realloc(alloc as *mut d8, 1, 2, 1).unwrap() as *mut u8; test!(*realloc == 1); } test!(buf.len() == 3); }
let alloc = pool.alloc(1, 1).unwrap() as *mut u8;
random_line_split
ta.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::alloc::{TaPool, MemPool}; #[test] fn alloc() { let mut buf = &mut [d8::new(0); 5][..]; let addr = b...
() { let mut buf = &mut [d8::new(0); 5][..]; unsafe { let mut pool = TaPool::new(&mut buf); let alloc = pool.alloc(1, 1).unwrap() as *mut u8; *alloc = 1; let realloc = pool.realloc(alloc as *mut d8, 1, 2, 1).unwrap() as *mut u8; test!(*realloc == 1); } test!(buf.l...
realloc
identifier_name
ta.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::alloc::{TaPool, MemPool}; #[test] fn alloc()
#[test] fn realloc() { let mut buf = &mut [d8::new(0); 5][..]; unsafe { let mut pool = TaPool::new(&mut buf); let alloc = pool.alloc(1, 1).unwrap() as *mut u8; *alloc = 1; let realloc = pool.realloc(alloc as *mut d8, 1, 2, 1).unwrap() as *mut u8; test!(*realloc == 1); ...
{ let mut buf = &mut [d8::new(0); 5][..]; let addr = buf.as_ptr() as usize; unsafe { let mut pool1 = TaPool::new(&mut buf); let mut pool2 = pool1; let a1 = pool1.alloc(1, 1).unwrap(); test!(a1 as usize == addr); let a2 = pool2.alloc(2, 1).unwrap(); test!(a2 ...
identifier_body
stream.rs
> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// receiver. The sender will b...
Data(t) => Ok(t), GoUp(up) => Err(Upgraded(up)), } } None => { match self.cnt.load(atomic::SeqCst) { n if n!= DISCONNECTED => Err(Empty), // This is a little bit of a tricky case. We...
} self.steals += 1; match data {
random_line_split
stream.rs
or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// receiver. The sender will be...
} } pub fn drop_port(&mut self) { // Dropping a port seems like a fairly trivial thing. In theory all we // need to do is flag that we're disconnected and then everything else // can take over (we don't have anyone to wake up). // // The catch for Ports is that ...
{ assert!(n >= 0); }
conditional_block
stream.rs
or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// receiver. The sender will be...
pub fn upgrade(&mut self, up: Receiver<T>) -> UpgradeResult { // If the port has gone away, then there's no need to proceed any // further. if self.port_dropped.load(atomic::SeqCst) { return UpDisconnected } self.do_send(GoUp(up)) } fn do_send(&mut self, t: Message<T>) -> ...
{ // If the other port has deterministically gone away, then definitely // must return the data back up the stack. Otherwise, the data is // considered as being sent. if self.port_dropped.load(atomic::SeqCst) { return Err(t) } match self.do_send(Data(t)) { UpSuccess ...
identifier_body
stream.rs
or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// receiver. The sender will be...
{ UpSuccess, UpDisconnected, UpWoke(BlockedTask), } pub enum SelectionResult<T> { SelSuccess, SelCanceled(BlockedTask), SelUpgraded(BlockedTask, Receiver<T>), } // Any message could contain an "upgrade request" to a new shared port, so the // internal queue it's a queue of T, but rather Messa...
UpgradeResult
identifier_name
cssconditionrule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSConditionRuleBinding::CSSConditionRuleMethods; use dom::bindings::inherit...
(parent_stylesheet: &CSSStyleSheet, rules: Arc<Locked<StyleCssRules>>) -> CSSConditionRule { CSSConditionRule { cssgroupingrule: CSSGroupingRule::new_inherited(parent_stylesheet, rules), } } pub fn parent_stylesheet(&self) -> &CSSStyleSheet { self.cs...
new_inherited
identifier_name
cssconditionrule.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::cssmediarule::CSSMediaRule; use dom::cssstylesheet::CSSStyleSheet; use dom::csssupportsrule::CSSSupportsRule; use dom_struct::dom_struct; use style::shared_lock::{SharedRwLock, Locked}; use style::stylearc::Arc; use style::stylesheets::CssRules as StyleCssRules; #[dom_struct] pub struct CSSConditionRule { ...
use dom::bindings::codegen::Bindings::CSSConditionRuleBinding::CSSConditionRuleMethods; use dom::bindings::inheritance::Castable; use dom::bindings::str::DOMString; use dom::cssgroupingrule::CSSGroupingRule;
random_line_split
hs_hist.rs
extern crate cv; use cv::highgui::*; use cv::imgcodecs::ImageReadMode; use cv::imgproc::ColorConversion; use cv::*; fn main()
let hsv = mat.cvt_color(ColorConversion::BGR2HSV); //////////////////////////////// // // 2. Calculate the histogram // (demo multiple channels) // /////////////////////////////// let hbins = 30; let sbins = 32; let hist_size = [hbins, sbins]; let hranges = [0.0, 180.0]...
{ //////////////////////////////// // // 1. Read the image // /////////////////////////////// let args: Vec<_> = std::env::args().collect(); if args.len() != 2 { println!("Usage: calchist <Path to Image>"); std::process::exit(-1); } let mat = Mat::from_path(&args[1]...
identifier_body
hs_hist.rs
extern crate cv; use cv::highgui::*; use cv::imgcodecs::ImageReadMode; use cv::imgproc::ColorConversion; use cv::*; fn main() { //////////////////////////////// // // 1. Read the image // /////////////////////////////// let args: Vec<_> = std::env::args().collect(); if args.len()!= 2 { ...
let hsv = mat.cvt_color(ColorConversion::BGR2HSV); //////////////////////////////// // // 2. Calculate the histogram // (demo multiple channels) // /////////////////////////////// let hbins = 30; let sbins = 32; let hist_size = [hbins, sbins]; let hranges = [0.0, 180....
{ println!("Could not open or find the image"); std::process::exit(-1); }
conditional_block
hs_hist.rs
extern crate cv; use cv::highgui::*; use cv::imgcodecs::ImageReadMode; use cv::imgproc::ColorConversion; use cv::*; fn
() { //////////////////////////////// // // 1. Read the image // /////////////////////////////// let args: Vec<_> = std::env::args().collect(); if args.len()!= 2 { println!("Usage: calchist <Path to Image>"); std::process::exit(-1); } let mat = Mat::from_path(&args[...
main
identifier_name
hs_hist.rs
extern crate cv; use cv::highgui::*; use cv::imgcodecs::ImageReadMode; use cv::imgproc::ColorConversion; use cv::*; fn main() { //////////////////////////////// // // 1. Read the image // /////////////////////////////// let args: Vec<_> = std::env::args().collect(); if args.len()!= 2 { ...
// /////////////////////////////// let hbins = 30; let sbins = 32; let hist_size = [hbins, sbins]; let hranges = [0.0, 180.0]; let sranges = [0.0, 256.0]; let ranges = [hranges, sranges]; let channels = [0, 1]; let hist = hsv.calc_hist(&channels, &Mat::new(), &hist_size, &ran...
random_line_split
threads.rs
//! I/O compression/decompression threading control. //! //! This module provides functions for enabling/disabling and managing the //! global thread pool of OpenEXR. Importantly, if the thread pool is enabled, //! OpenEXR will use the same thread pool for all OpenEXR reading/writing, which //! can sometimes have unex...
if error!= 0 { Err(Error::take(error_out)) } else { Ok(()) } } #[test] fn test_set_global_thread_count() { assert!(set_global_thread_count(4).is_ok()); assert!(set_global_thread_count(::std::os::raw::c_int::max_value() as usize + 1).is_err()); }
openexr_sys::CEXR_set_global_thread_count( thread_count as ::std::os::raw::c_int, &mut error_out, ) };
random_line_split
threads.rs
//! I/O compression/decompression threading control. //! //! This module provides functions for enabling/disabling and managing the //! global thread pool of OpenEXR. Importantly, if the thread pool is enabled, //! OpenEXR will use the same thread pool for all OpenEXR reading/writing, which //! can sometimes have unex...
} #[test] fn test_set_global_thread_count() { assert!(set_global_thread_count(4).is_ok()); assert!(set_global_thread_count(::std::os::raw::c_int::max_value() as usize + 1).is_err()); }
{ Ok(()) }
conditional_block
threads.rs
//! I/O compression/decompression threading control. //! //! This module provides functions for enabling/disabling and managing the //! global thread pool of OpenEXR. Importantly, if the thread pool is enabled, //! OpenEXR will use the same thread pool for all OpenEXR reading/writing, which //! can sometimes have unex...
{ assert!(set_global_thread_count(4).is_ok()); assert!(set_global_thread_count(::std::os::raw::c_int::max_value() as usize + 1).is_err()); }
identifier_body
threads.rs
//! I/O compression/decompression threading control. //! //! This module provides functions for enabling/disabling and managing the //! global thread pool of OpenEXR. Importantly, if the thread pool is enabled, //! OpenEXR will use the same thread pool for all OpenEXR reading/writing, which //! can sometimes have unex...
(thread_count: usize) -> Result<()> { if thread_count > ::std::os::raw::c_int::max_value() as usize { return Err(Error::Generic(String::from( "The number of threads is too high", ))); } let mut error_out = ::std::ptr::null(); let error = unsafe { openexr_sys::CEXR_s...
set_global_thread_count
identifier_name
derive.rs
extern crate setlike; extern crate avarice; #[macro_use] extern crate avarice_derive; #[cfg(test)] mod test { use avarice::objective::*; use avarice::objective::curvature::Bounded; use avarice::errors::*; use setlike::Setlike; use std::iter; macro_rules! obj { ($tr:ident, $name:ident) ...
obj!(Modular, ModObj); #[test] fn mod_derived_bounds() { assert!(ModObj::bounds() == (Some(1.0), Some(1.0))); } }
{ assert!(SupObj::bounds() == (Some(1.0), None)); }
identifier_body
derive.rs
extern crate setlike; extern crate avarice; #[macro_use] extern crate avarice_derive; #[cfg(test)] mod test { use avarice::objective::*; use avarice::objective::curvature::Bounded; use avarice::errors::*; use setlike::Setlike;
($tr:ident, $name:ident) => { #[derive($tr, Debug, Clone)] struct $name {} impl Objective for $name { type Element = (); type State = (); fn elements(&self) -> ElementIterator<Self> { Box::new(iter::empty()...
use std::iter; macro_rules! obj {
random_line_split
derive.rs
extern crate setlike; extern crate avarice; #[macro_use] extern crate avarice_derive; #[cfg(test)] mod test { use avarice::objective::*; use avarice::objective::curvature::Bounded; use avarice::errors::*; use setlike::Setlike; use std::iter; macro_rules! obj { ($tr:ident, $name:ident) ...
() { assert!(SupObj::bounds() == (Some(1.0), None)); } obj!(Modular, ModObj); #[test] fn mod_derived_bounds() { assert!(ModObj::bounds() == (Some(1.0), Some(1.0))); } }
supmod_derived_bounds
identifier_name
documentfragment.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentFragmentBinding; use dom::bindings::codegen::Bindings::DocumentFragm...
pub fn new(document: JSRef<Document>) -> Temporary<DocumentFragment> { Node::reflect_node(box DocumentFragment::new_inherited(document), document, DocumentFragmentBinding::Wrap) } pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<DocumentFragment>> { ...
{ DocumentFragment { node: Node::new_inherited(DocumentFragmentNodeTypeId, document), } }
identifier_body
documentfragment.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentFragmentBinding; use dom::bindings::codegen::Bindings::DocumentFragm...
{ node: Node, } impl DocumentFragmentDerived for EventTarget { fn is_documentfragment(&self) -> bool { *self.type_id() == NodeTargetTypeId(DocumentFragmentNodeTypeId) } } impl DocumentFragment { /// Creates a new DocumentFragment. fn new_inherited(document: JSRef<Document>) -> DocumentFra...
DocumentFragment
identifier_name
documentfragment.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentFragmentBinding; use dom::bindings::codegen::Bindings::DocumentFragm...
node: Node::new_inherited(DocumentFragmentNodeTypeId, document), } } pub fn new(document: JSRef<Document>) -> Temporary<DocumentFragment> { Node::reflect_node(box DocumentFragment::new_inherited(document), document, DocumentFragmentBinding::Wrap) } ...
random_line_split
book-store.rs
//! Tests for book-store //! //! Generated by [script][script] using [canonical data][canonical-data] //! //! [script]: https://github.com/exercism/rust/blob/master/bin/init_exercise.py //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/book-store/canonical_data.jso...
#[test] /// Only a single book fn test_only_a_single_book() { process_total_case((vec![1], vec![vec![1]]), 8.0); } #[test] #[ignore] /// Two of the same book fn test_two_of_the_same_book() { process_total_case((vec![2, 2], vec![vec![2], vec![2]]), 16.0); } #[test] #[ignore] /// Empty basket fn test_empty_b...
// a single series. There is no discount advantage for having more than // one copy of any single book in a grouping.
random_line_split
book-store.rs
//! Tests for book-store //! //! Generated by [script][script] using [canonical data][canonical-data] //! //! [script]: https://github.com/exercism/rust/blob/master/bin/init_exercise.py //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/book-store/canonical_data.jso...
#[test] #[ignore] /// Two of the same book fn test_two_of_the_same_book() { process_total_case((vec![2, 2], vec![vec![2], vec![2]]), 16.0); } #[test] #[ignore] /// Empty basket fn test_empty_basket() { process_total_case((vec![], vec![]), 0.0); } #[test] #[ignore] /// Two different books fn test_two_diff...
{ process_total_case((vec![1], vec![vec![1]]), 8.0); }
identifier_body
book-store.rs
//! Tests for book-store //! //! Generated by [script][script] using [canonical data][canonical-data] //! //! [script]: https://github.com/exercism/rust/blob/master/bin/init_exercise.py //! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/book-store/canonical_data.jso...
() { process_total_case((vec![1, 1, 2, 2, 3, 3, 4, 4, 5], vec![vec![1, 2, 3, 4, 5], vec![1, 2, 3, 4]]), 55.6); } #[test] #[ignore] /// Two copies of each book fn test_two_copies_of_each_book() { process_total_case((vec![1, 1, 2, 2, 3, 3, 4, 4, 5, 5], vec![vec![1, 2, 3, 4, 5], vec![1, 2, 3, 4, 5]]), 60.0); } ...
test_two_each_of_first_4_books_and_1_copy_each_of_rest
identifier_name
glue.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/. */ #![allow(unsafe_code)] use app_units::Au; use bindings::{RawGeckoDocument, RawGeckoElement}; use bindings::{RawSe...
#[no_mangle] pub extern "C" fn Servo_GetComputedValuesForAnonymousBox(_: *mut nsIAtom) -> *mut ServoComputedValues { unimplemented!(); } #[no_mangle] pub extern "C" fn Servo_AddRefComputedValues(ptr: *mut ServoComputedValues) -> () { type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>; ...
let node = unsafe { GeckoElement::from_raw(element).as_node() }; let arc_cv = node.borrow_data().map(|data| data.style.clone()); arc_cv.map_or(ptr::null_mut(), |arc| unsafe { transmute(arc) }) }
random_line_split
glue.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/. */ #![allow(unsafe_code)] use app_units::Au; use bindings::{RawGeckoDocument, RawGeckoElement}; use bindings::{RawSe...
<GeckoType, ServoType> { phantom1: PhantomData<GeckoType>, phantom2: PhantomData<ServoType>, } impl<GeckoType, ServoType> ArcHelpers<GeckoType, ServoType> { fn with<F, Output>(raw: *mut GeckoType, cb: F) -> Output where F: FnOnce(&Arc<ServoType>) -> Output { let owned = unsaf...
ArcHelpers
identifier_name
glue.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/. */ #![allow(unsafe_code)] use app_units::Au; use bindings::{RawGeckoDocument, RawGeckoElement}; use bindings::{RawSe...
#[no_mangle] pub extern "C" fn Servo_ReleaseComputedValues(ptr: *mut ServoComputedValues) -> () { type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>; unsafe { Helpers::release(ptr) }; } #[no_mangle] pub extern "C" fn Servo_InitStyleSet() -> *mut RawServoStyleSet { let data = Box::new(Per...
{ type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>; unsafe { Helpers::addref(ptr) }; }
identifier_body
product.rs
//! The unit of processing passing through a pipeline. use std::fmt; /// Color of a grid cell on a Product. #[derive(Clone,Copy,Debug,Eq,PartialEq)] pub enum Color { Unset, Red, Green, Blue, } impl Color { fn short(&self) -> &'static str { match *self { Color::Unset => " ", ...
Ok(()) } }
} try!(f.write_str(",")); }
random_line_split
product.rs
//! The unit of processing passing through a pipeline. use std::fmt; /// Color of a grid cell on a Product. #[derive(Clone,Copy,Debug,Eq,PartialEq)] pub enum Color { Unset, Red, Green, Blue, } impl Color { fn short(&self) -> &'static str { match *self { Color::Unset => " ", ...
() -> Self { Color::Unset } } /// Size of the 2D color grid on a Product. pub const GRID_SIZE: usize = 3; /// Color grid type used in Products. pub type ColorGrid = [[Color; GRID_SIZE]; GRID_SIZE]; /// Product is the unit of processing. /// /// Products are fed into the processing network, mutated, and o...
default
identifier_name
product.rs
//! The unit of processing passing through a pipeline. use std::fmt; /// Color of a grid cell on a Product. #[derive(Clone,Copy,Debug,Eq,PartialEq)] pub enum Color { Unset, Red, Green, Blue, } impl Color { fn short(&self) -> &'static str { match *self { Color::Unset => " ", ...
} impl fmt::Display for Product { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { for row in &self.color_grid { for cell in row { try!(f.write_str(cell.short())); } try!(f.write_str(",")); } Ok(()) } }
{ let mut colors = ColorGrid::default(); for row in &mut colors { for mut cell in row { *cell = color; } } Product { color_grid: colors } }
identifier_body
config.rs
use crate::model::*; use slog::Logger; use slog::{info, o, warn}; use yaml_rust::Yaml; pub fn parse_dot_files(log: &Logger, dot_files: &Yaml) -> Vec<DotFile> { let mut parsed_dot_files = Vec::new(); info!(log, "Processing dotfiles"); if let Yaml::Hash(entries) = dot_files.clone() { for (key, value) in entrie...
parsed_dot_files } fn dot_file_from_settings(log: &Logger, target: &str, settings: &yaml_rust::yaml::Hash) -> DotFile { let mut dot_file = DotFile { source: "<todo>".to_string(), target: target.to_string(), dot_file_type: DotFileType::LINK, }; for (key, value) in settings.clone() { if let (Yam...
{ warn!(log, "Found no entries to process"); }
conditional_block
config.rs
use crate::model::*; use slog::Logger; use slog::{info, o, warn}; use yaml_rust::Yaml; pub fn parse_dot_files(log: &Logger, dot_files: &Yaml) -> Vec<DotFile> { let mut parsed_dot_files = Vec::new(); info!(log, "Processing dotfiles"); if let Yaml::Hash(entries) = dot_files.clone() { for (key, value) in entrie...
(log: &Logger, s: &str) -> DotFileType { match s.to_lowercase().as_ref() { "copy" => DotFileType::COPY, "link" => DotFileType::LINK, x => { warn!(log, "could not parse file type. fallback to link."; "file_type" => x); DotFileType::LINK } } } #[cfg(test)] mod tests { use super::*; us...
dot_file_type_from_string
identifier_name
config.rs
use crate::model::*; use slog::Logger; use slog::{info, o, warn};
pub fn parse_dot_files(log: &Logger, dot_files: &Yaml) -> Vec<DotFile> { let mut parsed_dot_files = Vec::new(); info!(log, "Processing dotfiles"); if let Yaml::Hash(entries) = dot_files.clone() { for (key, value) in entries { match (key, value) { (Yaml::String(target), Yaml::String(source)) => p...
use yaml_rust::Yaml;
random_line_split
config.rs
use crate::model::*; use slog::Logger; use slog::{info, o, warn}; use yaml_rust::Yaml; pub fn parse_dot_files(log: &Logger, dot_files: &Yaml) -> Vec<DotFile> { let mut parsed_dot_files = Vec::new(); info!(log, "Processing dotfiles"); if let Yaml::Hash(entries) = dot_files.clone() { for (key, value) in entrie...
target: "~/.tmux/plugins/tpm".to_string(), dot_file_type: DotFileType::LINK, }); assert_that(&parsed_dot_files).contains(&DotFile { source: "tmux.conf".to_string(), target: "~/.tmux.conf".to_string(), dot_file_type: DotFileType::COPY, }); assert_that(&parsed_dot_files).cont...
{ let s = " files: ~/.tmux/plugins/tpm: tpm ~/.tmux.conf: src: tmux.conf type: copy ~/.vimrc: src: vimrc type: link "; let yaml_documents = YamlLoader::load_from_str(s).unwrap(); let yaml_config = &yaml_documents[0]; let dot_files: &Yaml = &yaml_config["files"...
identifier_body
source.rs
//! Event sources and callbacks. //! //! This is a light-weight implementation of the observer pattern. Subjects are //! modelled as the `Source` type and observers as boxed closures. use std::sync::{RwLock, Weak}; /// An error that can occur with a weakly referenced callback. #[derive(PartialEq, Eq, Clone, Copy, Deb...
impl<A: Send + Sync + Clone +'static> Source<A> { /// Make the source send an event to all its observers. pub fn send(&mut self, a: A) { use std::mem; let mut new_callbacks = vec![]; mem::swap(&mut new_callbacks, &mut self.callbacks); let n = new_callbacks.len(); let mut...
{ self.callbacks.push(Box::new(callback)); } }
random_line_split
source.rs
//! Event sources and callbacks. //! //! This is a light-weight implementation of the observer pattern. Subjects are //! modelled as the `Source` type and observers as boxed closures. use std::sync::{RwLock, Weak}; /// An error that can occur with a weakly referenced callback. #[derive(PartialEq, Eq, Clone, Copy, Deb...
#[test] fn source_register_and_send() { let mut src = Source::new(); let a = Arc::new(RwLock::new(3)); { let a = a.clone(); src.register(move |x| { *a.write().unwrap() = x; Ok(()) }); } assert_eq!(src.c...
{ let a = Arc::new(RwLock::new(3)); let a2 = a.clone(); let weak = Arc::downgrade(&a); let _ = thread::spawn(move || { let _g = a2.write().unwrap(); panic!(); }) .join(); assert_eq!(with_weak(&weak, |_| ()), Err(CallbackError::Poisoned)); ...
identifier_body
source.rs
//! Event sources and callbacks. //! //! This is a light-weight implementation of the observer pattern. Subjects are //! modelled as the `Source` type and observers as boxed closures. use std::sync::{RwLock, Weak}; /// An error that can occur with a weakly referenced callback. #[derive(PartialEq, Eq, Clone, Copy, Deb...
} } } #[cfg(test)] mod test { use super::*; use std::sync::{Arc, RwLock}; use std::thread; #[test] fn with_weak_no_error() { let a = Arc::new(RwLock::new(3)); let weak = Arc::downgrade(&a); assert_eq!( with_weak(&weak, |a| { *a = 4; ...
{ self.callbacks.push(callback); }
conditional_block
source.rs
//! Event sources and callbacks. //! //! This is a light-weight implementation of the observer pattern. Subjects are //! modelled as the `Source` type and observers as boxed closures. use std::sync::{RwLock, Weak}; /// An error that can occur with a weakly referenced callback. #[derive(PartialEq, Eq, Clone, Copy, Deb...
(&mut self, a: A) { use std::mem; let mut new_callbacks = vec![]; mem::swap(&mut new_callbacks, &mut self.callbacks); let n = new_callbacks.len(); let mut iter = new_callbacks.into_iter(); for _ in 1..n { let mut callback = iter.next().unwrap(); if...
send
identifier_name
text_list.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
(self) -> ListIter<Reader<'a>, Result<crate::text::Reader<'a>>>{ let l = self.len(); ListIter::new(self, l) } } impl <'a> FromPointerReader<'a> for Reader<'a> { fn get_from_pointer(reader: &PointerReader<'a>, default: Option<&'a [crate::Word]>) -> Result<Reader<'a>> { Ok(Reader { reader...
iter
identifier_name
text_list.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
} } impl <'a> IndexMove<u32, Result<crate::text::Reader<'a>>> for Reader<'a>{ fn index_move(&self, index : u32) -> Result<crate::text::Reader<'a>> { self.get(index) } } impl <'a> Reader<'a> { pub fn get(self, index : u32) -> Result<crate::text::Reader<'a>> { assert!(index < self.len(...
} impl <'a> FromPointerReader<'a> for Reader<'a> { fn get_from_pointer(reader: &PointerReader<'a>, default: Option<&'a [crate::Word]>) -> Result<Reader<'a>> { Ok(Reader { reader : reader.get_list(Pointer, default)? })
random_line_split
idle.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 ...
() { let tube = Tube::new(); let cb = ~MyCallback(tube.clone(), 1); let mut idle = IdleWatcher::new(local_loop(), cb as ~Callback); idle.resume(); fail!(); } #[test] fn fun_combinations_of_methods() { let mut tube = Tube::new(); let cb = ~MyCallback(t...
smoke_fail
identifier_name
idle.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 ...
} #[test] fn not_used() { let cb = ~MyCallback(Tube::new(), 1); let _idle = IdleWatcher::new(local_loop(), cb as ~Callback); } #[test] fn smoke_test() { let mut tube = Tube::new(); let cb = ~MyCallback(tube.clone(), 1); let mut idle = IdleWatcher::new(l...
{ match *self { MyCallback(ref mut tube, val) => tube.send(val) } }
identifier_body
idle.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 ...
idle.pause(); idle.resume(); idle.resume(); tube.recv(); idle.pause(); idle.pause(); idle.resume(); tube.recv(); } #[test] fn pause_pauses() { let mut tube = Tube::new(); let cb = ~MyCallback(tube.clone(), 1); let mut i...
tube.recv();
random_line_split
idle.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } impl UvHandle<uvll::uv_idle_t> for IdleWatcher { fn uv_handle(&self) -> *uvll::uv_idle_t { self.handle } } extern fn idle_cb(handle: *uvll::uv_idle_t, status: c_int) { assert_eq!(status, 0); let idle: &mut IdleWatcher = unsafe { UvHandle::from_uv_handle(&handle) }; idle.callback.call(); } im...
{ assert_eq!(unsafe { uvll::uv_idle_start(self.handle, idle_cb) }, 0) self.idle_flag = true; }
conditional_block
lib.rs
#![doc(html_logo_url = "https://raw.githubusercontent.com/Kliemann-Service-GmbH/xMZ-Mod-Touch-Server/master/share/xmz-logo.png", html_favicon_url = "https://raw.githubusercontent.com/Kliemann-Service-GmbH/xMZ-Mod-Touch-Server/master/share/favicon.ico", html_root_url = "https://gaswarnanlagen.com/")] //! `...
extern crate iron; extern crate libmodbus_rs; extern crate rand; extern crate router; extern crate serde_json; extern crate sysfs_gpio; pub mod errors; pub mod exception; pub mod json_api; pub mod server; pub mod shift_register; pub use self::exception::{Action, Check, Exception, ExceptionType}; pub use self::server:...
#[macro_use] extern crate log; #[macro_use] extern crate serde_derive; extern crate chrono; extern crate env_logger;
random_line_split
tag-align-dyn-u64.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...
}
random_line_split
tag-align-dyn-u64.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn is_8_byte_aligned(u: &Tag<u64>) -> bool { let p: uint = unsafe { mem::transmute(u) }; return (p & 7_usize) == 0_usize; } pub fn main() { let x = mk_rec(); assert!(is_8_byte_aligned(&x.t)); }
{ return Rec { c8:0u8, t:Tag::Tag2(0u64) }; }
identifier_body
tag-align-dyn-u64.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...
{ c8: u8, t: Tag<u64> } fn mk_rec() -> Rec { return Rec { c8:0u8, t:Tag::Tag2(0u64) }; } fn is_8_byte_aligned(u: &Tag<u64>) -> bool { let p: uint = unsafe { mem::transmute(u) }; return (p & 7_usize) == 0_usize; } pub fn main() { let x = mk_rec(); assert!(is_8_byte_aligned(&x.t)); }
Rec
identifier_name
git.rs
use std::collections::HashMap; use std::env; use std::fs::{self, File}; use std::io::prelude::*; use std::path::{Path, PathBuf}; use semver; use git2; use rustc_serialize::json; use app::App; use dependency::Kind; use util::{CargoResult, internal}; #[derive(RustcEncodable, RustcDecodable)] pub struct Crate { pub...
<F>(repo: &git2::Repository, mut f: F) -> CargoResult<()> where F: FnMut() -> CargoResult<(String, PathBuf)> { let repo_path = repo.workdir().unwrap(); // Attempt to commit in a loop. It's possible that we're going to need to // rebase our repository, and after that it's possible that we're going to ...
commit_and_push
identifier_name
git.rs
use std::collections::HashMap; use std::env; use std::fs::{self, File}; use std::io::prelude::*; use std::path::{Path, PathBuf}; use semver; use git2; use rustc_serialize::json; use app::App; use dependency::Kind; use util::{CargoResult, internal}; #[derive(RustcEncodable, RustcDecodable)] pub struct Crate { pub...
if git_crate.name!= krate || git_crate.vers.to_string()!= version.to_string() { return Ok(line.to_string()) } git_crate.yanked = Some(yanked); Ok(json::encode(&git_crate).unwrap()) }).collect::<CargoResult<Vec<String>>>(); le...
let new = prev.lines().map(|line| { let mut git_crate = try!(json::decode::<Crate>(line).map_err(|_| { internal(format!("couldn't decode: `{}`", line)) }));
random_line_split
git.rs
use std::collections::HashMap; use std::env; use std::fs::{self, File}; use std::io::prelude::*; use std::path::{Path, PathBuf}; use semver; use git2; use rustc_serialize::json; use app::App; use dependency::Kind; use util::{CargoResult, internal}; #[derive(RustcEncodable, RustcDecodable)] pub struct Crate { pub...
dst.clone())) }) } pub fn yank(app: &App, krate: &str, version: &semver::Version, yanked: bool) -> CargoResult<()> { let repo = app.git_repo.lock().unwrap(); let repo = &*repo; let repo_path = repo.workdir().unwrap(); let dst = index_file(&repo_path, krate); commit_and...
{ let repo = app.git_repo.lock().unwrap(); let repo = &*repo; let repo_path = repo.workdir().unwrap(); let dst = index_file(&repo_path, &krate.name); commit_and_push(repo, || { // Add the crate to its relevant file try!(fs::create_dir_all(dst.parent().unwrap())); let mut pre...
identifier_body
oestexturefloatlinear.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 super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::r...
() -> WebGLExtensionSpec { WebGLExtensionSpec::All } fn is_supported(ext: &WebGLExtensions) -> bool { ext.supports_any_gl_extension(&["GL_OES_texture_float_linear", "GL_ARB_texture_float"]) } fn enable(ext: &WebGLExtensions) { ext.enable_filterable_tex_type(webgl::FLOAT); }...
spec
identifier_name
oestexturefloatlinear.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 super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::r...
fn name() -> &'static str { "OES_texture_float_linear" } }
{ ext.enable_filterable_tex_type(webgl::FLOAT); }
identifier_body
oestexturefloatlinear.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 super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::r...
ext.enable_filterable_tex_type(webgl::FLOAT); } fn name() -> &'static str { "OES_texture_float_linear" } }
ext.supports_any_gl_extension(&["GL_OES_texture_float_linear", "GL_ARB_texture_float"]) } fn enable(ext: &WebGLExtensions) {
random_line_split