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 |
|---|---|---|---|---|
offsets.rs | use byteorder::{BigEndian, ReadBytesExt};
use futures::Stream;
use rdkafka::config::{ClientConfig, TopicConfig};
use rdkafka::consumer::stream_consumer::StreamConsumer;
use rdkafka::consumer::{Consumer, EmptyConsumerContext};
use rdkafka::error::KafkaError;
use rdkafka::{Message, Offset, TopicPartitionList};
use cache... |
fn consume_offset_topic(
cluster_id: ClusterId,
consumer: StreamConsumer<EmptyConsumerContext>,
cache: &Cache,
) -> Result<()> {
let mut local_cache = HashMap::new();
let mut last_dump = Instant::now();
debug!("Starting offset consumer loop for {:?}", cluster_id);
for message in consumer... | {
let tp_elements = tp_list.elements_for_topic("__consumer_offsets");
let mut offsets = vec![0; tp_elements.len()];
for tp in &tp_elements {
offsets[tp.partition() as usize] = tp.offset().to_raw();
}
offsets
} | identifier_body |
movmskpd.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn | () {
run_test(&Instruction { mnemonic: Mnemonic::MOVMSKPD, operand1: Some(Direct(ESP)), operand2: Some(Direct(XMM1)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 80, 225], OperandSize::Dword)
}
fn movmskpd_2() {
run_t... | movmskpd_1 | identifier_name |
movmskpd.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn movmskpd_1() {
run_test(&Instruction { mnemonic: Mnemonic::MOVMSKPD, operand1: Some(Direct(ESP)), operand2: Some(Direct... | } | random_line_split | |
movmskpd.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
fn movmskpd_1() |
fn movmskpd_2() {
run_test(&Instruction { mnemonic: Mnemonic::MOVMSKPD, operand1: Some(Direct(RDX)), operand2: Some(Direct(XMM1)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 80, 209], OperandSize::Qword)
}
| {
run_test(&Instruction { mnemonic: Mnemonic::MOVMSKPD, operand1: Some(Direct(ESP)), operand2: Some(Direct(XMM1)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 80, 225], OperandSize::Dword)
} | identifier_body |
cssrule.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
use crate::dom::bindings::inheritance... | lse {
unreachable!()
}
}
// Given a StyleCssRule, create a new instance of a derived class of
// CSSRule based on which rule it is
pub fn new_specific(
window: &Window,
parent_stylesheet: &CSSStyleSheet,
rule: StyleCssRule,
) -> DomRoot<CSSRule> {
... | rule as &dyn SpecificCSSRule
} e | conditional_block |
cssrule.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
use crate::dom::bindings::inheritance... | // https://drafts.csswg.org/cssom/#dom-cssrule-csstext
fn CssText(&self) -> DOMString {
self.as_specific().get_css()
}
// https://drafts.csswg.org/cssom/#dom-cssrule-csstext
fn SetCssText(&self, _: DOMString) {
// do nothing
}
}
pub trait SpecificCSSRule {
fn ty(&self) -> u... | if self.parent_stylesheet_removed.get() {
None
} else {
Some(DomRoot::from_ref(&*self.parent_stylesheet))
}
}
| identifier_body |
cssrule.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
use crate::dom::bindings::inheritance... | self) -> &dyn SpecificCSSRule {
if let Some(rule) = self.downcast::<CSSStyleRule>() {
rule as &dyn SpecificCSSRule
} else if let Some(rule) = self.downcast::<CSSFontFaceRule>() {
rule as &dyn SpecificCSSRule
} else if let Some(rule) = self.downcast::<CSSKeyframesRule>() {... | _specific(& | identifier_name |
cssrule.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
use crate::dom::bindings::inheritance... | // CSSRule based on which rule it is
pub fn new_specific(
window: &Window,
parent_stylesheet: &CSSStyleSheet,
rule: StyleCssRule,
) -> DomRoot<CSSRule> {
// be sure to update the match in as_specific when this is updated
match rule {
StyleCssRule::Import(s... | // Given a StyleCssRule, create a new instance of a derived class of | random_line_split |
stream_blob00.rs | #![cfg(all(test, feature = "test_e2e"))]
use azure_sdk_core::prelude::*;
use azure_sdk_core::{range::Range, DeleteSnapshotsMethod};
use azure_sdk_storage_blob::prelude::*;
use azure_sdk_storage_core::prelude::*;
use futures::stream::StreamExt;
#[tokio::test]
async fn create_blob_and_stream_back() {
code().await.un... | println!("{}/{} blob deleted!", container_name, file_name);
Ok(())
} | .finalize()
.await?;
| random_line_split |
stream_blob00.rs | #![cfg(all(test, feature = "test_e2e"))]
use azure_sdk_core::prelude::*;
use azure_sdk_core::{range::Range, DeleteSnapshotsMethod};
use azure_sdk_storage_blob::prelude::*;
use azure_sdk_storage_core::prelude::*;
use futures::stream::StreamExt;
#[tokio::test]
async fn create_blob_and_stream_back() |
async fn code() -> Result<(), Box<dyn std::error::Error>> {
let container_name = "azuresdkforrust";
let file_name = "azure_sdk_for_rust_stream_test.txt";
// First we retrieve the account name and master key from environment variables.
let account =
std::env::var("STORAGE_ACCOUNT").expect("Set... | {
code().await.unwrap();
} | identifier_body |
stream_blob00.rs | #![cfg(all(test, feature = "test_e2e"))]
use azure_sdk_core::prelude::*;
use azure_sdk_core::{range::Range, DeleteSnapshotsMethod};
use azure_sdk_storage_blob::prelude::*;
use azure_sdk_storage_core::prelude::*;
use futures::stream::StreamExt;
#[tokio::test]
async fn create_blob_and_stream_back() {
code().await.un... | () -> Result<(), Box<dyn std::error::Error>> {
let container_name = "azuresdkforrust";
let file_name = "azure_sdk_for_rust_stream_test.txt";
// First we retrieve the account name and master key from environment variables.
let account =
std::env::var("STORAGE_ACCOUNT").expect("Set env variable S... | code | identifier_name |
stream_blob00.rs | #![cfg(all(test, feature = "test_e2e"))]
use azure_sdk_core::prelude::*;
use azure_sdk_core::{range::Range, DeleteSnapshotsMethod};
use azure_sdk_storage_blob::prelude::*;
use azure_sdk_storage_core::prelude::*;
use futures::stream::StreamExt;
#[tokio::test]
async fn create_blob_and_stream_back() {
code().await.un... |
let string = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
client
.put_block_blob()
... | {
client
.create_container()
.with_container_name(container_name)
.with_public_access(PublicAccess::Blob)
.finalize()
.await?;
} | conditional_block |
fsm.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::mailbox::BasicMailbox;
use std::borrow::Cow;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::{ptr, usize};
// The FSM is notified.
const NOTIFYSTATE_NOTIFIED: usize = 0;
// The FSM is idle.
const NOTIFYSTATE_IDLE: usize ... |
let p = self.data.swap(ptr::null_mut(), Ordering::AcqRel);
if!p.is_null() {
Some(unsafe { Box::from_raw(p) })
} else {
panic!("inconsistent status and data, something should be wrong.");
}
}
/// Notify fsm via a `FsmScheduler`.
#[inline]
pub fn ... | {
return None;
} | conditional_block |
fsm.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::mailbox::BasicMailbox;
use std::borrow::Cow;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::{ptr, usize};
// The FSM is notified.
const NOTIFYSTATE_NOTIFIED: usize = 0;
// The FSM is idle.
const NOTIFYSTATE_IDLE: usize ... | (&self) {
match self.status.swap(NOTIFYSTATE_DROP, Ordering::AcqRel) {
NOTIFYSTATE_NOTIFIED | NOTIFYSTATE_DROP => return,
_ => {}
}
let ptr = self.data.swap(ptr::null_mut(), Ordering::SeqCst);
if!ptr.is_null() {
unsafe {
Box::from_raw(... | clear | identifier_name |
fsm.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::mailbox::BasicMailbox;
use std::borrow::Cow;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::{ptr, usize};
// The FSM is notified.
const NOTIFYSTATE_NOTIFIED: usize = 0;
// The FSM is idle.
const NOTIFYSTATE_IDLE: usize ... |
fn get_priority(&self) -> Priority {
Priority::Normal
}
}
pub struct FsmState<N> {
status: AtomicUsize,
data: AtomicPtr<N>,
}
impl<N: Fsm> FsmState<N> {
pub fn new(data: Box<N>) -> FsmState<N> {
FsmState {
status: AtomicUsize::new(NOTIFYSTATE_IDLE),
data: ... | {
None
} | identifier_body |
fsm.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use crate::mailbox::BasicMailbox;
use std::borrow::Cow;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::{ptr, usize};
// The FSM is notified.
const NOTIFYSTATE_NOTIFIED: usize = 0;
// The FSM is idle.
const NOTIFYSTATE_IDLE: usize ... | #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Priority {
Low,
Normal,
}
/// `FsmScheduler` schedules `Fsm` for later handles.
pub trait FsmScheduler {
type Fsm: Fsm;
/// Schedule a Fsm for later handles.
fn schedule(&self, fsm: Box<Self::Fsm>);
/// Shutdown the scheduler, which indicat... | // The FSM is expected to be dropped.
const NOTIFYSTATE_DROP: usize = 2;
| random_line_split |
htmlsourceelement.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 | use dom::bindings::inheritance::Castable;
use dom::bindings::root::DomRoot;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
#[dom_st... | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLSourceElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; | random_line_split |
htmlsourceelement.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::HTMLSourceElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding:... | (&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
/// <https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted>
fn bind_to_tree(&self, tree_in_doc: bool) {
self.super_type().unwrap().bind_to_tree(tree_in_doc);
let pare... | super_type | identifier_name |
htmlsourceelement.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::HTMLSourceElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding:... |
}
}
| {
media.handle_source_child_insertion();
} | conditional_block |
htmlsourceelement.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::HTMLSourceElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding:... |
}
impl VirtualMethods for HTMLSourceElement {
fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
/// <https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted>
fn bind_to_tree(&self, tree_in_doc: bool) {
self.... | {
Node::reflect_node(Box::new(HTMLSourceElement::new_inherited(local_name, prefix, document)),
document,
HTMLSourceElementBinding::Wrap)
} | identifier_body |
problem4.rs | fn is_palindrome(num: i64) -> bool {
let num_str = num.to_string();
let chars_to_check = num_str.len()/2;
let mut iter = num_str.as_bytes().iter().take(chars_to_check);
let mut rev_iter = num_str.as_bytes().iter().rev().take(chars_to_check);
// HACK: In future rust versions, this can probably be rep... | assert_eq!(is_palindrome(10), false);
assert_eq!(is_palindrome(11), true);
assert_eq!(is_palindrome(12), false);
assert_eq!(is_palindrome(22), true);
assert_eq!(is_palindrome(33), true);
assert_eq!(is_palindrome(333), true);
assert_eq!(is_palindrome(131), true);
... |
#[test]
fn tests() {
assert_eq!(is_palindrome(0), true);
assert_eq!(is_palindrome(1), true); | random_line_split |
problem4.rs | fn is_palindrome(num: i64) -> bool {
let num_str = num.to_string();
let chars_to_check = num_str.len()/2;
let mut iter = num_str.as_bytes().iter().take(chars_to_check);
let mut rev_iter = num_str.as_bytes().iter().rev().take(chars_to_check);
// HACK: In future rust versions, this can probably be rep... |
}
| {
assert_eq!(is_palindrome(0), true);
assert_eq!(is_palindrome(1), true);
assert_eq!(is_palindrome(10), false);
assert_eq!(is_palindrome(11), true);
assert_eq!(is_palindrome(12), false);
assert_eq!(is_palindrome(22), true);
assert_eq!(is_palindrome(33), true);
... | identifier_body |
problem4.rs | fn is_palindrome(num: i64) -> bool {
let num_str = num.to_string();
let chars_to_check = num_str.len()/2;
let mut iter = num_str.as_bytes().iter().take(chars_to_check);
let mut rev_iter = num_str.as_bytes().iter().rev().take(chars_to_check);
// HACK: In future rust versions, this can probably be rep... | (max_digits: u32) -> i64 {
let mut highest_found = 0;
for a in 1..10i64.pow(max_digits) {
for b in 1..10i64.pow(max_digits) {
let prod = a*b;
if prod > highest_found && is_palindrome(prod) {
highest_found = prod
}
}
}
return highest_fou... | largest_palindrome_product | identifier_name |
oestexturehalffloat.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::OESTextureHalfFloatBinding::{self, OESTextureHalfFloatConstants};
use dom::b... |
}
fn name() -> &'static str {
"OES_texture_half_float"
}
}
| {
// Special internal formats must be used to avoid clamped float values
ext.add_effective_tex_internal_format(webgl::RGBA, hf, gl::RGBA16F);
ext.add_effective_tex_internal_format(webgl::RGB, hf, gl::RGB16F);
ext.add_effective_tex_internal_format(webgl::LUMINANCE, hf, gl:... | conditional_block |
oestexturehalffloat.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::OESTextureHalfFloatBinding::{self, OESTextureHalfFloatConstants};
use dom::b... | }
}
}
impl WebGLExtension for OESTextureHalfFloat {
type Extension = OESTextureHalfFloat;
fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloat> {
reflect_dom_object(Box::new(OESTextureHalfFloat::new_inherited()),
&*ctx.global(),
... | random_line_split | |
oestexturehalffloat.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::OESTextureHalfFloatBinding::{self, OESTextureHalfFloatConstants};
use dom::b... |
fn is_supported(ext: &WebGLExtensions) -> bool {
ext.supports_any_gl_extension(&["GL_OES_texture_half_float",
"GL_ARB_half_float_pixel",
"GL_NV_half_float",
"GL_EXT_color_buffer_half_flo... | {
reflect_dom_object(Box::new(OESTextureHalfFloat::new_inherited()),
&*ctx.global(),
OESTextureHalfFloatBinding::Wrap)
} | identifier_body |
oestexturehalffloat.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::OESTextureHalfFloatBinding::{self, OESTextureHalfFloatConstants};
use dom::b... | (ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloat> {
reflect_dom_object(Box::new(OESTextureHalfFloat::new_inherited()),
&*ctx.global(),
OESTextureHalfFloatBinding::Wrap)
}
fn is_supported(ext: &WebGLExtensions) -> bool {
ext.suppo... | new | identifier_name |
deriving-eq-ord-boxed-slice.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 ... | struct Foo(Box<[u8]>);
pub fn main() {
let a = Foo(Box::new([0, 1, 2]));
let b = Foo(Box::new([0, 1, 2]));
assert_eq!(a, b);
println!("{}", a!= b);
println!("{}", a < b);
println!("{}", a <= b);
println!("{}", a == b);
println!("{}", a > b);
println!("{}", a >= b);
} | // except according to those terms.
// run-pass
#[derive(PartialEq, PartialOrd, Eq, Ord, Debug)] | random_line_split |
deriving-eq-ord-boxed-slice.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 ... | () {
let a = Foo(Box::new([0, 1, 2]));
let b = Foo(Box::new([0, 1, 2]));
assert_eq!(a, b);
println!("{}", a!= b);
println!("{}", a < b);
println!("{}", a <= b);
println!("{}", a == b);
println!("{}", a > b);
println!("{}", a >= b);
}
| main | identifier_name |
deriving-eq-ord-boxed-slice.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 ... | {
let a = Foo(Box::new([0, 1, 2]));
let b = Foo(Box::new([0, 1, 2]));
assert_eq!(a, b);
println!("{}", a != b);
println!("{}", a < b);
println!("{}", a <= b);
println!("{}", a == b);
println!("{}", a > b);
println!("{}", a >= b);
} | identifier_body | |
request.rs | //! The module that contains the request code.
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
use std::io::Error;
use std::str;
use std::sync::mpsc::channel;
use std::time::Duration;
use Method;
use curl::easy::{Easy, List};
use futures::{BoxFuture, failed, Future};
use response::Response;
use tokio... | (mut self, max_redirects: u32) -> Self {
self.max_redirects = max_redirects;
self
}
/// Adds a URL parameter to the request.
pub fn param(mut self, name: &str, value: &str) -> Self {
self.params.push((name.to_owned(), value.to_owned()));
self
}
/// Sets the given re... | max_redirects | identifier_name |
request.rs | //! The module that contains the request code.
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
use std::io::Error;
use std::str;
use std::sync::mpsc::channel;
use std::time::Duration;
use Method;
use curl::easy::{Easy, List};
use futures::{BoxFuture, failed, Future};
use response::Response;
use tokio... | else {
Ok(())
})
.and_then(|_| easy.url(url.as_str()))
.and_then(|_| easy.write_function(move |data| {
let _ = body_tx.send(Vec::from(data));
Ok(data.len())
}))
};
match config_res... | {
easy.timeout(timeout)
} | conditional_block |
request.rs | //! The module that contains the request code.
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
use std::io::Error;
use std::str;
use std::sync::mpsc::channel;
use std::time::Duration;
use Method;
use curl::easy::{Easy, List};
use futures::{BoxFuture, failed, Future};
use response::Response;
use tokio... |
/// Sets the thresholds which, when reached, aborts a download due to too
/// low speeds.
///
/// Pass 0 for either parameter to disable lowspeed limiting.
///
/// ## Remarks
/// `bytes` sets the minimum average amount of bytes transferred in `per_duration`
/// time. If this number is ... | {
self.set_json(serde_json::to_vec(body).unwrap())
} | identifier_body |
request.rs | //! The module that contains the request code.
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
use std::io::Error;
use std::str;
use std::sync::mpsc::channel;
use std::time::Duration;
use Method;
use curl::easy::{Easy, List};
use futures::{BoxFuture, failed, Future};
use response::Response;
use tokio... | .and_then(|_| if follow_redirects {
easy.follow_location(true)
.and_then(|_| easy.max_redirections(max_redirects))
} else {
Ok(())
})
.and_then(|_| easy.header_function(move |header| {
... | .and_then(|_| easy.custom_request(method.as_ref())) | random_line_split |
rc_slice.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (vec: Vec<T>) -> Self {
RcSlice {
offset: 0,
len: vec.len() as u32,
data: Rc::new(vec.into_boxed_slice()),
}
}
}
impl<T> Deref for RcSlice<T> {
type Target = [T];
fn deref(&self) -> &[T] {
&self.data[self.offset as usize.. (self.offset + self.len)... | new | identifier_name |
rc_slice.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut CTX,
hasher: &mut StableHasher<W>) {
(**self).hash_stable(hcx, hasher);
}
} | }
}
impl<CTX, T> HashStable<CTX> for RcSlice<T>
where T: HashStable<CTX> | random_line_split |
rc_slice.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
impl<CTX, T> HashStable<CTX> for RcSlice<T>
where T: HashStable<CTX>
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut CTX,
hasher: &mut StableHasher<W>) {
(**self).hash_stable(hcx, hasher);
}
}
| {
fmt::Debug::fmt(self.deref(), f)
} | identifier_body |
regions-fn-subtyping.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 ... |
fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
// Here, x, y, and z are free. Other letters
// are bound. Note that the arrangement
// subtype::<T1>(of::<T2>()) will typecheck
// iff T1 <: T2.
subtype::< <'a>|&'a T|>(
of::< <'a>|&'a T|>());
subtype::< <'a>|&'a T|>(
... | { fail!(); } | identifier_body |
regions-fn-subtyping.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,T>() -> |T|:'a { fail!(); }
fn subtype<T>(x: |T|) { fail!(); }
fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
// Here, x, y, and z are free. Other letters
// are bound. Note that the arrangement
// subtype::<T1>(of::<T2>()) will typecheck
// iff T1 <: T2.
subtype::< <'a>|&'a T|>(
... | of | identifier_name |
regions-fn-subtyping.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 ... |
fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
// Here, x, y, and z are free. Other letters
// are bound. Note that the arrangement
// subtype::<T1>(of::<T2>()) will typecheck
// iff T1 <: T2.
subtype::< <'a>|&'a T|>(
of::< <'a>|&'a T|>());
subtype::< <'a>|&'a T|>(
... |
fn of<'a,T>() -> |T|:'a { fail!(); }
fn subtype<T>(x: |T|) { fail!(); } | random_line_split |
size.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/. */
//! Generic type for CSS properties that are composed by two dimensions.
use crate::parser::ParserContext;
use c... |
}
impl<L> ToCss for Size2D<L>
where
L: ToCss + PartialEq,
{
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
self.width.to_css(dest)?;
if self.height!= self.width {
dest.write_str(" ")?;
self.height.to_css(dest)?;
}
... | {
let first = parse_one(context, input)?;
let second = input
.try_parse(|i| parse_one(context, i))
.unwrap_or_else(|_| first.clone());
Ok(Self::new(first, second))
} | identifier_body |
size.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/. */
//! Generic type for CSS properties that are composed by two dimensions.
use crate::parser::ParserContext;
use c... |
Ok(())
}
}
impl<L: Zero> Zero for Size2D<L> {
fn zero() -> Self {
Self::new(L::zero(), L::zero())
}
fn is_zero(&self) -> bool {
self.width.is_zero() && self.height.is_zero()
}
}
| {
dest.write_str(" ")?;
self.height.to_css(dest)?;
} | conditional_block |
size.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/. */
//! Generic type for CSS properties that are composed by two dimensions.
use crate::parser::ParserContext;
use c... | () -> Self {
Self::new(L::zero(), L::zero())
}
fn is_zero(&self) -> bool {
self.width.is_zero() && self.height.is_zero()
}
}
| zero | identifier_name |
size.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/. */
//! Generic type for CSS properties that are composed by two dimensions.
use crate::parser::ParserContext;
use c... | Ok(Self::new(first, second))
}
}
impl<L> ToCss for Size2D<L>
where
L: ToCss + PartialEq,
{
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
self.width.to_css(dest)?;
if self.height!= self.width {
dest.write_str(" ")?;
... | {
let first = parse_one(context, input)?;
let second = input
.try_parse(|i| parse_one(context, i))
.unwrap_or_else(|_| first.clone()); | random_line_split |
iced_features.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
/// Gets the available features
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub struct IcedFeatures;
impl IcedFeatures {
/// `true` if the gas (AT&T) formatter is available
#[must_us... |
/// `true` if the instruction info code is available
#[must_use]
#[inline]
pub fn has_instruction_info() -> bool {
cfg!(feature = "instr_info")
}
}
| {
cfg!(all(feature = "encoder", feature = "op_code_info"))
} | identifier_body |
iced_features.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
/// Gets the available features
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub struct IcedFeatures;
impl IcedFeatures {
/// `true` if the gas (AT&T) formatter is available
#[must_us... | pub fn has_nasm() -> bool {
cfg!(feature = "nasm")
}
/// `true` if the fast formatter is available
#[must_use]
#[inline]
pub fn has_fast_fmt() -> bool {
cfg!(feature = "fast_fmt")
}
/// `true` if the decoder is available
#[must_use]
#[inline]
pub fn has_decoder() -> bool {
cfg!(feature = "decoder")
... | #[inline] | random_line_split |
iced_features.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
/// Gets the available features
#[allow(missing_copy_implementations)]
#[allow(missing_debug_implementations)]
pub struct IcedFeatures;
impl IcedFeatures {
/// `true` if the gas (AT&T) formatter is available
#[must_us... | () -> bool {
cfg!(all(feature = "encoder", feature = "op_code_info"))
}
/// `true` if the instruction info code is available
#[must_use]
#[inline]
pub fn has_instruction_info() -> bool {
cfg!(feature = "instr_info")
}
}
| has_op_code_info | identifier_name |
roman_numerals.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 ... | (cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
-> Box<MacResult +'static> {
static NUMERALS: &'static [(&'static str, uint)] = &[
("M", 1000), ("CM", 900), ("D", 500), ("CD", 400),
("C", 100), ("XC", 90), ("L", 50), ("XL", 40),
("X", 10), ("IX", 9), ("V", 5), ("IV", 4)... | expand_rn | identifier_name |
roman_numerals.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 ... | {
reg.register_macro("rn", expand_rn);
} | identifier_body | |
roman_numerals.rs | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// force-host
#![crate_type="dylib"]
#![feature(plugin_registrar)]
extern crate syntax... | // 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 | random_line_split | |
main.rs | use slog::{crit, o, Drain};
static POSSIBLE_BACKENDS: &[&str] = &[
#[cfg(feature = "winit")]
"--winit : Run anvil as a X11 or Wayland client using winit.",
#[cfg(feature = "udev")]
"--tty-udev : Run anvil as a tty udev client (requires root if without logind).",
#[cfg(feature = "x11")]
"--x11 :... | () {
// A logger facility, here we use the terminal here
let log = if std::env::var("ANVIL_MUTEX_LOG").is_ok() {
slog::Logger::root(std::sync::Mutex::new(slog_term::term_full().fuse()).fuse(), o!())
} else {
slog::Logger::root(
slog_async::Async::default(slog_term::term_full().fu... | main | identifier_name |
main.rs | use slog::{crit, o, Drain};
static POSSIBLE_BACKENDS: &[&str] = &[
#[cfg(feature = "winit")]
"--winit : Run anvil as a X11 or Wayland client using winit.",
#[cfg(feature = "udev")]
"--tty-udev : Run anvil as a tty udev client (requires root if without logind).",
#[cfg(feature = "x11")]
"--x11 :... | println!("\t{}", b);
}
}
}
} | None => {
println!("USAGE: anvil --backend");
println!();
println!("Possible backends are:");
for b in POSSIBLE_BACKENDS { | random_line_split |
main.rs | use slog::{crit, o, Drain};
static POSSIBLE_BACKENDS: &[&str] = &[
#[cfg(feature = "winit")]
"--winit : Run anvil as a X11 or Wayland client using winit.",
#[cfg(feature = "udev")]
"--tty-udev : Run anvil as a tty udev client (requires root if without logind).",
#[cfg(feature = "x11")]
"--x11 :... |
None => {
println!("USAGE: anvil --backend");
println!();
println!("Possible backends are:");
for b in POSSIBLE_BACKENDS {
println!("\t{}", b);
}
}
}
}
| {
crit!(log, "Unknown backend: {}", other);
} | conditional_block |
main.rs | use slog::{crit, o, Drain};
static POSSIBLE_BACKENDS: &[&str] = &[
#[cfg(feature = "winit")]
"--winit : Run anvil as a X11 or Wayland client using winit.",
#[cfg(feature = "udev")]
"--tty-udev : Run anvil as a tty udev client (requires root if without logind).",
#[cfg(feature = "x11")]
"--x11 :... | }
#[cfg(feature = "udev")]
Some("--tty-udev") => {
slog::info!(log, "Starting anvil on a tty using udev");
anvil::udev::run_udev(log);
}
#[cfg(feature = "x11")]
Some("--x11") => {
slog::info!(log, "Starting anvil with x11 backend");
... | {
// A logger facility, here we use the terminal here
let log = if std::env::var("ANVIL_MUTEX_LOG").is_ok() {
slog::Logger::root(std::sync::Mutex::new(slog_term::term_full().fuse()).fuse(), o!())
} else {
slog::Logger::root(
slog_async::Async::default(slog_term::term_full().fuse(... | identifier_body |
ulps_eq.rs | #[cfg(feature = "num-complex")]
use num_complex::Complex;
#[cfg(not(feature = "std"))]
use num_traits::float::FloatCore;
use std::{cell, mem};
use AbsDiffEq;
/// Equality comparisons between two numbers using both the absolute difference and ULPs
/// (Units in Last Place) based comparisons.
pub trait UlpsEq<Rhs = Sel... | (&self, other: &Complex<T>, epsilon: T::Epsilon, max_ulps: u32) -> bool {
T::ulps_eq(&self.re, &other.re, epsilon.clone(), max_ulps)
&& T::ulps_eq(&self.im, &other.im, epsilon.clone(), max_ulps)
}
}
| ulps_eq | identifier_name |
ulps_eq.rs | #[cfg(feature = "num-complex")]
use num_complex::Complex;
#[cfg(not(feature = "std"))]
use num_traits::float::FloatCore;
use std::{cell, mem};
use AbsDiffEq;
/// Equality comparisons between two numbers using both the absolute difference and ULPs
/// (Units in Last Place) based comparisons.
pub trait UlpsEq<Rhs = Sel... | }
#[inline]
fn ulps_eq(&self, other: &Complex<T>, epsilon: T::Epsilon, max_ulps: u32) -> bool {
T::ulps_eq(&self.re, &other.re, epsilon.clone(), max_ulps)
&& T::ulps_eq(&self.im, &other.im, epsilon.clone(), max_ulps)
}
} | T::default_max_ulps() | random_line_split |
ulps_eq.rs | #[cfg(feature = "num-complex")]
use num_complex::Complex;
#[cfg(not(feature = "std"))]
use num_traits::float::FloatCore;
use std::{cell, mem};
use AbsDiffEq;
/// Equality comparisons between two numbers using both the absolute difference and ULPs
/// (Units in Last Place) based comparisons.
pub trait UlpsEq<Rhs = Sel... |
#[inline]
fn ulps_eq(&self, other: &cell::Cell<T>, epsilon: T::Epsilon, max_ulps: u32) -> bool {
T::ulps_eq(&self.get(), &other.get(), epsilon, max_ulps)
}
}
impl<T: UlpsEq +?Sized> UlpsEq for cell::RefCell<T> {
#[inline]
fn default_max_ulps() -> u32 {
T::default_max_ulps()
}
... | {
T::default_max_ulps()
} | identifier_body |
basic_shape.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 handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that ... |
self.coordinates
.iter()
.zip(other.coordinates.iter())
.map(|(this, other)| {
let d1 = this.0.compute_squared_distance(&other.0)?;
let d2 = this.1.compute_squared_distance(&other.1)?;
Ok(d1 + d2)
})
.sum()
... | {
return Err(());
} | conditional_block |
basic_shape.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 handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that ... | }
impl<L> Default for ShapeRadius<L> {
#[inline]
fn default() -> Self {
ShapeRadius::ClosestSide
}
}
impl<L> Animate for Polygon<L>
where
L: Animate,
{
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
if self.fill!= other.fill {
return Err(())... | radius.to_css(dest)?;
}
dest.write_str(")")
} | random_line_split |
basic_shape.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 handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that ... | (&self, other: &Self) -> Result<SquaredDistance, ()> {
if self.fill!= other.fill {
return Err(());
}
if self.coordinates.len()!= other.coordinates.len() {
return Err(());
}
self.coordinates
.iter()
.zip(other.coordinates.iter())
... | compute_squared_distance | identifier_name |
dna.rs | // Copyright 2014-2015 Johannes Köster, Peer Aramillo Irizar.
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! Implementation of the DNA alphabet.
//!
//! # Example
//!
//! ```
//! use bio::alphabets;... |
use alphabets::Alphabet;
use utils::IntoTextIterator;
/// The DNA alphabet (uppercase and lowercase).
pub fn alphabet() -> Alphabet {
Alphabet::new(b"ACGTacgt")
}
/// The DNA alphabet including N (uppercase and lowercase).
pub fn n_alphabet() -> Alphabet {
Alphabet::new(b"ACGTNacgtn")
}
/// The IUPAC DNA... | //! assert!(!alphabet.is_word(b"ACGU"));
//! ``` | random_line_split |
dna.rs |
// Copyright 2014-2015 Johannes Köster, Peer Aramillo Irizar.
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! Implementation of the DNA alphabet.
//!
//! # Example
//!
//! ```
//! use bio::alphabets... | 'a, T: IntoTextIterator<'a>>(text: T) -> Vec<u8> where
T::IntoIter: DoubleEndedIterator {
text.into_iter().rev().map(|&a| complement(a)).collect()
}
| evcomp< | identifier_name |
dna.rs |
// Copyright 2014-2015 Johannes Köster, Peer Aramillo Irizar.
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! Implementation of the DNA alphabet.
//!
//! # Example
//!
//! ```
//! use bio::alphabets... |
/// The IUPAC DNA alphabet (uppercase and lowercase).
pub fn iupac_alphabet() -> Alphabet {
Alphabet::new(b"ACGTURYSWKMBDHVNacgturyswkmbdhvn")
}
lazy_static! {
static ref COMPLEMENT: Vec<u8> = {
let mut comp = Vec::new();
comp.resize(256, 0);
for (v, mut a) in comp.iter_mut().enumera... |
Alphabet::new(b"ACGTNacgtn")
}
| identifier_body |
regions-mock-trans.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 ... | extern crate libc;
use std::mem;
struct arena(());
struct Bcx<'a> {
fcx: &'a Fcx<'a>
}
struct Fcx<'a> {
arena: &'a arena,
ccx: &'a Ccx
}
struct Ccx {
x: int
}
fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> {
unsafe {
mem::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
as li... | // except according to those terms.
| random_line_split |
regions-mock-trans.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 ... | () {
let ccx = Ccx { x: 0 };
f(&ccx);
}
| main | identifier_name |
nqueens.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... | (n: usize) {
let mut space = FDSpace::empty();
let mut queens = vec![];
// 2 queens can't share the same line.
for _ in 0..n {
queens.push(Box::new(space.vstore.alloc(IntervalSet::new(1, n as i32))) as Var<VStore>);
}
for i in 0..n-1 {
for j in i + 1..n {
// 2 queens can't share the same diag... | nqueens | identifier_name |
nqueens.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... |
// Search step.
let mut search = one_solution_engine();
search.start(&space);
let (frozen_space, status) = search.enter(space);
let space = frozen_space.unfreeze();
// Print result.
match status {
Satisfiable => {
print!("{}-queens problem is satisfiable. The first solution is:\n[", n);
... | random_line_split | |
nqueens.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... | }
// 2 queens can't share the same column.
join_distinct(&mut space.vstore, &mut space.cstore, queens);
// space.cstore.alloc(Box::new(Distinct::new(queens)));
// Search step.
let mut search = one_solution_engine();
search.start(&space);
let (frozen_space, status) = search.enter(space);
let space = f... | {
let mut space = FDSpace::empty();
let mut queens = vec![];
// 2 queens can't share the same line.
for _ in 0..n {
queens.push(Box::new(space.vstore.alloc(IntervalSet::new(1, n as i32))) as Var<VStore>);
}
for i in 0..n-1 {
for j in i + 1..n {
// 2 queens can't share the same diagonal.
... | identifier_body |
nqueens.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// 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... |
Unsatisfiable => println!("{}-queens problem is unsatisfiable.", n),
EndOfSearch => println!("Search terminated or was interrupted."),
Unknown(_) => unreachable!(
"After the search step, the problem instance should be either satisfiable or unsatisfiable.")
}
} | {
print!("{}-queens problem is satisfiable. The first solution is:\n[", n);
for dom in space.vstore.iter() {
// At this stage, dom.lower() == dom.upper().
print!("{}, ", dom.lower());
}
println!("]");
} | conditional_block |
structural_match.rs | use crate::infer::{InferCtxt, TyCtxtInferExt};
use crate::traits::ObligationCause;
use crate::traits::{self, TraitEngine};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::lang_items::LangItem;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFo... |
ty::Array(..) | ty::Slice(_) | ty::Ref(..) | ty::Tuple(..) => {
// First check all contained types and then tell the caller to continue searching.
return ty.super_visit_with(self);
}
ty::Infer(_) | ty::Placeholder(_) | ty::Bound(..) => {
... | {
// These primitive types are always structural match.
//
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
return ControlFlow::CONTINUE;
} | conditional_block |
structural_match.rs | use crate::infer::{InferCtxt, TyCtxtInferExt};
use crate::traits::ObligationCause;
use crate::traits::{self, TraitEngine};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::lang_items::LangItem;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFo... | /// Note that this does *not* recursively check if the substructure of `adt_ty`
/// implements the traits.
fn type_marked_structural(
infcx: &InferCtxt<'_, 'tcx>,
adt_ty: Ty<'tcx>,
cause: ObligationCause<'tcx>,
) -> bool {
let mut fulfillment_cx = traits::FulfillmentContext::new();
// require `#[der... | /// `#[derive(PartialEq)]` and `#[derive(Eq)]`).
/// | random_line_split |
structural_match.rs | use crate::infer::{InferCtxt, TyCtxtInferExt};
use crate::traits::ObligationCause;
use crate::traits::{self, TraitEngine};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::lang_items::LangItem;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFo... | (&self, adt_ty: Ty<'tcx>) -> bool {
adt_ty.is_structural_eq_shallow(self.tcx())
}
}
impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
type BreakTy = NonStructuralMatchTy<'tcx>;
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
Some(self.tcx())
}
fn visit_ty(&mut s... | type_marked_structural | identifier_name |
test_client_full.rs | use std::mem;
use bip_util::bt::{self};
use bip_utracker::{TrackerClient, ClientRequest};
use bip_utracker::announce::{ClientState, AnnounceEvent};
use futures::stream::Stream;
use futures::{Future};
use {handshaker};
#[test]
#[allow(unused)]
fn | () {
let (sink, mut stream) = handshaker();
let server_addr = "127.0.0.1:3504".parse().unwrap();
let request_capacity = 10;
let mut client = TrackerClient::with_capacity("127.0.0.1:4504".parse().unwrap(), sink, request_capacity).unwrap();
for _ in 0..request_capacity {
cl... | positive_client_request_dropped | identifier_name |
test_client_full.rs | use std::mem;
use bip_util::bt::{self};
use bip_utracker::{TrackerClient, ClientRequest};
use bip_utracker::announce::{ClientState, AnnounceEvent};
use futures::stream::Stream;
use futures::{Future};
use {handshaker};
#[test]
#[allow(unused)]
fn positive_client_request_dropped() |
mem::drop(client);
let buffer = stream.collect().wait().unwrap();
assert_eq!(request_capacity, buffer.len());
} | {
let (sink, mut stream) = handshaker();
let server_addr = "127.0.0.1:3504".parse().unwrap();
let request_capacity = 10;
let mut client = TrackerClient::with_capacity("127.0.0.1:4504".parse().unwrap(), sink, request_capacity).unwrap();
for _ in 0..request_capacity {
clien... | identifier_body |
test_client_full.rs | use std::mem;
use bip_util::bt::{self};
use bip_utracker::{TrackerClient, ClientRequest};
use bip_utracker::announce::{ClientState, AnnounceEvent};
use futures::stream::Stream; | #[allow(unused)]
fn positive_client_request_dropped() {
let (sink, mut stream) = handshaker();
let server_addr = "127.0.0.1:3504".parse().unwrap();
let request_capacity = 10;
let mut client = TrackerClient::with_capacity("127.0.0.1:4504".parse().unwrap(), sink, request_capacity).unwrap();... | use futures::{Future};
use {handshaker};
#[test] | random_line_split |
mod.rs | mod batch;
mod interactive;
mod text;
use crate::command::JudgingCommand;
use crate::config::Config;
use crate::errors::{JudgeErrorKind, JudgeResult, TestSuiteResult};
use crate::terminal::{TermOut, WriteAnsi, WriteSpaces};
use crate::testsuite::{BatchCase, TestCase, TestCases};
use crate::util::std_unstable::AsMillis... |
pub(crate) fn accepts(
config: &Config,
problem: &str,
nth: usize,
mut stdin: impl BufRead,
mut stderr: impl TermOut,
) -> JudgeResult<()> {
let (cases, _) = config.testcase_loader().load_merging(problem)?;
match cases {
TestCases::Batch(cases) => {
let case = cases
... | {
let (cases, _) = config.testcase_loader().load_merging(problem)?;
match &cases {
TestCases::Batch(cases) => cases
.get(nth)
.map(BatchCase::input)
.ok_or_else(|| JudgeErrorKind::IndexOutOfBounds(cases.len(), nth).into()),
TestCases::Interactive(cases) if nth... | identifier_body |
mod.rs | mod batch;
mod interactive;
mod text;
use crate::command::JudgingCommand;
use crate::config::Config;
use crate::errors::{JudgeErrorKind, JudgeResult, TestSuiteResult};
use crate::terminal::{TermOut, WriteAnsi, WriteSpaces};
use crate::testsuite::{BatchCase, TestCase, TestCases};
use crate::util::std_unstable::AsMillis... | ),
TestCases::Interactive(cases) => judge_all(
stdout,
stderr,
jobs,
display_limit,
cases,
&solver,
interactive::judge,
),
}
}
pub(crate) struct JudgeParams<'a, O: TermOut, E: TermOut> {
pub stdout: O,
... | batch::judge, | random_line_split |
mod.rs | mod batch;
mod interactive;
mod text;
use crate::command::JudgingCommand;
use crate::config::Config;
use crate::errors::{JudgeErrorKind, JudgeResult, TestSuiteResult};
use crate::terminal::{TermOut, WriteAnsi, WriteSpaces};
use crate::testsuite::{BatchCase, TestCase, TestCases};
use crate::util::std_unstable::AsMillis... | else {
for (i, name, outcome) in outcomes {
writeln!(stdout)?;
outcome.print_title(&mut stdout, i + 1, num_cases, &name, None)?;
outcome.print_details(display_limit, &mut stdout)?;
}
stdout.flush()?;
Err(JudgeErrorKind::Tes... | {
for (i, name, outcome) in outcomes {
outcome.print_title(&mut stdout, i + 1, num_cases, &name, Some(name_max_width))?;
}
writeln!(
stdout,
"All of the {} passed.",
plural!(num_cases, "test", "tests")
)?;
... | conditional_block |
mod.rs | mod batch;
mod interactive;
mod text;
use crate::command::JudgingCommand;
use crate::config::Config;
use crate::errors::{JudgeErrorKind, JudgeResult, TestSuiteResult};
use crate::terminal::{TermOut, WriteAnsi, WriteSpaces};
use crate::testsuite::{BatchCase, TestCase, TestCases};
use crate::util::std_unstable::AsMillis... | (params: JudgeParams<impl TermOut, impl TermOut>) -> JudgeResult<()> {
fn judge_all<
C: TestCase,
O: Outcome + Send +'static,
F: Future<Item = O, Error = io::Error> + Send +'static,
>(
mut stdout: impl TermOut,
mut stderr: impl TermOut,
jobs: NonZeroUsize,
... | judge | identifier_name |
string_slice_runtime.rs | #[derive( Debug, PartialEq )]
pub struct Struct1< 'a >
{
pub string_slice_1 : &'a str,
}
impl< 'a > Struct1< 'a >
{
#[inline]
pub fn former() -> Struct1Former< 'a >
{ | Struct1Former
{
string_slice_1 : ::core::option::Option::None,
}
}
}
pub struct Struct1Former< 'a >
{
string_slice_1 : ::core::option::Option< &'a str >,
}
impl< 'a > Struct1Former< 'a >
{
#[inline]
pub fn form( mut self ) -> Struct1< 'a >
{
let string_slice_1 = if self.string_slice_1.... | random_line_split | |
string_slice_runtime.rs |
#[derive( Debug, PartialEq )]
pub struct Struct1< 'a >
{
pub string_slice_1 : &'a str,
}
impl< 'a > Struct1< 'a >
{
#[inline]
pub fn former() -> Struct1Former< 'a >
{
Struct1Former
{
string_slice_1 : ::core::option::Option::None,
}
}
}
pub struct Struct1Former< 'a >
{
string_slice_1 :... | ;
Struct1 { string_slice_1 }
}
#[inline]
pub fn string_slice_1< Src >( mut self, src : Src ) -> Self
where
Src : ::core::convert::Into< &'a str >,
{
debug_assert!( self.string_slice_1.is_none() );
self.string_slice_1 = ::core::option::Option::Some( src.into() );
self
}
}
//
include!( ... | {
let val : &'a str = ::core::default::Default::default();
val
} | conditional_block |
string_slice_runtime.rs |
#[derive( Debug, PartialEq )]
pub struct Struct1< 'a >
{
pub string_slice_1 : &'a str,
}
impl< 'a > Struct1< 'a >
{
#[inline]
pub fn former() -> Struct1Former< 'a >
{
Struct1Former
{
string_slice_1 : ::core::option::Option::None,
}
}
}
pub struct Struct1Former< 'a >
{
string_slice_1 :... |
}
//
include!( "./string_slice_only_test.rs" );
| {
debug_assert!( self.string_slice_1.is_none() );
self.string_slice_1 = ::core::option::Option::Some( src.into() );
self
} | identifier_body |
string_slice_runtime.rs |
#[derive( Debug, PartialEq )]
pub struct Struct1< 'a >
{
pub string_slice_1 : &'a str,
}
impl< 'a > Struct1< 'a >
{
#[inline]
pub fn former() -> Struct1Former< 'a >
{
Struct1Former
{
string_slice_1 : ::core::option::Option::None,
}
}
}
pub struct | < 'a >
{
string_slice_1 : ::core::option::Option< &'a str >,
}
impl< 'a > Struct1Former< 'a >
{
#[inline]
pub fn form( mut self ) -> Struct1< 'a >
{
let string_slice_1 = if self.string_slice_1.is_some()
{
self.string_slice_1.take().unwrap()
}
else
{
let val : &'a str = ::core::d... | Struct1Former | identifier_name |
strukt.rs | use {value,types,Value,Expression,ExpressionTrait,Type};
use std;
#[derive(Clone,Debug,PartialEq,Eq)]
pub struct Struct
{
fields: Vec<Value>,
}
impl Struct
{
pub fn new(fields: Vec<Value>) -> Self {
Struct {
fields: fields,
}
}
pub fn fields(&self) -> std::slice::Iter<Val... | (self) -> Expression {
Expression::Literal(self.into())
}
}
impl Into<value::Literal> for Struct {
fn into(self) -> value::Literal {
value::Literal::Struct(self)
}
}
| into | identifier_name |
strukt.rs | use {value,types,Value,Expression,ExpressionTrait,Type};
use std;
#[derive(Clone,Debug,PartialEq,Eq)]
pub struct Struct
{
fields: Vec<Value>,
}
impl Struct
{
pub fn new(fields: Vec<Value>) -> Self {
Struct {
fields: fields,
}
}
pub fn fields(&self) -> std::slice::Iter<Val... |
}
| {
value::Literal::Struct(self)
} | identifier_body |
strukt.rs | use {value,types,Value,Expression,ExpressionTrait,Type};
use std;
#[derive(Clone,Debug,PartialEq,Eq)]
pub struct Struct
{
fields: Vec<Value>,
}
impl Struct
{
pub fn new(fields: Vec<Value>) -> Self {
Struct {
fields: fields,
}
}
pub fn fields(&self) -> std::slice::Iter<Val... | {
fn into(self) -> Expression {
Expression::Literal(self.into())
}
}
impl Into<value::Literal> for Struct {
fn into(self) -> value::Literal {
value::Literal::Struct(self)
}
} | impl Into<Expression> for Struct | random_line_split |
main.rs | fn main() {
let mut sequence = String::from("1113122113");
for _ in 0..40 {
sequence = look_and_say(sequence);
}
println!("The length is {} :D", sequence.len());
}
fn | (s: String) -> String {
let mut ret = String::new();
let chars = s.chars().collect::<Vec<_>>();
let mut index = 0;
let mut current_run = None;
while index < s.len() {
let next_char = chars[index];
current_run = match current_run {
Some((c, length)) => {
i... | look_and_say | identifier_name |
main.rs | fn main() {
let mut sequence = String::from("1113122113");
for _ in 0..40 {
sequence = look_and_say(sequence);
}
println!("The length is {} :D", sequence.len());
}
fn look_and_say(s: String) -> String {
let mut ret = String::new();
let chars = s.chars().collect::<Vec<_>>();
let m... |
#[test]
fn b() {
assert_eq!(look_and_say(String::from("11")), "21");
}
#[test]
fn c() {
assert_eq!(look_and_say(String::from("21")), "1211");
}
#[test]
fn d() {
assert_eq!(look_and_say(String::from("1211")), "111221");
}
#[test]
fn e() {
assert_eq!(look_and_say(String::from("111221")), "312211");
}... | {
assert_eq!(look_and_say(String::from("1")), "11");
} | identifier_body |
main.rs | fn main() {
let mut sequence = String::from("1113122113");
for _ in 0..40 {
sequence = look_and_say(sequence);
}
println!("The length is {} :D", sequence.len());
}
fn look_and_say(s: String) -> String {
let mut ret = String::new();
let chars = s.chars().collect::<Vec<_>>();
let m... |
};
}
if let Some((c, length)) = current_run {
ret = format!("{}{}{}", ret, length, c);
}
ret
}
#[test]
fn a() {
assert_eq!(look_and_say(String::from("1")), "11");
}
#[test]
fn b() {
assert_eq!(look_and_say(String::from("11")), "21");
}
#[test]
fn c() {
assert_eq!(look_a... | {
index += 1;
Some((next_char, 1))
} | conditional_block |
main.rs | fn main() {
let mut sequence = String::from("1113122113");
for _ in 0..40 {
sequence = look_and_say(sequence);
}
println!("The length is {} :D", sequence.len());
}
fn look_and_say(s: String) -> String {
let mut ret = String::new();
let chars = s.chars().collect::<Vec<_>>();
let m... | fn b() {
assert_eq!(look_and_say(String::from("11")), "21");
}
#[test]
fn c() {
assert_eq!(look_and_say(String::from("21")), "1211");
}
#[test]
fn d() {
assert_eq!(look_and_say(String::from("1211")), "111221");
}
#[test]
fn e() {
assert_eq!(look_and_say(String::from("111221")), "312211");
} | random_line_split | |
location.rs | header! {
/// `Location` header, defined in
/// [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.1.2)
///
/// The `Location` header field is used in some responses to refer to a
/// specific resource in relation to the response. The type of
/// relationship is defined by the combination o... | // Testcase from RFC
test_header!(test1, vec![b"/People.html#tim"]);
test_header!(test2, vec![b"http://www.example.net/index.html"]);
}
}
bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] }); | // TODO: Use URL
(Location, "Location") => [String]
test_location { | random_line_split |
htmlselectelement.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;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... |
}
}
}
fn bind_to_tree(&self, tree_in_doc: bool) {
if let Some(ref s) = self.super_type() {
s.bind_to_tree(tree_in_doc);
}
self.upcast::<Element>().check_ancestors_disabled_state_for_form_control();
}
fn unbind_from_tree(&self, context: &UnbindC... | {
el.set_disabled_state(false);
el.set_enabled_state(true);
el.check_ancestors_disabled_state_for_form_control();
} | conditional_block |
htmlselectelement.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;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... | (&self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast())
}
// Note: this function currently only exists for union.html.
// https://html.spec.whatwg.org/multipage/#dom-select-add
fn Add(&self, _element: HTMLOptionElementOrHTMLOpt... | Validity | identifier_name |
htmlselectelement.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;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... |
}
impl FormControl for HTMLSelectElement {}
impl Validatable for HTMLSelectElement {}
| {
match *local_name {
atom!("size") => AttrValue::from_u32(value.into(), DEFAULT_SELECT_SIZE),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
} | identifier_body |
htmlselectelement.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;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... | last_selected = Some(Root::from_ref(opt.r()));
}
let element = opt.upcast::<Element>();
if first_enabled.is_none() &&!element.disabled_state() {
first_enabled = Some(Root::from_ref(opt.r()));
}
}
if let Some(last_selected) ... |
let node = self.upcast::<Node>();
for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) {
if opt.Selected() {
opt.set_selectedness(false); | random_line_split |
regions-implied-bounds-projection-gap-3.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 ... | () { }
| main | identifier_name |
regions-implied-bounds-projection-gap-3.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 ... | { } | identifier_body | |
regions-implied-bounds-projection-gap-3.rs | // 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 http://opensource.org/licenses/MIT>, at your
// option. This file... | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | random_line_split | |
mod.rs | // Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
// File-specific allowances to silence internal warnings of `py_class!`.
#![allow(
clippy::used_underscore_binding,
clippy::transmute_ptr_to_ptr,
clippy::zero_ptr
)]
pub mod engin... | data subject: PyObject;
def __new__(_cls, product: PyType, declared_subject: PyType, subject: PyObject) -> CPyResult<Self> {
Self::create_instance(py, product, declared_subject, subject)
}
});
py_class!(pub class PyGeneratorResponseGetMulti |py| {
data gets: PyTuple;
def __new__(_cls, gets: P... | data product: PyType;
data declared_subject: PyType; | random_line_split |
mod.rs | // Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
// File-specific allowances to silence internal warnings of `py_class!`.
#![allow(
clippy::used_underscore_binding,
clippy::transmute_ptr_to_ptr,
clippy::zero_ptr
)]
pub mod engin... | <T>(value: &PyObject, field: &str) -> Result<T, String>
where
for<'a> T: FromPyObject<'a>,
{
let gil = Python::acquire_gil();
let py = gil.python();
value
.getattr(py, field)
.map_err(|e| format!("Could not get field `{}`: {:?}", field, e))?
.extract::<T>(py)
.map_err(|e| {
format!(
"F... | getattr | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.