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 |
|---|---|---|---|---|
lib.rs | // Copyright 2014 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | //! `GlDevice::with_gl` method. It is also used internally by the `GlDevice`
//! implementation.
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); | #![feature(phase)]
//! An OpenGL loader generated by [gl-rs](https://github.com/bjz/gl-rs).
//!
//! This is useful for directly accessing the underlying OpenGL API via the | random_line_split |
smallints.rs | // Copyright 2014-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.
//! A data structure for a sequence of small integers with a few big integers.
//! Small ints are stored in type S ... | else {
self.bigints.get(&i).cloned()
}
}
}
/// Iterator over the elements of a `SmallInts` sequence.
pub struct Iter<'a, S, B>
where
S: Integer + Bounded + NumCast + Copy,
B: Integer + NumCast + Copy,
<S as Num>::FromStrRadixErr: 'a,
<B as Num>::FromStrRadixErr: 'a,
{
smalli... |
cast(v)
} | conditional_block |
smallints.rs | // Copyright 2014-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.
//! A data structure for a sequence of small integers with a few big integers.
//! Small ints are stored in type S ... |
impl<'a, S, B> Iterator for Iter<'a, S, B>
where
S: 'a + Integer + Bounded + NumCast + Copy,
B: 'a + Integer + NumCast + Copy,
<S as Num>::FromStrRadixErr: 'a,
<B as Num>::FromStrRadixErr: 'a,
{
type Item = B;
fn next(&mut self) -> Option<B> {
match self.items.next() {
Some... | {
smallints: &'a SmallInts<S, B>,
items: Enumerate<slice::Iter<'a, S>>,
} | random_line_split |
smallints.rs | // Copyright 2014-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.
//! A data structure for a sequence of small integers with a few big integers.
//! Small ints are stored in type S ... | &self) -> bool {
self.smallints.is_empty()
}
fn real_value(&self, i: usize, v: S) -> Option<B> {
if v < S::max_value() {
cast(v)
} else {
self.bigints.get(&i).cloned()
}
}
}
/// Iterator over the elements of a `SmallInts` sequence.
pub struct Iter<'a... | s_empty( | identifier_name |
webdriver_handlers.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::conversions::FromJSValConvertible;
use dom::bindings::conversions::StringificationBehavior;
use... | None => Err(())
}).unwrap();
} | random_line_split | |
webdriver_handlers.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::conversions::FromJSValConvertible;
use dom::bindings::conversions::StringificationBehavior;
use... | (page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Temporary<Node>> {
let page = get_page(&*page, pipeline);
let document = page.document().root();
let node = NodeCast::from_ref(document.r());
for candidate in node.traverse_preorder() {
if candidate.root().r().get_unique_id() ==... | find_node_by_unique_id | identifier_name |
webdriver_handlers.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::conversions::FromJSValConvertible;
use dom::bindings::conversions::StringificationBehavior;
use... |
pub fn handle_find_elements_css(page: &Rc<Page>, _pipeline: PipelineId, selector: String,
reply: Sender<Result<Vec<String>, ()>>) {
reply.send(match page.document().root().r().QuerySelectorAll(selector.clone()) {
Ok(ref node_list) => {
let nodes = node_list.root... | {
reply.send(match page.document().root().r().QuerySelector(selector.clone()) {
Ok(node) => {
let result = node.map(|x| NodeCast::from_ref(x.root().r()).get_unique_id());
Ok(result)
}
Err(_) => Err(())
}).unwrap();
} | identifier_body |
jit.rs | //!
//! This module manages verifying the generated LLVM module, optimizing it using the LLVM
//! optimization passes, and compiling it to machine code.
use libc;
use llvm_sys;
use time;
use std::ffi::{CStr, CString};
use std::mem;
use std::ptr;
use std::sync::{Once, ONCE_INIT};
use libc::c_char;
use self::time::Pr... | else {
for global in globals {
LLVMAddGlobalMapping(engine, global.0, global.1);
}
Ok(engine)
}
}
/// Get a pointer to a named function in an execution engine.
unsafe fn find_function(engine: LLVMExecutionEngineRef, name: &str) -> WeldResult<I64Func> {
let c_name = CString:... | {
compile_err!(
"Creating execution engine failed: {}",
CStr::from_ptr(error_str).to_str().unwrap()
)
} | conditional_block |
jit.rs | //!
//! This module manages verifying the generated LLVM module, optimizing it using the LLVM
//! optimization passes, and compiling it to machine code.
use libc;
use llvm_sys;
use time;
use std::ffi::{CStr, CString};
use std::mem;
use std::ptr;
use std::sync::{Once, ONCE_INIT};
use libc::c_char;
use self::time::Pr... | (
context: LLVMContextRef,
module: LLVMModuleRef,
mappings: &[intrinsic::Mapping],
conf: &ParsedConf,
stats: &mut CompilationStats,
) -> WeldResult<CompiledModule> {
init();
let start = PreciseTime::now();
verify_module(module)?;
let end = PreciseTime::now();
stats
.llvm_... | compile | identifier_name |
jit.rs | //!
//! This module manages verifying the generated LLVM module, optimizing it using the LLVM
//! optimization passes, and compiling it to machine code.
use libc;
use llvm_sys;
use time;
use std::ffi::{CStr, CString};
use std::mem;
use std::ptr;
use std::sync::{Once, ONCE_INIT};
use libc::c_char;
use self::time::Pr... | let options_size = mem::size_of::<LLVMMCJITCompilerOptions>();
LLVMInitializeMCJITCompilerOptions(&mut options, options_size);
options.OptLevel = conf.llvm.opt_level;
options.CodeModel = LLVMCodeModel::LLVMCodeModelDefault;
let result_code = LLVMCreateMCJITCompilerForModule(
&mut engine,
... | {
// Create a filtered list of globals. Needs to be done before creating the execution engine
// since we lose ownership of the module. (?)
let mut globals = vec![];
for mapping in mappings.iter() {
let global = LLVMGetNamedFunction(module, mapping.0.as_ptr());
// The LLVM optimizer can ... | identifier_body |
jit.rs | //!
//! This module manages verifying the generated LLVM module, optimizing it using the LLVM
//! optimization passes, and compiling it to machine code.
use libc;
use llvm_sys;
use time;
use std::ffi::{CStr, CString};
use std::mem;
use std::ptr;
use std::sync::{Once, ONCE_INIT};
use libc::c_char;
use self::time::Pr... | if conf.llvm.llvm_unroller { 0 } else { 1 },
);
LLVMExtPassManagerBuilderSetDisableVectorize(
builder,
if conf.llvm.llvm_vectorizer { 0 } else { 1 },
);
// 250 should correspond to OptLevel = 3
LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 250);
if conf.llvm.fun... | LLVMPassManagerBuilderSetDisableUnrollLoops(
builder, | random_line_split |
sequential.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/. */
//! Implements sequential traversal over the DOM tree.
#![deny(missing_docs)]
use context::TraversalStatistics;
... | <E, D>(traversal: &D,
root: E,
token: PreTraverseToken)
where E: TElement,
D: DomTraversal<E>,
{
let dump_stats = TraversalStatistics::should_dump();
let start_time = if dump_stats { Some(time::precise_time_s()) } else { None };
debug_assert... | traverse_dom | identifier_name |
sequential.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/. */
//! Implements sequential traversal over the DOM tree.
#![deny(missing_docs)]
use context::TraversalStatistics;
... | debug_assert!(token.should_traverse());
fn doit<E, D>(traversal: &D, traversal_data: &mut PerLevelTraversalData,
thread_local: &mut D::ThreadLocalContext, node: E::ConcreteNode)
where E: TElement,
D: DomTraversal<E>
{
traversal.process_preorder(traversal_data... | let start_time = if dump_stats { Some(time::precise_time_s()) } else { None };
debug_assert!(!traversal.is_parallel()); | random_line_split |
sequential.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/. */
//! Implements sequential traversal over the DOM tree.
#![deny(missing_docs)]
use context::TraversalStatistics;
... | ;
debug_assert!(!traversal.is_parallel());
debug_assert!(token.should_traverse());
fn doit<E, D>(traversal: &D, traversal_data: &mut PerLevelTraversalData,
thread_local: &mut D::ThreadLocalContext, node: E::ConcreteNode)
where E: TElement,
D: DomTraversal<E>
{
... | { None } | conditional_block |
sequential.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/. */
//! Implements sequential traversal over the DOM tree.
#![deny(missing_docs)]
use context::TraversalStatistics;
... | });
if let Some(ref mut depth) = traversal_data.current_dom_depth {
*depth -= 1;
}
}
if D::needs_postorder_traversal() {
traversal.process_postorder(thread_local, node);
}
}
let mut traversal_data = PerLevelTraversalData ... | {
let dump_stats = TraversalStatistics::should_dump();
let start_time = if dump_stats { Some(time::precise_time_s()) } else { None };
debug_assert!(!traversal.is_parallel());
debug_assert!(token.should_traverse());
fn doit<E, D>(traversal: &D, traversal_data: &mut PerLevelTraversalData,
... | identifier_body |
table_caption.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/. */
//! CSS table formatting contexts.
use app_units::Au;
use crate::block::BlockFlow;
use crate::context::LayoutCont... | self.block_flow
.update_late_computed_block_position_if_necessary(block_position)
}
fn build_display_list(&mut self, state: &mut DisplayListBuildState) {
debug!("build_display_list_table_caption: same process as block flow");
self.block_flow.build_display_list(state);
}
... | random_line_split | |
table_caption.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/. */
//! CSS table formatting contexts.
use app_units::Au;
use crate::block::BlockFlow;
use crate::context::LayoutCont... | (fragment: Fragment) -> TableCaptionFlow {
TableCaptionFlow {
block_flow: BlockFlow::from_fragment(fragment),
}
}
}
impl Flow for TableCaptionFlow {
fn class(&self) -> FlowClass {
FlowClass::TableCaption
}
fn as_mut_table_caption(&mut self) -> &mut TableCaptionFlow ... | from_fragment | identifier_name |
sts.rs | #![cfg(feature = "sts")]
extern crate rusoto_core;
extern crate rusoto_sts;
use rusoto_core::default_tls_client;
use rusoto_sts::{Sts, StsClient};
use rusoto_sts::{AssumeRoleRequest, AssumeRoleError};
use rusoto_sts::{GetSessionTokenRequest, GetSessionTokenError};
use rusoto_sts::StsSessionCredentialsProvider;
use ru... | () {
let credentials = DefaultCredentialsProvider::new().unwrap();
let sts = StsClient::new(default_tls_client().unwrap(), credentials, Region::UsEast1);
// http://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html
match sts.assume_role(&AssumeRoleRequest{
role_arn: "bogus".to_owned(... | main | identifier_name |
sts.rs | #![cfg(feature = "sts")]
extern crate rusoto_core;
extern crate rusoto_sts;
use rusoto_core::default_tls_client;
use rusoto_sts::{Sts, StsClient};
use rusoto_sts::{AssumeRoleRequest, AssumeRoleError};
use rusoto_sts::{GetSessionTokenRequest, GetSessionTokenError};
use rusoto_sts::StsSessionCredentialsProvider;
use ru... | serial_number: Some("123456789".to_owned()),
..Default::default()
}) {
Err(GetSessionTokenError::Unknown(msg)) =>
assert!(msg.contains("Please verify your MFA serial number is valid and associated with this user.")),
err =>
panic!("this should have... | {
let credentials = DefaultCredentialsProvider::new().unwrap();
let sts = StsClient::new(default_tls_client().unwrap(), credentials, Region::UsEast1);
// http://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html
match sts.assume_role(&AssumeRoleRequest{
role_arn: "bogus".to_owned(),
... | identifier_body |
sts.rs | #![cfg(feature = "sts")]
extern crate rusoto_core;
extern crate rusoto_sts;
use rusoto_core::default_tls_client;
use rusoto_sts::{Sts, StsClient};
use rusoto_sts::{AssumeRoleRequest, AssumeRoleError};
use rusoto_sts::{GetSessionTokenRequest, GetSessionTokenError};
use rusoto_sts::StsSessionCredentialsProvider;
use ru... | err =>
panic!("this should have been an Unknown STS Error: {:?}", err)
}
match sts.get_session_token(
&GetSessionTokenRequest {
token_code: Some("123456".to_owned()),
serial_number: Some("123456789".to_owned()),
..Default::default()
}) {
... | role_session_name: "rusoto_test_session".to_owned(),
..Default::default()
}) {
Err(AssumeRoleError::Unknown(msg)) =>
assert!(msg.contains("validation error detected: Value 'bogus' at 'roleArn' failed to satisfy constraint")), | random_line_split |
dao_manager.rs | use crate::{DBPlatform, Dao, DataError, DbError, Rows, Value};
/// an interface executing sql statement and getting the results as generic DAO values
/// without any further conversion.
pub struct DaoManager(pub DBPlatform);
impl DaoManager {
pub fn begin_transaction(&mut self) -> Result<(), DbError> {
se... |
pub fn execute_sql_with_one_return(
&mut self,
sql: &str,
params: &[&Value],
) -> Result<Dao, DbError> {
let record: Result<Option<Dao>, DbError> =
self.execute_sql_with_maybe_one_return(sql, params);
match record {
Ok(record) => match record {
... | {
let rows = self.0.execute_sql_with_return(sql, params)?;
let daos: Vec<Dao> = rows.iter().collect();
Ok(daos)
} | identifier_body |
dao_manager.rs | use crate::{DBPlatform, Dao, DataError, DbError, Rows, Value};
/// an interface executing sql statement and getting the results as generic DAO values
/// without any further conversion.
pub struct DaoManager(pub DBPlatform);
impl DaoManager {
pub fn begin_transaction(&mut self) -> Result<(), DbError> {
se... | (
&mut self,
sql: &str,
params: &[&Value],
) -> Result<Rows, DbError> {
let rows = self.0.execute_sql_with_return(sql, params)?;
Ok(rows)
}
pub fn execute_sql_with_records_return(
&mut self,
sql: &str,
params: &[&Value],
) -> Result<Vec<Da... | execute_sql_with_return | identifier_name |
dao_manager.rs | use crate::{DBPlatform, Dao, DataError, DbError, Rows, Value};
/// an interface executing sql statement and getting the results as generic DAO values
/// without any further conversion.
pub struct DaoManager(pub DBPlatform);
impl DaoManager {
pub fn begin_transaction(&mut self) -> Result<(), DbError> {
se... | pub fn commit_transaction(&mut self) -> Result<(), DbError> {
self.0.commit_transaction()
}
pub fn rollback_transaction(&mut self) -> Result<(), DbError> {
self.0.rollback_transaction()
}
pub fn execute_sql_with_return(
&mut self,
sql: &str,
params: &[&Value... | }
| random_line_split |
mbe.rs | //! This module implements declarative macros: old `macro_rules` and the newer
//! `macro`. Declarative macros are also known as "macro by example", and that's
//! why we call this module `mbe`. For external documentation, prefer the
//! official terminology: "declarative macros".
crate mod macro_check;
crate mod macr... | (kind: TokenKind, span: Span) -> TokenTree {
TokenTree::Token(Token::new(kind, span))
}
}
| token | identifier_name |
mbe.rs | //! This module implements declarative macros: old `macro_rules` and the newer
//! `macro`. Declarative macros are also known as "macro by example", and that's
//! why we call this module `mbe`. For external documentation, prefer the
//! official terminology: "declarative macros".
crate mod macro_check;
crate mod macr... |
impl TokenTree {
/// Return the number of tokens in the tree.
fn len(&self) -> usize {
match *self {
TokenTree::Delimited(_, ref delimed) => match delimed.delim {
token::NoDelim => delimed.tts.len(),
_ => delimed.tts.len() + 2,
},
Toke... | MetaVar(Span, Ident),
/// e.g., `$var:expr`. This is only used in the left hand side of MBE macros.
MetaVarDecl(Span, Ident /* name to bind */, Option<NonterminalKind>),
} | random_line_split |
mbe.rs | //! This module implements declarative macros: old `macro_rules` and the newer
//! `macro`. Declarative macros are also known as "macro by example", and that's
//! why we call this module `mbe`. For external documentation, prefer the
//! official terminology: "declarative macros".
crate mod macro_check;
crate mod macr... |
}
| {
TokenTree::Token(Token::new(kind, span))
} | identifier_body |
explicit-self.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
a: int
}
fn thing(x: A) -> thing {
thing {
x: x
}
}
impl thing {
pub fn bar(~self) -> int { self.x.a }
pub fn quux(&self) -> int { self.x.a }
pub fn baz<'a>(&'a self) -> &'a A { &self.x }
pub fn spam(self) -> int { self.x.a }
}
trait Nus { fn f(&self); }
impl Nus for thing { fn... | A | identifier_name |
explicit-self.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
impl shape {
// self is in the implicit self region
pub fn select<'r, T>(&self, threshold: f64, a: &'r T, b: &'r T)
-> &'r T {
if compute_area(self) > threshold {a} else {b}
}
}
fn select_based_on_unit_circle<'r, T>(
threshold: f64, a: &'r T, b: &'r T) -> &'r T {
... | rectangle(_, ref size) => size.w * size.h
}
} | random_line_split |
delta.rs | //! Add a delta to a weave file.
use regex::Regex;
use std::{
collections::BTreeMap,
fs::{remove_file, rename},
io::{self, BufRead, BufReader, BufWriter, Write},
mem::replace,
path::PathBuf,
process::{Command, Stdio},
};
use crate::{header::Header, Entry, Error, NamingConvention, Parser, PullP... | }
impl<W: Write> Sink for RevWriter<W> {
fn plain(&mut self, text: &str, keep: bool) -> Result<()> {
if!keep {
return Ok(());
}
writeln!(&mut self.dest, "{}", text)?;
Ok(())
}
}
/// The weave writer writes out the contents of a weave to a file.
struct WeaveWriter<W... | }
}
struct RevWriter<W: Write> {
dest: BufWriter<W>, | random_line_split |
delta.rs | //! Add a delta to a weave file.
use regex::Regex;
use std::{
collections::BTreeMap,
fs::{remove_file, rename},
io::{self, BufRead, BufReader, BufWriter, Write},
mem::replace,
path::PathBuf,
process::{Command, Stdio},
};
use crate::{header::Header, Entry, Error, NamingConvention, Parser, PullP... |
}
struct RevWriter<W: Write> {
dest: BufWriter<W>,
}
impl<W: Write> Sink for RevWriter<W> {
fn plain(&mut self, text: &str, keep: bool) -> Result<()> {
if!keep {
return Ok(());
}
writeln!(&mut self.dest, "{}", text)?;
Ok(())
}
}
/// The weave writer writes ou... | {
self.temp
.as_mut()
.expect("Attempt to flush DeltaWriter that is closed")
.writer
.flush()
} | identifier_body |
delta.rs | //! Add a delta to a weave file.
use regex::Regex;
use std::{
collections::BTreeMap,
fs::{remove_file, rename},
io::{self, BufRead, BufReader, BufWriter, Write},
mem::replace,
path::PathBuf,
process::{Command, Stdio},
};
use crate::{header::Header, Entry, Error, NamingConvention, Parser, PullP... | (mut self) -> Result<()> {
// Close the temporary file, getting its name.
let temp = replace(&mut self.temp, None);
let temp_name = match temp {
Some(mut wi) => {
wi.writer.flush()?;
drop(wi.writer);
wi.name
}
No... | close | identifier_name |
password.rs | use std::{fmt, io::Write};
use bcrypt::{hash, verify};
use diesel::{backend::Backend, deserialize, serialize, sql_types::Text};
use failure::Fail;
use log::error;
#[cfg(any(test, feature = "test"))]
use log::warn;
use serde::de::{Deserialize, Deserializer};
/// Create a trait used to verify passwords.
///
/// This tr... |
})
}
}
impl Create for Password {
fn create(password: PlaintextPassword) -> Result<Password, CreationError> {
#[cfg(any(test, feature = "test"))]
warn!("BUILT IN TEST MODE");
#[cfg(not(any(test, feature = "test")))]
let h = hash(&password.0, bcrypt::DEFAULT_COST);
... | {
Err(VerificationError::Password)
} | conditional_block |
password.rs | use std::{fmt, io::Write};
use bcrypt::{hash, verify};
use diesel::{backend::Backend, deserialize, serialize, sql_types::Text};
use failure::Fail;
use log::error;
#[cfg(any(test, feature = "test"))]
use log::warn;
use serde::de::{Deserialize, Deserializer};
/// Create a trait used to verify passwords.
///
/// This tr... | /// Currently, this means the password is too short, or two submitted passwords do not match.
#[fail(display = "Error validating password")]
Validation(#[cause] ValidationError),
/// This should only happen in very rare circumstances, since generally bcrypt is good about not
/// having errors.
#... | /// This happens when a password does not meet the requirements to be considered usable. | random_line_split |
password.rs | use std::{fmt, io::Write};
use bcrypt::{hash, verify};
use diesel::{backend::Backend, deserialize, serialize, sql_types::Text};
use failure::Fail;
use log::error;
#[cfg(any(test, feature = "test"))]
use log::warn;
use serde::de::{Deserialize, Deserializer};
/// Create a trait used to verify passwords.
///
/// This tr... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "********")
}
}
impl fmt::Display for Password {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "********")
}
}
impl Verify for Password {
fn verify(&self, given_password: PlaintextPassword) -> Result<(), Veri... | fmt | identifier_name |
mod.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | }
for sub in pt.nodes().iter() {
Builder::walk_mutate(&mut builder, cx, sub);
}
let base_node = pt.get_by_path("mcu").and_then(|mcu|{mcu.get_by_path("clock")});
match base_node {
Some(node) => Builder::walk_materialize(&mut builder, cx, node),
None => {
cx.parse_sess().sp... | {
let mut builder = Builder::new(pt.clone());
if !pt.expect_subnodes(cx, &["mcu", "os", "drivers"]) {
return None;
}
match pt.get_by_path("mcu") {
Some(node) => mcu::attach(&mut builder, cx, node),
None => (), // TODO(farcaller): should it actaully fail?
}
match pt.get_by_p... | identifier_body |
mod.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | {
main_stmts: Vec<P<ast::Stmt>>,
type_items: Vec<P<ast::Item>>,
pt: Rc<node::PlatformTree>,
}
impl Builder {
pub fn build(cx: &mut ExtCtxt, pt: Rc<node::PlatformTree>) -> Option<Builder> {
let mut builder = Builder::new(pt.clone());
if!pt.expect_subnodes(cx, &["mcu", "os", "drivers"]) {
return ... | Builder | identifier_name |
mod.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... |
match pt.get_by_path("mcu") {
Some(node) => mcu::attach(&mut builder, cx, node),
None => (), // TODO(farcaller): should it actaully fail?
}
match pt.get_by_path("os") {
Some(node) => os::attach(&mut builder, cx, node),
None => (), // TODO(farcaller): this should fail.
}
... | random_line_split | |
bytecode.rs | #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct StrID(pub usize);
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct ChunkID(pub usize);
/// A chunk of bytecode, pairing instructions with metadata.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Chunk {
/// The bytecode instructions to be... | /// Pop elements of the stack, create a new tuple with those elements, and
/// push the new tuple onto the stack.
NewTuple(usize),
/// Push a new integer onto the stack.
NewI32(i32),
/// Push a new string onto the stack.
NewStr(StrID),
/// Pop free variables off the stack, create a new function with ... |
/// Push a local variable onto the stack.
GetLocal(usize),
| random_line_split |
bytecode.rs | #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct | (pub usize);
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct ChunkID(pub usize);
/// A chunk of bytecode, pairing instructions with metadata.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Chunk {
/// The bytecode instructions to be executed, starting at the first one.
pub insts: Vec<Inst>,
//... | StrID | identifier_name |
usmodel.rs | endogenous ewma epinfma zcapf rkf kf pkf cf invef yf labf wf rrf mc zcap rk k pk c inve y lab pinf w r a b g
qs ms spinf sw kpf kp
endogenous labobs robs pinfobs dy dc dinve dw
exogenous ea eb eg eqs em epinf ew
parameters curvw cgy curvp constelab constepinf constebeta cmaw cmap calfa
czcap csadjcost c... | (csigl*lab + (1/(1-chabb/cgamma))*c - ((chabb/cgamma)/(1-chabb/cgamma))*c(-1) -w)
+ 1*sw ;
% Monetary policy reaction function
r = crpi*(1-crr)*pinf +cry*(1-crr)*(y-yf)+crdy*(y-yf-y(-1)+yf(-1))+crr*r(-1)+ms ;
a = crhoa*a(-1) + sig_a*ea; %
b = crhob*b(-1) + sig_b*eb... | random_line_split | |
colors.rs | #![feature(test)]
extern crate test;
extern crate ratel;
extern crate ratel_visitor;
use ratel_visitor::{Visitable, Visitor};
use test::{Bencher, black_box};
static SOURCE: &'static str = r#"
'use strict';
/**
* Extract red color out of a color integer:
*
* 0x00DEAD -> 0x00
*
* @param {Number} color
* @retu... | {
const mask = '#000000';
const hex = int.toString( 16 );
return mask.substring( 0, 7 - hex.length ) + hex;
}
/**
* Converts a hex string containing a color such as '#00DEAD' to
* an integer, such as 0x00DEAD;
*
* @param {Number} num
* @return {String}
*/
function hexToInt( hex )
{
return par... | * @param {Number} int
* @return {String}
*/
function intToHex( int ) | random_line_split |
colors.rs | #![feature(test)]
extern crate test;
extern crate ratel;
extern crate ratel_visitor;
use ratel_visitor::{Visitable, Visitor};
use test::{Bencher, black_box};
static SOURCE: &'static str = r#"
'use strict';
/**
* Extract red color out of a color integer:
*
* 0x00DEAD -> 0x00
*
* @param {Number} color
* @retu... | (b: &mut Bencher) {
let module = ratel::parse(SOURCE).expect("Must parse");
let arena = module.arena();
let offset = unsafe { arena.offset() };
b.iter(|| {
unsafe { arena.reset_to(offset) };
black_box(module.visit_with(&mut DummyStaticVisitor));
});
}
| empty_traverse | identifier_name |
colors.rs | #![feature(test)]
extern crate test;
extern crate ratel;
extern crate ratel_visitor;
use ratel_visitor::{Visitable, Visitor};
use test::{Bencher, black_box};
static SOURCE: &'static str = r#"
'use strict';
/**
* Extract red color out of a color integer:
*
* 0x00DEAD -> 0x00
*
* @param {Number} color
* @retu... | {
let module = ratel::parse(SOURCE).expect("Must parse");
let arena = module.arena();
let offset = unsafe { arena.offset() };
b.iter(|| {
unsafe { arena.reset_to(offset) };
black_box(module.visit_with(&mut DummyStaticVisitor));
});
} | identifier_body | |
intelligent_acceleration.rs | use super::Obstacle;
pub const COMFORTABLE_BREAKING_DECELERATION: f32 = 0.4;
pub fn | (
car: &Obstacle,
obstacle: &Obstacle,
safe_time_headway: f32,
) -> f32 {
// http://en.wikipedia.org/wiki/Intelligent_driver_model
let car_length = 4.0;
let acceleration = 0.4;
let max_deceleration: f32 = 5.0;
let desired_velocity = car.max_velocity;
let acceleration_exponent = 4.0;... | intelligent_acceleration | identifier_name |
intelligent_acceleration.rs | use super::Obstacle;
pub const COMFORTABLE_BREAKING_DECELERATION: f32 = 0.4;
pub fn intelligent_acceleration(
car: &Obstacle,
obstacle: &Obstacle,
safe_time_headway: f32,
) -> f32 | (-max_deceleration).max(
acceleration
* (1.0
- (car.velocity / desired_velocity).powf(acceleration_exponent)
- (s_star / net_distance).powf(2.0)),
)
}
| {
// http://en.wikipedia.org/wiki/Intelligent_driver_model
let car_length = 4.0;
let acceleration = 0.4;
let max_deceleration: f32 = 5.0;
let desired_velocity = car.max_velocity;
let acceleration_exponent = 4.0;
let minimum_spacing = 4.0;
let net_distance = *obstacle.position - *car.po... | identifier_body |
intelligent_acceleration.rs | use super::Obstacle;
pub const COMFORTABLE_BREAKING_DECELERATION: f32 = 0.4;
pub fn intelligent_acceleration(
car: &Obstacle,
obstacle: &Obstacle,
safe_time_headway: f32,
) -> f32 {
// http://en.wikipedia.org/wiki/Intelligent_driver_model
let car_length = 4.0;
let acceleration = 0.4;
let ... |
(-max_deceleration).max(
acceleration
* (1.0
- (car.velocity / desired_velocity).powf(acceleration_exponent)
- (s_star / net_distance).powf(2.0)),
)
} | / (2.0 * (acceleration * COMFORTABLE_BREAKING_DECELERATION).sqrt())),
); | random_line_split |
ptr.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
let q: *const isize = &2;
assert_eq!(q.as_ref().unwrap(), &2);
let p: *mut isize = null_mut();
assert_eq!(p.as_ref(), None);
let q: *mut isize = &mut 2;
assert_eq!(q.as_ref().unwrap(), &2);
// Lifetime inference
let u = 2isize;
{
le... | #[test]
fn test_as_ref() {
unsafe {
let p: *const isize = null();
assert_eq!(p.as_ref(), None); | random_line_split |
ptr.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let mut xs = [0u8; 20];
let ptr = xs.as_mut_ptr();
unsafe { write_bytes(ptr, 5u8, xs.len()); }
assert!(xs == [5u8; 20]);
}
#[test]
fn test_unsized_unique() {
let xs: &mut [i32] = &mut [1, 2, 3];
let ptr = unsafe { Unique::new(xs as *mut [i32]) };
let ys = unsafe { &mut **ptr };
let... | test_set_memory | identifier_name |
ptr.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let xs: &mut [i32] = &mut [1, 2, 3];
let ptr = unsafe { Unique::new(xs as *mut [i32]) };
let ys = unsafe { &mut **ptr };
let zs: &mut [i32] = &mut [1, 2, 3];
assert!(ys == zs);
} | identifier_body | |
htmltablesectionelement.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::HTMLTableSectionElementBinding;
use dom::bindings::codegen::InheritTypes::HT... | (localName: DOMString, document: &JSRef<Document>) -> HTMLTableSectionElement {
HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(HTMLTableSectionElementTypeId, localName, document)
}
}
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTab... | new_inherited | identifier_name |
htmltablesectionelement.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::HTMLTableSectionElementBinding;
use dom::bindings::codegen::InheritTypes::HT... |
}
| {
self.htmlelement.reflector()
} | identifier_body |
htmltablesectionelement.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::InheritTypes::HTMLTableSectionElementDerived;
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::Document;
use dom::element::HTMLTableSectionElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmleleme... | use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding; | random_line_split |
graph.rs | // -----------------------------------------------
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═══... | self.pretty = Some(pretty);
self
}
#[doc = "Specific routing value"]
pub fn routing(mut self, routing: &'b str) -> Self {
self.routing = Some(routing);
self
}
#[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST ... | sponse."]
pub fn pretty(mut self, pretty: bool) -> Self {
| identifier_body |
graph.rs | // -----------------------------------------------
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═══... | self.human = Some(human);
self
}
#[doc = "Pretty format the returned JSON response."]
pub fn pretty(mut self, pretty: bool) -> Self {
self.pretty = Some(pretty);
self
}
#[doc = "Specific routing value"]
pub fn routing(mut self, routing: &'b str) -> Self {
... | pub fn human(mut self, human: bool) -> Self { | random_line_split |
graph.rs | // -----------------------------------------------
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═══... | #[doc = "Pretty format the returned JSON response."]
pub fn pretty(mut self, pretty: bool) -> Self {
self.pretty = Some(pretty);
self
}
#[doc = "Specific routing value"]
pub fn routing(mut self, routing: &'b str) -> Self {
self.routing = Some(routing);
self
}
... | self
}
| identifier_name |
mod.rs | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::WINR {
#[doc = r" Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, ... | (&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
#[doc = "Bits 0:11 - Watchdog counter window value"]
#[inline(always)]
pub fn win(&mut self) -> _WINW {
_WINW { w: self }
}
}
| bits | identifier_name |
mod.rs | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::WINR {
#[doc = r" Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, ... | pub fn reset(&self) {
self.write(|w| w)
}
}
#[doc = r" Value of the field"]
pub struct WINR {
bits: u16,
}
impl WINR {
#[doc = r" Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u16 {
self.bits
}
}
#[doc = r" Proxy"]
pub struct _WINW<'a> {
w: &'a ... | }
#[doc = r" Writes the reset value to the register"]
#[inline(always)] | random_line_split |
mod.rs | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::WINR {
#[doc = r" Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, ... |
#[doc = r" Writes the reset value to the register"]
#[inline(always)]
pub fn reset(&self) {
self.write(|w| w)
}
}
#[doc = r" Value of the field"]
pub struct WINR {
bits: u16,
}
impl WINR {
#[doc = r" Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u16 {
... | {
let mut w = W::reset_value();
f(&mut w);
self.register.set(w.bits);
} | identifier_body |
enumeration.rs | use crate::model::builtin::BuiltinString;
use crate::model::symbol::Symbol;
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Enumeration {
pub name: Symbol,
pub members: Vec<Symbol>,
pub documentation: String,
pub default: Symbol,
/// There are enums that are handled specially bec... | {
pub name: Symbol,
pub type_: BuiltinString,
/// A language like Rust wouldn't need this, but in, e.g. C++, an enum cannot contain a value,
/// so the enum and the potential 'other' value need to be 'wrapped' together in some way.
pub wrapper_class_name: Symbol,
}
| OtherField | identifier_name |
enumeration.rs | use crate::model::builtin::BuiltinString;
use crate::model::symbol::Symbol;
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Enumeration {
pub name: Symbol, | /// enum behaves like a variant where some value can be held in a field that might be named, for
/// example `other`. For an example of an 'enum' like this, see the `Dynamics` element in
/// `musicxml.xsd`, which uses empty element choices for its enum values and an
/// `<other>whatever</other>` choice ... | pub members: Vec<Symbol>,
pub documentation: String,
pub default: Symbol,
/// There are enums that are handled specially because they were part of an element that allowed
/// for an "other" field that could hold a string. If `other_field.is_some()`, it means that the | random_line_split |
traits-negative-impls.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 ... |
// The dummy functions are used to avoid adding new cfail files.
// What happens is that the compiler attempts to squash duplicates and some
// errors are not reported. This way, we make sure that, for each function, different
// typeck phases are involved and all errors are reported.
#![feature(optin_builtin_traits)... | // except according to those terms. | random_line_split |
traits-negative-impls.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 ... | () {
struct TestType;
impl!Send for TestType {}
// This will complain about a missing Send impl because `Sync` is implement *just*
// for T that are `Send`. Look at #20366 and #19950
is_sync(Outer2(TestType));
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `main::Test... | main | identifier_name |
lib.rs | Captures, nlist: &mut Threads,
caps: &mut Captures, pc: uint) -> StepState {
$step_insts
StepContinue
}
fn add(&self, nlist: &mut Threads, pc: uint,
groups: &mut Captures) {
if nlist.contains(pc) {
return
}
... | arm_inst | identifier_name | |
lib.rs | .names.as_slice().iter(),
|cx, name| match *name {
Some(ref name) => {
let name = name.as_slice();
quote_expr!(cx, Some($name))
}
None => cx.expr_none(self.sp),
}
);
let prefix_anchor =
... | Submatches => $save,
Exists | Location => $add,
}
})
} else {
quote_expr!(self.cx, {
nlist.add_empty($pc);
... | random_line_split | |
lib.rs |
/// Generates specialized code for the Pike VM for a particular regular
/// expression.
///
/// There are two primary differences between the code generated here and the
/// general code in vm.rs.
///
/// 1. All heap allocation is removed. Sized vector types are used instead.
/// Care must be taken to make sure th... | {
reg.register_macro("regex", native);
} | identifier_body | |
group.rs | #![deny(warnings)]
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
extern crate mpi;
use mpi::traits::*;
use mpi::topology::{SystemGroup, GroupRelation, Rank};
fn | () {
let universe = mpi::initialize().unwrap();
let world = universe.world();
let g = world.group();
// Group accessors and Communicator accessors agree
assert_eq!(world.size(), g.size());
assert_eq!(world.rank(), g.rank().unwrap());
// g == g
assert_eq!(GroupRelation::Identical, g.com... | main | identifier_name |
group.rs | #![deny(warnings)]
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
extern crate mpi;
use mpi::traits::*;
use mpi::topology::{SystemGroup, GroupRelation, Rank};
fn main() {
let universe = mpi::initialize().unwrap();
let world = universe.world();
let g = world.group();
// Group ac... | // f intersection s == empty Group
let fs = f.intersection(&s);
assert_eq!(GroupRelation::Identical, empty.compare(&fs));
// rank is either in f or in s
assert!((f.rank().is_some() && s.rank().is_none())
^ (f.rank().is_none() && s.rank().is_some()));
// inverting rank mappings
... | let fs = f.union(&s);
assert_eq!(GroupRelation::Identical, g.compare(&fs));
| random_line_split |
group.rs | #![deny(warnings)]
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
extern crate mpi;
use mpi::traits::*;
use mpi::topology::{SystemGroup, GroupRelation, Rank};
fn main() | let empty = g.difference(&h);
// g difference h == g difference g = empty Group
assert_eq!(GroupRelation::Identical, SystemGroup::empty().compare(&empty));
assert_eq!(0, empty.size());
// g intersection empty == empty Group
assert_eq!(0, g.intersection(&empty).size());
let first_half: Vec<... | {
let universe = mpi::initialize().unwrap();
let world = universe.world();
let g = world.group();
// Group accessors and Communicator accessors agree
assert_eq!(world.size(), g.size());
assert_eq!(world.rank(), g.rank().unwrap());
// g == g
assert_eq!(GroupRelation::Identical, g.compar... | identifier_body |
brush.rs | use crate::prelude::*;
/// A `Brush` defines the fill pattern of shapes.
/// The syntax allows to express fill patterns in several ways:
///
/// * solid colors
/// * colors with alpha channel
/// * gradients of colors
/// * gradients with directions
/// * gradients with angles
///
/// The string declaration of a `Brus... |
}
impl From<Brush> for Color {
fn from(b: Brush) -> Color {
match b {
Brush::SolidColor(color) => color,
_ => Color::rgb(0, 0, 0),
}
}
}
impl From<Brush> for Gradient {
fn from(b: Brush) -> Gradient {
match b {
Brush::Gradient(g) => g,
... | {
match self {
Brush::SolidColor(color) => color.a() == 0,
_ => false,
}
} | identifier_body |
brush.rs | use crate::prelude::*;
/// A `Brush` defines the fill pattern of shapes.
/// The syntax allows to express fill patterns in several ways:
///
/// * solid colors
/// * colors with alpha channel
/// * gradients of colors
/// * gradients with directions
/// * gradients with angles
///
/// The string declaration of a `Brus... | ///
/// ## Definition of a color name
/// With the given implementation you can choose between three methods
/// to define a color.
///
/// A. `color codes`
///
/// You can define the value of a color with a symbol "#" followed
/// by letters or numbers. These numbers are in hexadecimal numeral system.
/// The short va... | /// .background("linear-gradient(to top right, white, skyblue 60%, lightskyblue 80%, yellow 83%, yellow)")
/// ```
/// Read on to see how the syntax is composed. | random_line_split |
brush.rs | use crate::prelude::*;
/// A `Brush` defines the fill pattern of shapes.
/// The syntax allows to express fill patterns in several ways:
///
/// * solid colors
/// * colors with alpha channel
/// * gradients of colors
/// * gradients with directions
/// * gradients with angles
///
/// The string declaration of a `Brus... | (g: Gradient) -> Brush {
Brush::Gradient(g)
}
}
impl From<&str> for Brush {
fn from(s: &str) -> Brush {
Expression::from(s).brush().unwrap_or_default()
}
}
impl From<String> for Brush {
fn from(s: String) -> Brush {
Self::from(&s[..])
}
}
impl From<Value> for Brush {
f... | from | identifier_name |
cabi_arm.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | } else if size <= 2 {
Type::i16(ccx)
} else {
Type::i32(ccx)
};
return ArgType::direct(ty, Some(llty), None, None);
}
ArgType::indirect(ty, Some(StructRetAttribute))
}
fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
if is_reg_ty(ty) {
... | Type::i8(ccx) | random_line_split |
cabi_arm.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | ty_align(elt)
}
_ => fail!("ty_align: unhandled type")
}
}
fn ty_size(ty: Type) -> uint {
match ty.kind() {
Integer => {
unsafe {
((llvm::LLVMGetIntTypeWidth(ty.to_ref()) as uint) + 7) / 8
}
}
Pointer => 4,
Flo... | {
match ty.kind() {
Integer => {
unsafe {
((llvm::LLVMGetIntTypeWidth(ty.to_ref()) as uint) + 7) / 8
}
}
Pointer => 4,
Float => 4,
Double => 8,
Struct => {
if ty.is_packed() {
1
} else {
... | identifier_body |
cabi_arm.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (off: uint, ty: Type) -> uint {
let a = ty_align(ty);
return align_up_to(off, a);
}
fn ty_align(ty: Type) -> uint {
match ty.kind() {
Integer => {
unsafe {
((llvm::LLVMGetIntTypeWidth(ty.to_ref()) as uint) + 7) / 8
}
}
Pointer => 4,
Fl... | align | identifier_name |
cabi_arm.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | else {
ArgType::direct(Type::void(ccx), None, None, None)
};
return FnType {
arg_tys: arg_tys,
ret_ty: ret_ty,
};
}
| {
classify_ret_ty(ccx, rty)
} | conditional_block |
htmlfontelement.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::attr::{Attr, AttrValue};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTMLF... | (&self) -> Option<RGBA> {
self.color.get()
}
#[allow(unsafe_code)]
pub fn get_face(&self) -> Option<Atom> {
let face = unsafe { self.face.borrow_for_layout() };
match *face {
Some(ref s) => Some(s.clone()),
None => None,
}
}
}
| get_color | identifier_name |
htmlfontelement.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::attr::{Attr, AttrValue};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTMLF... | }
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
match name {
&atom!("face") => AttrValue::from_atomic(value),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
}
impl HTMLFontElement {
pub fn get_color(&self... | random_line_split | |
htmlfontelement.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::attr::{Attr, AttrValue};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTMLF... |
}
impl HTMLFontElement {
pub fn get_color(&self) -> Option<RGBA> {
self.color.get()
}
#[allow(unsafe_code)]
pub fn get_face(&self) -> Option<Atom> {
let face = unsafe { self.face.borrow_for_layout() };
match *face {
Some(ref s) => Some(s.clone()),
None... | {
match name {
&atom!("face") => AttrValue::from_atomic(value),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
} | identifier_body |
distance.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/. */
//! Machinery to compute distances between animatable values.
use app_units::Au;
use euclid::Size2D;
use std::ite... | (self, rhs: Self) -> Self {
SquaredDistance { value: self.value + rhs.value }
}
}
impl Sum for SquaredDistance {
fn sum<I>(iter: I) -> Self
where
I: Iterator<Item = Self>,
{
iter.fold(SquaredDistance::from_sqrt(0.), Add::add)
}
}
| add | identifier_name |
distance.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/. */
//! Machinery to compute distances between animatable values.
use app_units::Au;
use euclid::Size2D;
use std::ite... | #[inline]
fn add(self, rhs: Self) -> Self {
SquaredDistance { value: self.value + rhs.value }
}
}
impl Sum for SquaredDistance {
fn sum<I>(iter: I) -> Self
where
I: Iterator<Item = Self>,
{
iter.fold(SquaredDistance::from_sqrt(0.), Add::add)
}
} | random_line_split | |
phantom.rs | use std::marker::PhantomData;
// A phantom tuple struct which is generic over A with hidden parameter B.
#[derive(PartialEq)] // Allow equality test for this type
struct PhantomTuple<A, B>(A,PhantomData<B>);
// A phantom type struct which is generic over A with hidden parameter B.
#[derive(PartialEq)] // Allow equali... | () {
// Here, `f32` and `f64`
// PhantomTuple type specified as <char, f32>
let _tuple1: PhantomTuple<char, f32> = PhantomTuple('Q', PhantomData);
// PhantomTuple type specified as <char, f64>
let _tuple2: PhantomTuple<char, f64> = PhantomTuple('Q', PhantomData);
// Type specified as <char, f32... | main | identifier_name |
phantom.rs | use std::marker::PhantomData;
// A phantom tuple struct which is generic over A with hidden parameter B.
#[derive(PartialEq)] // Allow equality test for this type
struct PhantomTuple<A, B>(A,PhantomData<B>);
// A phantom type struct which is generic over A with hidden parameter B.
#[derive(PartialEq)] // Allow equali... | fn main() {
// Here, `f32` and `f64`
// PhantomTuple type specified as <char, f32>
let _tuple1: PhantomTuple<char, f32> = PhantomTuple('Q', PhantomData);
// PhantomTuple type specified as <char, f64>
let _tuple2: PhantomTuple<char, f64> = PhantomTuple('Q', PhantomData);
// Type specified as <ch... | random_line_split | |
error-festival.rs | enum Question {
Yes,
No,
}
mod foo {
const FOO: u32 = 0;
}
fn main() { | //~^ ERROR E0368
y = 2;
//~^ ERROR E0425
x.z();
//~^ ERROR E0599
!Question::Yes;
//~^ ERROR E0600
foo::FOO;
//~^ ERROR E0603
0u32 as char;
//~^ ERROR E0604
let x = 0u8;
x as Vec<u8>;
//~^ ERROR E0605
let x = 5;
let x_is_nonzero = x as bool;
//~^ ER... | let x = "a";
x += 2; | random_line_split |
error-festival.rs | enum | {
Yes,
No,
}
mod foo {
const FOO: u32 = 0;
}
fn main() {
let x = "a";
x += 2;
//~^ ERROR E0368
y = 2;
//~^ ERROR E0425
x.z();
//~^ ERROR E0599
!Question::Yes;
//~^ ERROR E0600
foo::FOO;
//~^ ERROR E0603
0u32 as char;
//~^ ERROR E0604
let x = 0u8;... | Question | identifier_name |
trait-safety-fn-body.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 ... |
}
unsafe impl UnsafeTrait for *mut isize {
fn foo(self) {
// Unsafe actions are not made legal by taking place in an unsafe trait:
*self += 1; //~ ERROR E0133
}
}
fn main() { }
| { } | identifier_body |
trait-safety-fn-body.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 ... | (self) {
// Unsafe actions are not made legal by taking place in an unsafe trait:
*self += 1; //~ ERROR E0133
}
}
fn main() { }
| foo | identifier_name |
trait-safety-fn-body.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 ... |
unsafe trait UnsafeTrait : Sized {
fn foo(self) { }
}
unsafe impl UnsafeTrait for *mut isize {
fn foo(self) {
// Unsafe actions are not made legal by taking place in an unsafe trait:
*self += 1; //~ ERROR E0133
}
}
fn main() { } | // Check that an unsafe impl does not imply that unsafe actions are
// legal in the methods. | random_line_split |
datetimeformat.rs | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | impl From<&str> for TimeZone {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl Default for TimeZone {
fn default() -> Self {
Self("UTC".to_string())
}
}
/// The hour cycle to use
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum... | #[derive(Eq, PartialEq, Debug, Clone)]
pub struct TimeZone(pub String);
| random_line_split |
datetimeformat.rs | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | (s: &str) -> Self {
Self(s.to_string())
}
}
/// The way day periods (morning, afternoon) should be expressed.
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum DayPeriod {
/// "AM", "PM"
Narrow,
/// "A.M.", "P.M".
Short,
/// "Morning", "Afternoo... | from | identifier_name |
datetimeformat.rs | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
}
/// The way day periods (morning, afternoon) should be expressed.
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum DayPeriod {
/// "AM", "PM"
Narrow,
/// "A.M.", "P.M".
Short,
/// "Morning", "Afternoon".
Long,
}
/// Controls the number formatti... | {
Self(s.to_string())
} | identifier_body |
i686_wrs_vxworks.rs | use crate::spec::{LinkerFlavor, StackProbeType, Target};
pub fn target() -> Target {
let mut base = super::vxworks_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = Some(64);
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
// don't use probe... | options: base,
}
} | f64:32:64-f80:32-n8:16:32-S128"
.to_string(),
arch: "x86".to_string(), | random_line_split |
i686_wrs_vxworks.rs | use crate::spec::{LinkerFlavor, StackProbeType, Target};
pub fn target() -> Target | {
let mut base = super::vxworks_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = Some(64);
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
base.stack_probes... | identifier_body | |
i686_wrs_vxworks.rs | use crate::spec::{LinkerFlavor, StackProbeType, Target};
pub fn | () -> Target {
let mut base = super::vxworks_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = Some(64);
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
base... | target | identifier_name |
core.rs |
use std::sync::Mutex;
use std::sync::mpsc::{sync_channel, SyncSender, Receiver};
use std::thread;
use std::path::Path;
use env_logger;
use iron::prelude::*;
use router::Router;
use server::routes::{get_value,set_value,ping};
use db::worker::WorkerPool;
use core::db::DB;
use core::query::{Query, run_query};
pub fn | () {
env_logger::init().unwrap();
let (in_ch, out_ch) : (SyncSender<Box<Query>>, Receiver<Box<Query>>) = sync_channel(20);
let path = Path::new("composedb_data");
let db = DB::new(path);
let num_workers = 3;
let worker_queue_size = 2;
let run_query = move |q: Box<Query>| run_query(q, db.... | run | identifier_name |
core.rs | use std::sync::Mutex;
use std::sync::mpsc::{sync_channel, SyncSender, Receiver};
use std::thread;
use std::path::Path;
|
use server::routes::{get_value,set_value,ping};
use db::worker::WorkerPool;
use core::db::DB;
use core::query::{Query, run_query};
pub fn run() {
env_logger::init().unwrap();
let (in_ch, out_ch) : (SyncSender<Box<Query>>, Receiver<Box<Query>>) = sync_channel(20);
let path = Path::new("composedb_data");... | use env_logger;
use iron::prelude::*;
use router::Router; | random_line_split |
core.rs |
use std::sync::Mutex;
use std::sync::mpsc::{sync_channel, SyncSender, Receiver};
use std::thread;
use std::path::Path;
use env_logger;
use iron::prelude::*;
use router::Router;
use server::routes::{get_value,set_value,ping};
use db::worker::WorkerPool;
use core::db::DB;
use core::query::{Query, run_query};
pub fn ... | let mut router = Router::new();
let in_ch_2 = Mutex::new(in_ch.clone());
let in_ch_3 = Mutex::new(in_ch.clone());
router.get("/json", move |r: &mut Request| get_value( r, &in_ch_2 ));
router.post("/json/set", move |r: &mut Request| set_value( r, &in_ch_3 ));
router.get("/ping", move |r: &mut R... | {
env_logger::init().unwrap();
let (in_ch, out_ch) : (SyncSender<Box<Query>>, Receiver<Box<Query>>) = sync_channel(20);
let path = Path::new("composedb_data");
let db = DB::new(path);
let num_workers = 3;
let worker_queue_size = 2;
let run_query = move |q: Box<Query>| run_query(q, db.clo... | identifier_body |
config.rs | use std::{fmt, os, mem};
use std::cell::{RefCell, RefMut};
use std::collections::hash_map::{HashMap};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::io;
use std::io::fs::{self, PathExtensions, File};
use std::string;
use rustc_serialize::{Encodable,Encoder};
use toml;
use core::MultiShell;
use ops... |
loop {
let possible = current.join(".cargo").join("config");
if possible.exists() {
let file = try!(File::open(&possible));
match walk(file) {
Ok(res) => return Ok(res),
_ => ()
}
}
if!current.pop() { break; }
... | where F: FnMut(File) -> CargoResult<T>
{
let mut current = pwd.clone(); | random_line_split |
config.rs | use std::{fmt, os, mem};
use std::cell::{RefCell, RefMut};
use std::collections::hash_map::{HashMap};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::io;
use std::io::fs::{self, PathExtensions, File};
use std::string;
use rustc_serialize::{Encodable,Encoder};
use toml;
use core::MultiShell;
use ops... |
pub fn registry_source_path(&self) -> Path {
self.home_path.join("registry").join("src")
}
pub fn shell(&self) -> RefMut<&'a mut MultiShell> {
self.shell.borrow_mut()
}
pub fn jobs(&self) -> u32 {
self.jobs
}
pub fn target(&self) -> Option<&str> {
self.ta... | {
self.home_path.join("registry").join("cache")
} | identifier_body |
config.rs | use std::{fmt, os, mem};
use std::cell::{RefCell, RefMut};
use std::collections::hash_map::{HashMap};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::io;
use std::io::fs::{self, PathExtensions, File};
use std::string;
use rustc_serialize::{Encodable,Encoder};
use toml;
use core::MultiShell;
use ops... | (&self) -> &Path { &self.home_path }
pub fn git_db_path(&self) -> Path {
self.home_path.join("git").join("db")
}
pub fn git_checkout_path(&self) -> Path {
self.home_path.join("git").join("checkouts")
}
pub fn registry_index_path(&self) -> Path {
self.home_path.join("regist... | home | identifier_name |
config.rs | use std::{fmt, os, mem};
use std::cell::{RefCell, RefMut};
use std::collections::hash_map::{HashMap};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::io;
use std::io::fs::{self, PathExtensions, File};
use std::string;
use rustc_serialize::{Encodable,Encoder};
use toml;
use core::MultiShell;
use ops... |
let (rustc_version, rustc_host) = try!(ops::rustc_version());
Ok(Config {
home_path: try!(homedir().chain_error(|| {
human("Cargo couldn't find your home directory. \
This probably means that $HOME was not set.")
})),
shell: Re... | {
return Err(human("jobs must be at least 1"))
} | conditional_block |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.